Skip to content

Commit

Permalink
Merge pull request #94 from karel-burda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
karel-burda authored Dec 28, 2018
2 parents e9951da + 6daf66d commit dd7b1cb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
![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`.

Client defines timer's action that should be of type `timers::callback`, thus `std::function<void()>`.
Time intervals are being defined as `timers::interval` = `std::chrono::duration<double>`.

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:

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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.
Expand All @@ -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.
2 changes: 1 addition & 1 deletion submodules/cmake-helpers
Submodule cmake-helpers updated 2 files
+1 −1 CMakeLists.txt
+9 −9 README.md
2 changes: 1 addition & 1 deletion submodules/cpp-utils
2 changes: 1 addition & 1 deletion submodules/test-utils

0 comments on commit dd7b1cb

Please sign in to comment.