Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
toolbox::io Namespace Reference

Classes

class  BasicDisposer
 
class  BasicHandle
 
class  Buffer
 
class  Epoll
 
class  EventFd
 
struct  FilePolicy
 
class  FileWatcher
 FileWatcher watches for changes to files. More...
 
struct  Hook
 
class  Inotify
 Inotify provides a simplified interface to an inotify instance. More...
 
struct  MsgEvent
 
class  OStream
 
class  Reactor
 
class  ReactorRunner
 
class  StreamBuf
 
class  Timer
 
class  TimerFd
 
class  TimerPool
 
class  TimerQueue
 
class  Waker
 
struct  WatchFile
 
struct  WatchFilePolicy
 

Typedefs

using ConstBuffer = boost::asio::const_buffer
 
using MutableBuffer = boost::asio::mutable_buffer
 
using EpollEvent = epoll_event
 
using FileHandle = BasicHandle< FilePolicy >
 
using HookList = boost::intrusive::list< Hook, boost::intrusive::constant_time_size< false > >
 
using WatchFileHandle = BasicHandle< WatchFilePolicy >
 
using IoSlot = BasicSlot< CyclTime, int, unsigned >
 
using HistogramPtr = std::unique_ptr< Histogram >
 
using MetricCallbackFunction = std::function< void(CyclTime now, HistogramPtr &&time_hist, HistogramPtr &&work_hist)>
 MetricCallbackFunction implementer is responsible for deleting the Histogram.
 
using LoopCallbackFunction = std::function< void(CyclTime now)>
 LoopCallbackFunction called at end of each Reactor loop, indicating micros taken and work done.
 
using TimerSlot = BasicSlot< CyclTime, Timer & >
 

Enumerations

enum  : unsigned {
  EpollIn = EPOLLIN , EpollOut = EPOLLOUT , EpollRdHup = EPOLLRDHUP , EpollPri = EPOLLPRI ,
  EpollErr = EPOLLERR , EpollHup = EPOLLHUP , EpollEt = EPOLLET , EpollOneShot = EPOLLONESHOT
}
 
enum class  Priority { High = 0 , Low = 1 }
 

Functions

ConstBuffer advance (ConstBuffer buf, std::size_t n) noexcept
 
MutableBuffer advance (MutableBuffer buf, std::size_t n) noexcept
 
template<typename DataT >
void emplace_event (MsgEvent &ev, int type) noexcept
 
template<typename DataT , typename... ArgsT>
void emplace_event (MsgEvent &ev, int type, ArgsT &&... args) noexcept
 
template<typename DataT >
const DataTdata (const MsgEvent &ev) noexcept
 
template<typename DataT >
DataTdata (MsgEvent &ev) noexcept
 
std::size_t file_size (int fd)
 Get file size.
 
mode_t file_mode () noexcept
 Get current file mode.
 
void set_non_block (int fd, std::error_code &ec) noexcept
 
void set_non_block (int fd)
 
template<typename PolicyT >
constexpr bool operator== (const BasicHandle< PolicyT > &lhs, const BasicHandle< PolicyT > &rhs)
 
template<typename PolicyT >
constexpr bool operator!= (const BasicHandle< PolicyT > &lhs, const BasicHandle< PolicyT > &rhs)
 
void dispatch (CyclTime now, const HookList &l) noexcept
 
constexpr bool operator== (WatchFile lhs, WatchFile rhs)
 
constexpr bool operator!= (WatchFile lhs, WatchFile rhs)
 
FileHandle inotify_init (int flags, std::error_code &ec) noexcept
 Initialise an inotify instance.
 
FileHandle inotify_init (std::error_code &ec) noexcept
 Initialise an inotify instance.
 
FileHandle inotify_init (int flags=0)
 
WatchFileHandle inotify_add_watch (int fd, const char *path, std::uint32_t mask, std::error_code &ec) noexcept
 Add a watch to an initialised inotify instance.
 
WatchFileHandle inotify_add_watch (int fd, const char *path, std::uint32_t mask)
 Add a watch to an initialised inotify instance.
 
void intrusive_ptr_release (Timer::Impl *impl) noexcept
 
