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)
 
- 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 30 of file Reactor.cpp.

◆ ~Reactor()

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

Definition at line 37 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 42 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 142 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 147 of file Reactor.hpp.

◆ add_hook()

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

Definition at line 153 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. Returns the number of events signalled.

Definition at line 56 of file Reactor.cpp.

◆ do_wakeup()

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

Thread-safe.

Implements toolbox::io::Waker.

Definition at line 108 of file Reactor.cpp.


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