VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GNet::FutureEvent Class Reference

An object that hooks into the event loop and calls back to the client code with a small unsigned integer payload. More...

#include <gfutureevent.h>

Public Types

typedef HWND handle_type
 

Public Member Functions

 FutureEvent (FutureEventHandler &)
 Constructor.
 
 ~FutureEvent ()
 Destructor.
 
handle_type handle () const
 Returns a handle that can be passed between threads and used in send(). More...
 

Static Public Member Functions

static bool send (handle_type handle, unsigned int payload) g__noexcept
 Pokes the event payload into the main event loop so that the callback is called once the stack is unwound. More...
 

Friends

class FutureEventImp
 

Detailed Description

An object that hooks into the event loop and calls back to the client code with a small unsigned integer payload.

The trigger function send() is typically called from a "future/promise" worker thread just before it finishes.

Eg:

struct Foo : private FutureEventHandler
{
Foo() ;
void onFutureEvent( unsigned int result ) ;
void run( FutureEvent::handle_type ) ;
FutureEvent m_future_event ;
std::thread m_thread ;
}
Foo::Foo() : m_thread(&Foo::run,this,m_future_event.handle())
{
}
void Foo::run( FutureEvent::handle_type h )
{
... // do blocking work
FutureEvent::send( h , 123 ) ;
}

Definition at line 62 of file gfutureevent.h.

Member Function Documentation

GNet::FutureEvent::handle_type GNet::FutureEvent::handle ( ) const

Returns a handle that can be passed between threads and used in send().

Definition at line 150 of file gfutureevent_unix.cpp.

bool GNet::FutureEvent::send ( handle_type  handle,
unsigned int  payload 
)
static

Pokes the event payload into the main event loop so that the callback is called once the stack is unwound.

Returns true on success.

Definition at line 145 of file gfutureevent_unix.cpp.


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