Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
toolbox::io::Reactor Class Reference

#include <toolbox/io/Reactor.hpp>

Inheritance diagram for toolbox::io::Reactor:
Inheritance graph
[legend]
Collaboration diagram for toolbox::io::Reactor:
Collaboration graph
[legend]

Classes

class  Handle
 

Public Types

enum class  HookType : int { EndOfCycleNoWait = 1 , EndOfEventDispatch = 2 }
 
using Event = EpollEvent
 

Public Member Functions

 Reactor (std::size_t size_hint=0)
 
 ~Reactor () override
 
 Reactor (const Reactor &)=delete
 
Reactoroperator= (const Reactor &)=delete
 
 Reactor (Reactor &&)=delete
 
Reactoroperator= (Reactor &&)=delete
 
Handle subscribe (int fd, unsigned events, IoSlot slot)
 
Timer timer (MonoTime expiry, Duration interval, Priority priority, TimerSlot slot)
 Throws std::bad_alloc only.
 
Timer timer (MonoTime expiry, Priority priority, TimerSlot slot)
 Throws std::bad_alloc only.
 
void add_hook (Hook &hook, HookType ht=HookType::EndOfCycleNoWait) noexcept
 
int poll (CyclTime now, Duration timeout=NoTimeout)
 
void yield () noexcept
 
void set_high_priority_poll_threshold (Micros thresh)
 
void set_user_high_priority_hook (PollSlot slot)
 
void set_user_hook_poll_threshold (Micros thresh)
 
- Public Member Functions inherited from toolbox::io::Waker
 Waker () noexcept=default
 
virtual ~Waker ()
 
 Waker (const Waker &) noexcept=default
 
Wakeroperator= (const Waker &) noexcept=default
 
 Waker (Waker &&) noexcept=default
 
Wakeroperator= (Waker &&) noexcept=default
 
void wakeup () noexcept
 

Protected Member Functions

void do_wakeup () noexcept final
 Thread-safe.
 

Detailed Description

Definition at line 34 of file Reactor.hpp.

Member Typedef Documentation

◆ Event

Definition at line 36 of file Reactor.hpp.

Member Enumeration Documentation

◆ HookType

Enumerator
EndOfCycleNoWait 
EndOfEventDispatch 

Definition at line 38 of file Reactor.hpp.

Constructor & Destructor Documentation

◆ Reactor() [1/3]

toolbox::io::Reactor::Reactor ( std::size_t  size_hint = 0)
explicit

Definition at line 45 of file Reactor.cpp.

◆ ~Reactor()

toolbox::io::Reactor::~Reactor ( )
override

Definition at line 52 of file Reactor.cpp.

◆ Reactor() [2/3]

toolbox::io::Reactor::Reactor ( const Reactor )
delete

◆ Reactor() [3/3]

toolbox::io::Reactor::Reactor ( Reactor &&  )
delete

Member Function Documentation

◆ operator=() [1/2]

Reactor & toolbox::io::Reactor::operator= ( const Reactor )
delete

◆ operator=() [2/2]

Reactor & toolbox::io::Reactor::operator= ( Reactor &&  )
delete

◆ subscribe()

Reactor::Handle toolbox::io::Reactor::subscribe ( int  fd,
unsigned  events,
IoSlot  slot 
)

Definition at line 57 of file Reactor.cpp.

◆ timer() [1/2]

Timer toolbox::io::Reactor::timer ( MonoTime  expiry,
Duration  interval,
Priority  priority,
TimerSlot  slot 
)
inline

Throws std::bad_alloc only.

Definition at line 148 of file Reactor.hpp.

◆ timer() [2/2]

Timer toolbox::io::Reactor::timer ( MonoTime  expiry,
Priority  priority,
TimerSlot  slot 
)
inline

Throws std::bad_alloc only.

Definition at line 153 of file Reactor.hpp.

◆ add_hook()

void toolbox::io::Reactor::add_hook ( Hook hook,
HookType  ht = HookType::EndOfCycleNoWait 
)
inlinenoexcept

Definition at line 159 of file Reactor.hpp.

◆ poll()

int toolbox::io::Reactor::poll ( CyclTime  now,
Duration  timeout = NoTimeout 
)

Poll for I/O and timer events. The thread-local cycle time is unconditionally updated after the call to epoll() returns.

Parameters
timeoutis ignored when immediate mode is used. Returns the number of events signalled.

Definition at line 72 of file Reactor.cpp.

◆ yield()

void toolbox::io::Reactor::yield ( )
noexcept

Definition at line 154 of file Reactor.cpp.

◆ set_high_priority_poll_threshold()

void toolbox::io::Reactor::set_high_priority_poll_threshold ( Micros  thresh)
inline

Definition at line 178 of file Reactor.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ set_user_high_priority_hook()

void toolbox::io::Reactor::set_user_high_priority_hook ( PollSlot  slot)
inline

Definition at line 180 of file Reactor.hpp.

◆ set_user_hook_poll_threshold()

void toolbox::io::Reactor::set_user_hook_poll_threshold ( Micros  thresh)
inline

Definition at line 181 of file Reactor.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ do_wakeup()

void toolbox::io::Reactor::do_wakeup ( )
finalprotectedvirtualnoexcept

Thread-safe.

Implements toolbox::io::Waker.

Definition at line 125 of file Reactor.cpp.


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