void intrusive_ptr_add_ref (Timer::Impl *impl) noexcept
 
std::ostream & operator<< (std::ostream &os, const Timer &tmr)
 

Variables

constexpr Duration NoTimeout {-1}
 

Typedef Documentation

◆ ConstBuffer

using toolbox::io::ConstBuffer = typedef boost::asio::const_buffer

Definition at line 28 of file Buffer.hpp.

◆ MutableBuffer

using toolbox::io::MutableBuffer = typedef boost::asio::mutable_buffer

Definition at line 29 of file Buffer.hpp.

◆ EpollEvent

Definition at line 155 of file Epoll.hpp.

◆ FileHandle

Definition at line 108 of file Handle.hpp.

◆ HookList

using toolbox::io::HookList = typedef boost::intrusive::list<Hook, boost::intrusive::constant_time_size<false> >

Definition at line 39 of file Hook.hpp.

◆ WatchFileHandle

Definition at line 50 of file Inotify.hpp.

◆ IoSlot

Definition at line 32 of file Reactor.hpp.

◆ HistogramPtr

Definition at line 31 of file Runner.hpp.

◆ MetricCallbackFunction

MetricCallbackFunction implementer is responsible for deleting the Histogram.

Definition at line 34 of file Runner.hpp.

◆ LoopCallbackFunction

LoopCallbackFunction called at end of each Reactor loop, indicating micros taken and work done.

Definition at line 37 of file Runner.hpp.

◆ TimerSlot

Definition at line 34 of file Timer.hpp.

Enumeration Type Documentation

◆ anonymous enum

Enumerator
EpollIn 

The associated file is available for read(2) operations.

EpollOut 

The associated file is available for write(2) operations.

EpollRdHup 

Stream socket peer closed connection, or shut down writing half of connection. (This flag is especially useful for writing simple code to detect peer shutdown when using Edge-Triggered monitoring.)

EpollPri 

There is an exceptional condition on the file descriptor. See the discussion of POLLPRI in poll(2).

EpollErr 

Error condition happened on the associated file descriptor. This event is also reported for the write end of a pipe when the read end has been closed. epoll_wait(2) will always report for this event; it is not necessary to set it in events.

EpollHup 

Hang up happened on the associated file descriptor. epoll_wait(2) will always wait for this event; it is not necessary to set it in events.

Note that when reading from a channel such as a pipe or a stream socket, this event merely indicates that the peer closed its end of the channel. Subsequent reads from the channel will return 0 (end of file) only after all outstanding data in the channel has been consumed.

EpollEt 

Sets the Edge-Triggered behavior for the associated file descriptor. The default behavior for epoll is Level-Triggered. See epoll(7) for more detailed information about Edge and Level-Triggered event distribution architectures.

EpollOneShot 

Sets the one-shot behavior for the associated file descriptor. This means that after an event is pulled out with epoll_wait(2) the associated file descriptor is internally disabled and no other events will be reported by the epoll interface. The user must call epoll_ctl() with EPOLL_CTL_MOD to rearm the file descriptor with a new event mask.

Definition at line 113 of file Epoll.hpp.

◆ Priority

Enumerator
High 
Low 

Definition at line 30 of file Reactor.hpp.

Function Documentation

◆ advance() [1/2]

TOOLBOX_API ConstBuffer toolbox::io::advance ( ConstBuffer  buf,
std::size_t  n 
)
noexcept

Definition at line 48 of file Buffer.cpp.

◆ advance() [2/2]

TOOLBOX_API MutableBuffer toolbox::io::advance ( MutableBuffer  buf,
std::size_t  n 
)
noexcept

Definition at line 56 of file Buffer.cpp.

◆ emplace_event() [1/2]

template<typename DataT >
void toolbox::io::emplace_event ( MsgEvent ev,
int  type 
)
noexcept

Definition at line 34 of file Event.hpp.

◆ emplace_event() [2/2]

template<typename DataT , typename... ArgsT>
void toolbox::io::emplace_event ( MsgEvent ev,
int  type,
ArgsT &&...  args 
)
noexcept

Definition at line 44 of file Event.hpp.

◆ data() [1/2]

template<typename DataT >
const DataT & toolbox::io::data ( const MsgEvent ev)
noexcept

