winss
Public Member Functions | List of all members
winss::WaitMultiplexer Class Reference

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...
 
WaitMultiplexeroperator= (const WaitMultiplexer &)=delete
 No copy. More...
 
WaitMultiplexeroperator= (WaitMultiplexer &&)=delete
 No move. More...
 

Detailed Description

A HANDLE wait multiplexer.

Constructor & Destructor Documentation

winss::WaitMultiplexer::WaitMultiplexer ( )
inline
winss::WaitMultiplexer::WaitMultiplexer ( const WaitMultiplexer )
delete

No copy.

winss::WaitMultiplexer::WaitMultiplexer ( WaitMultiplexer &&  )
delete

No move.

Member Function Documentation

void winss::WaitMultiplexer::AddCloseEvent ( const winss::EventWrapper close_event,
DWORD  return_code 
)
virtual

Add a close event to the multiplexer.

This will watch the event and stop the multiplexer with the given return code.

Parameters
close_eventThe event object to watch.
return_codeThe return code to exit with.

References winss::EventWrapper::GetHandle(), RemoveTriggeredCallback(), and Stop().

void winss::WaitMultiplexer::AddInitCallback ( winss::Callback  callback)
virtual
void winss::WaitMultiplexer::AddStopCallback ( winss::Callback  callback)
virtual
void winss::WaitMultiplexer::AddTimeoutCallback ( DWORD  timeout,
winss::Callback  callback,
std::string  group = "" 
)
virtual

Add a timeout item which given the timeout period will call the callback if it is not removed before that time.

Parameters
timeoutThe time in ms from now.
callbackThe callback to call on timeout event.
groupThe 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().

void winss::WaitMultiplexer::AddTriggeredCallback ( const winss::HandleWrapper handle,
winss::TriggeredCallback  callback 
)
virtual
int winss::WaitMultiplexer::GetReturnCode ( ) const
virtual

Gets the set return code of the multiplexer.

Returns
The return code.
DWORD winss::WaitMultiplexer::GetTimeout ( ) const
virtual

Gets the next timeout in ms from now.

Returns
The next timeout in ms from now.

References winss::WaitTimeoutItem::timeout.

bool winss::WaitMultiplexer::HasStarted ( ) const
virtual

Gets if the multiplexer is has started.

Returns
True if the multiplexer has started otherwise false.
bool winss::WaitMultiplexer::IsStopping ( ) const
virtual

Gets if the multiplexer is stopping.

Returns
True if the multiplexer is stopping otherwise false.

Referenced by winss::SuperviseTmpl< TMutex, TProcess >::Complete().

WaitMultiplexer& winss::WaitMultiplexer::operator= ( const WaitMultiplexer )
delete

No copy.

WaitMultiplexer& winss::WaitMultiplexer::operator= ( WaitMultiplexer &&  )
delete

No move.

bool winss::WaitMultiplexer::RemoveTimeoutCallback ( std::string  group)
virtual

Removes the timeout call back for the given group.

Parameters
groupThe 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().

bool winss::WaitMultiplexer::RemoveTriggeredCallback ( const winss::HandleWrapper handle)
virtual

Removes the triggered callback which matches the given handle.

Parameters
handleThe handle which the callback is associated with.

Referenced by AddCloseEvent(), and winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().

int winss::WaitMultiplexer::Start ( )
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.

Returns
The exit code which was set.

References winss::WaitTimeoutItem::callback, winss::FAILED, winss::TIMEOUT, winss::WaitTimeoutItem::timeout, winss::HandleWrapper::Wait(), and WINDOWS.

Referenced by winss::Control::Start().

void winss::WaitMultiplexer::Stop ( int  code)
virtual

The documentation for this class was generated from the following files: