Reactor¶
pembroke::Reactor¶
-
class
pembroke::Reactor¶ Class representing the main event-loop.
- See
- See
pembroke::reactor()
Public Functions
-
Reactor(const ReactorBuilder &builder)¶ Construct a new reactor object given a builder containing configuration information.
- See
pembroke::reactor()
- See
- Note
Throws and exception if the event-loop fails to construct, which would likely be a product of any custom configuration settings given. Unfortunately exact details are not available on which configuration caused the issue due to insufficient error reporting in libevent.
- Parameters
builder: ReactorBuilder object constructed from pembroke::reactor()
-
auto
run_blocking() const noexcept -> bool¶ Run the reactor in a blocking fashion and do not exit.
- Note
In order to exit the event-loop, you will need to call
pause()from an event in the reactor. You can continue in a blocking fashion by re-calling this method.- See
pause()
- Return
True if the loop ran successfully, False otherwise
-
auto
tick() const noexcept -> bool¶ Run the event-loop once. If there are no active events then this mehtod will return immediately. If there are active events, then tick() will wait for them to finish and execute the callbacks before returning.
- Note
If you only want to execute ready-events, use
tick_fast()- See
- Return
True if the loop ran successfully, False otherwise
-
auto
tick_fast() const noexcept -> bool¶ Run the event-loop once, much like tick(). However this function will only execute the callbacks of events that are ready.
-
auto
stop() const noexcept -> bool¶ Stop the reactor, returning control to the portion of code that invoked the blocking run (
blocking_run()). If the reactor is not running, this function will have no success.- See
blocking_run()
- Return
True if the reactor was successfully stopped (or if the reactor was not runnig), False if an error was encountered while attempting to stop.