diff --git a/CMakeLists.txt b/CMakeLists.txt index 8888f98..3582f2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) -project(timers VERSION 1.3.3 LANGUAGES CXX) +project(timers VERSION 1.3.4 LANGUAGES CXX) add_library(${PROJECT_NAME} INTERFACE) diff --git a/README.md b/README.md index afda901..4a84390 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -![Version](https://img.shields.io/badge/version-1.3.3-green.svg) +![Version](https://img.shields.io/badge/version-1.3.4-green.svg) [![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE) [![Build Status](https://travis-ci.org/karel-burda/timers.svg?branch=master)](https://travis-ci.org/karel-burda/timers) [![Codecov Status](https://codecov.io/gh/karel-burda/timers/branch/master/graph/badge.svg)](https://codecov.io/gh/karel-burda/timers/branch/master) -# Important +## Important This project contains git sub-modules that are needed for building example and tests. If you just want to use the implementation, you can clone without sub-modules. In case you want to build the example or tests, be sure to clone the repository with `--recurse-submodules` or `--recursive` on older versions of git. Alternatively, you can clone without sub-modules and initialize these later. -# Introduction +## Introduction `timers` features a thread-safe and header-only library that's implementing timer-related functionality and provides following features: -* General blocking timer: `blocking` -* Single-shot timer that does given action after time period expires: `single_shot` -* Its asynchronous version: `single_shot_async` -* Timer that does some action periodically: `periodic` -* Its asynchronous version: `periodic_async` -* Scoped "RAII" timer that stops underlying timer automatically upon destruction: `scoped` + * General blocking timer: `blocking` + * Single-shot timer that does given action after time period expires: `single_shot` + * Its asynchronous version: `single_shot_async` + * Timer that does some action periodically: `periodic` + * Its asynchronous version: `periodic_async` + * Scoped "RAII" timer that stops underlying timer automatically upon destruction: `scoped` Implemented using C++11 with the use of `std::conditional_variable`, `std::promise` and `std::async`. @@ -24,27 +24,27 @@ Client defines timer's action that should be of type `timers::callback`, thus `s Time intervals are being defined as `timers::interval` = `std::chrono::duration`. Implementation might throw these exceptions upon the `start(...)`: -* `callback_not_callable` -* `time_period_is_zero` -* `time_period_is_negative` + * `callback_not_callable` + * `time_period_is_zero` + * `time_period_is_negative` See [exceptions.hpp](include/timers/exceptions.hpp) for more info. Policies specifies how timer class will behave when exception is thrown from the user's callback: -* `stop` -- causes the timer to call `stop()` on itself and re-throws catched exception -* `ignore` -- causes the timer to ignore catched exception and keep on working + * `stop` -- causes the timer to call `stop()` on itself and re-throws catched exception + * `ignore` -- causes the timer to ignore catched exception and keep on working See [policies.hpp](include/timers/policies.hpp). -# Usage +## Usage Implementation resides in the `burda::timers` namespace, so it might be useful to do `namespace timers = burda::timers;` in your project. -## 1. CMake Way +### 1. CMake Way Recommended option. There are essentially these ways of how to use this package depending on your preferences our build architecture: -### A) Generate directly +#### A) Generate directly Call `add_subdirectory(...)` directly in your CMakeLists.txt: @@ -64,7 +64,7 @@ target_link_libraries(my-project timers) # or with private visibility: target_link_libraries(my-project PRIVATE timers) ``` -### B) Generate separately +#### B) Generate separately Generation phase on the timers is run separately, that means that you run: ```cmake @@ -90,14 +90,14 @@ target_link_libraries(my-project burda::timers) # or with public visibility: target_link_libraries(my-project PUBLIC burda::timers) ``` -## 2. Manual Way +### 2. Manual Way Not recommended. Make sure that the `include` directory is in the search paths. You also have to set C++ 11 standard and potentially other settings as well (e.g. linking `pthread` on POSIXes, etc.). -# Example +## Examples For full use cases, see [main.cpp](example/src/main.cpp) or implementation of unit tests at [tests/unit](tests/unit). ### Blocking @@ -203,7 +203,7 @@ foo.work(); For full use cases, see [main.cpp](example/src/main.cpp) or implementation of unit tests at [tests/unit](tests/unit). -# Unit Tests +## Unit Tests Tests require sub-modules [cmake-helpers](https://github.com/karel-burda/cmake-helpers), [cpp-utils](https://github.com/karel-burda/cpp-utils) and [test-utils](https://github.com/karel-burda/test-utils). For building tests, run CMake in the source directory [tests/unit](tests/unit): @@ -228,7 +228,7 @@ This is the example of running tests in the debug mode. For more info, see [.travis.yml](.travis.yml). -# Continuous Integration +## Continuous Integration Continuous Integration is now being run Linux, OS X and Windows on Travis: https://travis-ci.org/karel-burda/timers. Compilers are set-up to treat warnings as errors and with pedantic warning level. @@ -237,8 +237,8 @@ Targets are built in one stage with debug symbols with code coverage measure and Valgrind is being run on the example as well. The project is using these jobs: -* `timers, example, tests -- linux, debug, cppcheck, valgrind, coverage, g++, 64-bit` -* `timers, example, tests -- osx, release with debug info, clang++, 64-bit` -* `timers, example, tests -- windows, release, msvc, 32-bit` + * `timers, example, tests -- linux, debug, cppcheck, valgrind, coverage, g++, 64-bit` + * `timers, example, tests -- osx, release with debug info, clang++, 64-bit` + * `timers, example, tests -- windows, release, msvc, 32-bit` Project uses [codecov.io](https://codecov.io/gh/karel-burda/timers) for code coverage summary. diff --git a/submodules/cmake-helpers b/submodules/cmake-helpers index c5a7b95..3a3c672 160000 --- a/submodules/cmake-helpers +++ b/submodules/cmake-helpers @@ -1 +1 @@ -Subproject commit c5a7b953cb33755c9e06534acd15ea476d589adb +Subproject commit 3a3c672f038690ce9d22855c63b99a570ae2412a diff --git a/submodules/cpp-utils b/submodules/cpp-utils index 1c476f2..89739e2 160000 --- a/submodules/cpp-utils +++ b/submodules/cpp-utils @@ -1 +1 @@ -Subproject commit 1c476f231d2d3e3d24618a7e65007974917c118c +Subproject commit 89739e2add774d7072faeb75851fb4ff46b6f500 diff --git a/submodules/test-utils b/submodules/test-utils index e4ebea6..6e8fc19 160000 --- a/submodules/test-utils +++ b/submodules/test-utils @@ -1 +1 @@ -Subproject commit e4ebea6eb328b94b9a26b23a610dc9c7da7afa2d +Subproject commit 6e8fc198f5920be675ae01a5ff0f9f7c98166a24