Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Notifiable.hxx File Reference
#include <functional>
#include "os/OS.hxx"
#include "utils/Atomic.hxx"
#include "utils/Destructable.hxx"

Go to the source code of this file.

Classes

class  Notifiable
 An object that can schedule itself on an executor to run. More...
 
class  SyncNotifiable
 A Notifiable for synchronously waiting for a notification. More...
 
class  EmptyNotifiable
 A Notifiable that doesn't do anything when notified. More...
 
class  CrashNotifiable
 A Notifiable that will crash whenever called. More...
 
class  ProxyNotifiable
 A class for reliably detecting whether a Notification has happened yet or not. More...
 
class  BarrierNotifiable
 A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish. More...
 
class  AutoNotify
 This class sends a notification in its destructor. More...
 
class  TempNotifiable
 A notifiable class that calls a particular function object once when it is invoked, then deletes itself. More...
 

Macros

#define AutoNotify(l)   int error_omitted_autonotify_holder_variable[-1]
 If this error is presented, then the syntax of the AutoNotify was incorrectly used:
 

Functions

BarrierNotifiableNewBarrierNotifiable (Notifiable *done)
 Allocates a new barrier notifiable on the heap.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Basic building block of asynchronous operations: a zero-argument callback.

Author
Balazs Racz
Date
2 September 2013

Definition in file Notifiable.hxx.

Macro Definition Documentation

◆ AutoNotify

#define AutoNotify (   l)    int error_omitted_autonotify_holder_variable[-1]

If this error is presented, then the syntax of the AutoNotify was incorrectly used:

WRONG: AutoNotify(done); RIGHT: AutoNotify an(done);

Without the variable name the notification gets called immediately (since the temporary C++ object of type AutoNotifiable gets destructed immediately when the c++ statement fininshes), thus causing subtle concurrency bugs.

Definition at line 319 of file Notifiable.hxx.

Function Documentation

◆ NewBarrierNotifiable()

BarrierNotifiable * NewBarrierNotifiable ( Notifiable done)
inline

Allocates a new barrier notifiable on the heap.

The caller must free the returned pointer when the done notifiable is called.

Parameters
doneis the notifiable to call when the barrier is completed.
Returns
a new heap-allocated barrier notifiable.

Definition at line 256 of file Notifiable.hxx.