E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
GNet::FutureEvent Class Reference

An object that hooks into the event loop and calls back to the client code. More...

`#include <gfutureevent.h>`

## Public Types
typedef HANDLE | handle_type

## Public Member Functions
| FutureEvent (FutureEventHandler &, ExceptionHandler &)
| Constructor. Installs itself in the event loop.
| ~FutureEvent ()
| Destructor.
handle_type | handle ()
| Returns a handle that can be passed between threads and used in send(). More...

## Static Public Member Functions
static bool | send (handle_type handle) g__noexcept
| Pokes an event into the main event loop so that the FutureEventHandler callback is called asynchronously. More...

## Friends
class | FutureEventImp

## Detailed Description

An object that hooks into the event loop and calls back to the client code.

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

Eg:

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

Definition at line 62 of file gfutureevent.h.

## Member Function Documentation

GNet::FutureEvent::handle_type GNet::FutureEvent::handle | ( |  | ) |

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

This should be called once.

Definition at line 151 of file gfutureevent_unix.cpp.

bool GNet::FutureEvent::send | ( | handle_type | handle | ) |
| static

Pokes an event into the main event loop so that the FutureEventHandler callback is called asynchronously.

Should be called exactly once if handle() has been called.

This is safe even if the FutureEvent object has been deleted. Returns true on success.

Definition at line 146 of file gfutureevent_unix.cpp.

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

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/gfutureevent.h
- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/gfutureevent_unix.cpp