use an atomic to control thread-enabled
This commit is contained in:
parent
50f3145f9e
commit
188a403726
|
@ -36,7 +36,7 @@ namespace sACN {
|
|||
* @param source
|
||||
* @param universe
|
||||
*/
|
||||
UniverseSender::UniverseSender(Source * source, Universe * universe)
|
||||
UniverseSender::UniverseSender(Source *source, Universe *universe)
|
||||
: mSource(source)
|
||||
, mUniverse(universe)
|
||||
, terminated_resend(3)
|
||||
|
@ -113,10 +113,7 @@ void UniverseSender::flush()
|
|||
*/
|
||||
void UniverseSender::kill()
|
||||
{
|
||||
{
|
||||
std::unique_lock lk_ctl(mtx_control);
|
||||
enabled_ = false;
|
||||
}
|
||||
enabled_ = false;
|
||||
flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "data.h"
|
||||
#include "dmp.h"
|
||||
#include "../dmx/universe.h"
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
@ -81,9 +82,9 @@ private:
|
|||
/// > intervals of between 800mS and 1000mS.
|
||||
const std::chrono::milliseconds keep_alive_interval;
|
||||
|
||||
volatile bool enabled_;
|
||||
mutable std::shared_mutex mtx_control;
|
||||
mutable std::mutex mtx_thread_;
|
||||
std::atomic<bool> enabled_;
|
||||
std::condition_variable_any request_;
|
||||
std::thread worker_;
|
||||
void loop_();
|
||||
|
|
Loading…
Reference in New Issue