Definition at line 54 of file Event.hpp.

◆ data() [2/2]

template<typename DataT >
DataT & toolbox::io::data ( MsgEvent ev)
noexcept

Definition at line 60 of file Event.hpp.

◆ file_size()

std::size_t toolbox::io::file_size ( int  fd)
inline

Get file size.

Definition at line 255 of file File.hpp.

◆ file_mode()

mode_t toolbox::io::file_mode ( )
inlinenoexcept

Get current file mode.

Definition at line 263 of file File.hpp.

◆ set_non_block() [1/2]

void toolbox::io::set_non_block ( int  fd,
std::error_code &  ec 
)
inlinenoexcept

Definition at line 270 of file File.hpp.

◆ set_non_block() [2/2]

void toolbox::io::set_non_block ( int  fd)
inline

Definition at line 275 of file File.hpp.

◆ operator==() [1/2]

template<typename PolicyT >
constexpr bool toolbox::io::operator== ( const BasicHandle< PolicyT > &  lhs,
const BasicHandle< PolicyT > &  rhs 
)
constexpr

Definition at line 91 of file Handle.hpp.

◆ operator!=() [1/2]

template<typename PolicyT >
constexpr bool toolbox::io::operator!= ( const BasicHandle< PolicyT > &  lhs,
const BasicHandle< PolicyT > &  rhs 
)
constexpr

Definition at line 97 of file Handle.hpp.

◆ dispatch()

TOOLBOX_API void toolbox::io::dispatch ( CyclTime  now,
const HookList l 
)
noexcept

Definition at line 24 of file Hook.cpp.

Referenced by toolbox::io::Reactor::poll().

◆ operator==() [2/2]

constexpr bool toolbox::io::operator== ( WatchFile  lhs,
WatchFile  rhs 
)
constexpr

Definition at line 34 of file Inotify.hpp.

◆ operator!=() [2/2]

constexpr bool toolbox::io::operator!= ( WatchFile  lhs,
WatchFile  rhs 
)
constexpr

Definition at line 39 of file Inotify.hpp.

◆ inotify_init() [1/3]

FileHandle toolbox::io::inotify_init ( int  flags,
std::error_code &  ec 
)
inlinenoexcept

Initialise an inotify instance.

Definition at line 53 of file Inotify.hpp.

◆ inotify_init() [2/3]

FileHandle toolbox::io::inotify_init ( std::error_code &  ec)
inlinenoexcept

Initialise an inotify instance.

Definition at line 63 of file Inotify.hpp.

◆ inotify_init() [3/3]

FileHandle toolbox::io::inotify_init ( int  flags = 0)
inline

Initialise an inotify instance and returns a file descriptor associated with a new inotify event queue.

Definition at line 70 of file Inotify.hpp.

◆ inotify_add_watch() [1/2]

WatchFileHandle toolbox::io::inotify_add_watch ( int  fd,
const char path,
std::uint32_t  mask,
std::error_code &  ec 
)
inlinenoexcept

Add a watch to an initialised inotify instance.

Definition at line 80 of file Inotify.hpp.

◆ inotify_add_watch() [2/2]

WatchFileHandle toolbox::io::inotify_add_watch ( int  fd,
const char path,
std::uint32_t  mask 
)
inline

Add a watch to an initialised inotify instance.

Definition at line 92 of file Inotify.hpp.

◆ intrusive_ptr_release()

TOOLBOX_API void toolbox::io::intrusive_ptr_release ( Timer::Impl impl)
noexcept

Definition at line 181 of file Timer.cpp.

◆ intrusive_ptr_add_ref()

void toolbox::io::intrusive_ptr_add_ref ( Timer::Impl impl)
inlinenoexcept

Definition at line 186 of file Timer.hpp.

◆ operator<<()

std::ostream & toolbox::io::operator<< ( std::ostream &  os,
const Timer tmr 
)

Definition at line 31 of file Timer.ut.cpp.

Variable Documentation

◆ NoTimeout

constexpr Duration toolbox::io::NoTimeout {-1}
constexpr

Definition at line 29 of file Reactor.hpp.

Referenced by toolbox::io::Reactor::poll().