Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+65
@@ -0,0 +1,65 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <dds/core/cond/Condition.hpp>
|
||||
#include <dds/core/cond/GuardCondition.hpp>
|
||||
#include <dds/core/cond/WaitSet.hpp>
|
||||
|
||||
#include <future>
|
||||
#include <map>
|
||||
#include <DDS/Generic/ddsgen_export.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DDSGeneric
|
||||
{
|
||||
class DDSGEN_EXPORT WaitSetHandler final
|
||||
{
|
||||
public:
|
||||
class CallbackInterface
|
||||
{
|
||||
public:
|
||||
virtual ~CallbackInterface() = default;
|
||||
virtual void dataAvailable() = 0;
|
||||
};
|
||||
|
||||
WaitSetHandler();
|
||||
~WaitSetHandler();
|
||||
|
||||
bool attachWaitSet(const dds::core::cond::Condition &cond, CallbackInterface *cb);
|
||||
bool detachWaitSet(const dds::core::cond::Condition &cond, CallbackInterface *cb);
|
||||
bool enableWaitSet(const dds::core::cond::Condition &cond, CallbackInterface *cb);
|
||||
bool disableWaitSet(const dds::core::cond::Condition &cond, CallbackInterface *cb);
|
||||
|
||||
int attachedConditionCount() const;
|
||||
|
||||
private:
|
||||
struct WaitSetData final
|
||||
{
|
||||
dds::core::cond::Condition condition;
|
||||
CallbackInterface *callback = nullptr;
|
||||
bool enabled = true;
|
||||
bool needWaitSetAttach = false;
|
||||
|
||||
WaitSetData(const dds::core::cond::Condition &cond, CallbackInterface *cb)
|
||||
: condition(cond)
|
||||
, callback(cb)
|
||||
{}
|
||||
};
|
||||
private:
|
||||
void waitSetTask();
|
||||
private:
|
||||
|
||||
dds::core::cond::WaitSet m_waitSet;
|
||||
dds::core::cond::GuardCondition m_abortCondition;
|
||||
std::future<void> m_task;
|
||||
std::mutex m_accessMutex;
|
||||
std::map<const DDS_Condition *, WaitSetData> m_waitSetData;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user