volatile varibles in favor of std::atmoc<>

This commit is contained in:
Jinhao
2018-08-11 00:46:07 +08:00
parent 04e57771a4
commit a5f0d013c5
6 changed files with 18 additions and 14 deletions

View File

@@ -23,6 +23,8 @@
#include <windows.h>
#endif
#include <atomic>
namespace nana{ namespace audio
{
namespace detail
@@ -52,8 +54,8 @@ namespace nana{ namespace audio
private:
void _m_prepare_routine();
private:
volatile bool running_;
volatile bool wait_for_buffer_;
std::atomic<bool> running_;
std::atomic<bool> wait_for_buffer_;
std::thread thr_;
mutable std::mutex token_buffer_, token_prepared_;
mutable std::condition_variable cond_buffer_, cond_prepared_;

View File

@@ -193,7 +193,7 @@ namespace nana{ namespace pat{
cwrapper_.reset();
}
operator operator_bool_t() const volatile noexcept
operator operator_bool_t() const noexcept
{
return (fast_ptr_ ? &inner_bool::true_stand : nullptr);
}

View File

@@ -1,6 +1,6 @@
/*
* Timepiece Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,11 +21,11 @@ namespace system
{
public:
timepiece();
timepiece(const volatile timepiece&);
timepiece(const timepiece&);
~timepiece();
timepiece & operator=(const volatile timepiece &);
void start() volatile; ///< Set the begin time.
double calc() const volatile; ///< Get the intervals from the begin time.
timepiece & operator=(const timepiece &);
void start() noexcept; ///< Set the begin time.
double calc() const noexcept; ///< Get the intervals from the begin time.
private:
struct impl_t;
impl_t * impl_;