Skip to content

Commit

Permalink
Merge pull request #90 from karel-burda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
karel-burda authored Nov 26, 2018
2 parents 0cca31a + e0327ef commit 339ae18
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 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.0 LANGUAGES CXX)
project(timers VERSION 1.3.1 LANGUAGES CXX)

add_library(${PROJECT_NAME} INTERFACE)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Version](https://img.shields.io/badge/version-1.3.0-green.svg)
![Version](https://img.shields.io/badge/version-1.3.1-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)
Expand Down
2 changes: 1 addition & 1 deletion include/timers/async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static_assert(std::is_same<underlying_timer, periodic>::value || std::is_same<un
/// @throws std::future_error
void stop()
{
std::lock_guard<decltype(m_async_protection)> lock { m_async_protection };
const std::lock_guard<decltype(m_async_protection)> lock { m_async_protection };

underlying_timer::stop();

Expand Down
2 changes: 1 addition & 1 deletion include/timers/blocking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class blocking : private burda::cpp_utils::primitives::idisable_copy,
{
throw_if_time_invalid(time);

std::lock_guard<decltype(m_block_protection)> lock{ m_block_protection };
const std::lock_guard<decltype(m_block_protection)> lock{ m_block_protection };

std::unique_lock<decltype(m_cv_protection)> cv_lock{ m_cv_protection };
const auto terminated_after_interval_elapsed = !m_cv.wait_for(cv_lock, time, [&]
Expand Down
5 changes: 5 additions & 0 deletions include/timers/periodic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ class periodic : public single_shot
/// @see "single_shot::start"
void start(interval interval, callback callback, policies::start::exception policy = policies::start::get_default())
{
const std::lock_guard<decltype(m_periodic_protection)> lock{ m_periodic_protection };

while(single_shot::start(interval, callback, policy));
}

private:
std::mutex m_periodic_protection;
};
}
}
2 changes: 1 addition & 1 deletion tests/unit/src/periodic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TEST_F(periodic_test, start_in_parallel)
m_timer.start(1s, [&taskFinished2]() { taskFinished2 = true; });
});

std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(4s);

m_timer.stop();
starter1.wait();
Expand Down

0 comments on commit 339ae18

Please sign in to comment.