winss
|
A HANDLE wait multiplexer. More...
#include <wait_multiplexer.hpp>
Public Member Functions | |
WaitMultiplexer () | |
The default constructor. More... | |
WaitMultiplexer (const WaitMultiplexer &)=delete | |
No copy. More... | |
WaitMultiplexer (WaitMultiplexer &&)=delete | |
No move. More... | |
virtual void | AddInitCallback (Callback callback) |
Add an initialization callback. More... | |
virtual void | AddTriggeredCallback (const winss::HandleWrapper &handle, TriggeredCallback callback) |
Add a triggered callback for when an event happens on the given handle. More... | |
virtual void | AddTimeoutCallback (DWORD timeout, Callback callback, std::string group="") |
Add a timeout item which given the timeout period will call the callback if it is not removed before that time. More... | |
virtual void | AddStopCallback (Callback callback) |
Add a stop callback. More... | |
virtual bool | RemoveTriggeredCallback (const winss::HandleWrapper &handle) |
Removes the triggered callback which matches the given handle. More... | |
virtual bool | RemoveTimeoutCallback (std::string group) |
Removes the timeout call back for the given group. More... | |
virtual DWORD | GetTimeout () const |
Gets the next timeout in ms from now. More... | |
virtual int | Start () |
Starts the multiplexer which will block until some other event stops it. More... | |
virtual void | Stop (int code) |
Stops the multiplexer with the given code if one has not already been set. More... | |
virtual bool | IsStopping () const |
Gets if the multiplexer is stopping. More... | |
virtual bool | HasStarted () const |
Gets if the multiplexer is has started. More... | |
virtual int | GetReturnCode () const |
Gets the set return code of the multiplexer. More... | |
virtual void | AddCloseEvent (const winss::EventWrapper &close_event, DWORD return_code) |
Add a close event to the multiplexer. More... | |
WaitMultiplexer & | operator= (const WaitMultiplexer &)=delete |
No copy. More... | |
WaitMultiplexer & | operator= (WaitMultiplexer &&)=delete |
No move. More... | |
A HANDLE wait multiplexer.
|
inline |
The default constructor.
References winss::WaitTimeoutItem::callback, winss::WaitTimeoutItem::group, and winss::WaitTimeoutItem::timeout.
|
delete |
No copy.
|
delete |
No move.
|
virtual |
Add a close event to the multiplexer.
This will watch the event and stop the multiplexer with the given return code.
close_event | The event object to watch. |
return_code | The return code to exit with. |
References winss::EventWrapper::GetHandle(), RemoveTriggeredCallback(), and Stop().
|
virtual |
Add an initialization callback.
callback | The initialization callback. |
Referenced by winss::Control::Add(), winss::Control::Control(), winss::PipeServer< TPipeInstance >::PipeServer(), winss::SuperviseTmpl< TMutex, TProcess >::SuperviseTmpl(), and winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
virtual |
Add a stop callback.
callback | The stop callback. |
Referenced by winss::PipeClient< TInstance, PipeClientReceiveListener >::Connect(), winss::Control::Control(), winss::PipeServer< TPipeInstance >::PipeServer(), winss::SuperviseTmpl< TMutex, TProcess >::SuperviseTmpl(), and winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
virtual |
Add a timeout item which given the timeout period will call the callback if it is not removed before that time.
timeout | The time in ms from now. |
callback | The callback to call on timeout event. |
group | The group to identify the callback. |
References winss::WaitTimeoutItem::group.
Referenced by winss::Control::Control(), winss::SvScanTmpl< TService, TMutex, TProcess >::Schedule(), winss::SuperviseTmpl< TMutex, TProcess >::StartFinish(), and winss::SuperviseTmpl< TMutex, TProcess >::Triggered().
|
virtual |
Add a triggered callback for when an event happens on the given handle.
handle | The handle which will be watched. |
callback | The initialization callback. |
References winss::WaitTimeoutItem::callback, and winss::HandleWrapper::HasHandle().
Referenced by winss::PipeClient< TInstance, PipeClientReceiveListener >::Connect(), winss::PipeServer< TPipeInstance >::StartClient(), winss::SuperviseTmpl< TMutex, TProcess >::StartFinish(), winss::SuperviseTmpl< TMutex, TProcess >::StartRun(), winss::SvScanTmpl< TService, TMutex, TProcess >::Stop(), winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl(), winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate(), winss::PipeClient< TInstance, PipeClientReceiveListener >::Triggered(), and winss::PipeServer< TPipeInstance >::Triggered().
|
virtual |
Gets the set return code of the multiplexer.
|
virtual |
Gets the next timeout in ms from now.
References winss::WaitTimeoutItem::timeout.
|
virtual |
Gets if the multiplexer is has started.
|
virtual |
Gets if the multiplexer is stopping.
Referenced by winss::SuperviseTmpl< TMutex, TProcess >::Complete().
|
delete |
No copy.
|
delete |
No move.
|
virtual |
Removes the timeout call back for the given group.
group | The group which the timeout callback is associated with. |
Referenced by winss::Control::Control(), winss::SvScanTmpl< TService, TMutex, TProcess >::Scan(), winss::SvScanTmpl< TService, TMutex, TProcess >::Stop(), and winss::SuperviseTmpl< TMutex, TProcess >::Triggered().
|
virtual |
Removes the triggered callback which matches the given handle.
handle | The handle which the callback is associated with. |
Referenced by AddCloseEvent(), and winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
virtual |
Starts the multiplexer which will block until some other event stops it.
It will go into a loop calling WaitForMultipleObjects with all handles and the next timeout. When this returns the multiplexer will work out which event fired or timed out and will call the appropriate callback.
References winss::WaitTimeoutItem::callback, winss::FAILED, winss::TIMEOUT, winss::WaitTimeoutItem::timeout, winss::HandleWrapper::Wait(), and WINDOWS.
Referenced by winss::Control::Start().
|
virtual |
Stops the multiplexer with the given code if one has not already been set.
code | The exit code to stop with. |
References winss::WaitTimeoutItem::callback.
Referenced by AddCloseEvent(), winss::SuperviseTmpl< TMutex, TProcess >::Complete(), winss::Control::Control(), winss::SvScanTmpl< TService, TMutex, TProcess >::Exit(), winss::SvScanTmpl< TService, TMutex, TProcess >::Init(), winss::SuperviseTmpl< TMutex, TProcess >::Init(), winss::Control::Remove(), and winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate().