glibmm: Glib::SignalIO Class Reference

#include <glibmm/main.h>

Public Member Functions

sigc::connection connect (const sigc::slot< bool(IOCondition)>& slot, PollFD::fd_t fd, IOCondition condition, int priority=PRIORITY_DEFAULT)
 Connects an I/O handler that watches a file descriptor. More...

 
sigc::connection connect (const sigc::slot< bool(IOCondition)>& slot, const Glib::RefPtr< IOChannel >& channel, IOCondition condition, int priority=PRIORITY_DEFAULT)
 Connects an I/O handler that watches an I/O channel. More...

 

Member Function Documentation

sigc::connection Glib::SignalIO::connect ( const sigc::slot< bool(IOCondition)>&  slot,
PollFD::fd_t  fd,
IOCondition  condition,
int  priority = PRIORITY_DEFAULT 
)

Connects an I/O handler that watches a file descriptor.

bool io_handler(Glib::IOCondition io_condition) { ... }

is equivalent to:

bool io_handler(Glib::IOCondition io_condition) { ... }
const auto io_source = Glib::IOSource::create(fd, Glib::IO_IN | Glib::IO_HUP);
io_source->connect(sigc::ptr_fun(& io_handler));
io_source->attach(Glib::MainContext::get_default());

This method is not thread-safe. You should call it, or manipulate the returned sigc::connection object, only from the thread where the SignalIO object's MainContext runs.

Parameters
slotA slot to call when polling fd results in an event that matches condition. The event will be passed as a parameter to slot. If io_handler() returns false the handler is disconnected.
fdThe file descriptor (or a HANDLE on Win32 systems) to watch.
conditionThe conditions to watch for.
priorityThe priority of the new event source.
Returns
A connection handle, which can be used to disconnect the handler.
sigc::connection Glib::SignalIO::connect ( const sigc::slot< bool(IOCondition)>&  slot,
const Glib::RefPtr< IOChannel >&  channel,
IOCondition  condition,
int  priority = PRIORITY_DEFAULT 
)

Connects an I/O handler that watches an I/O channel.

bool io_handler(Glib::IOCondition io_condition) { ... }

is equivalent to:

bool io_handler(Glib::IOCondition io_condition) { ... }
const auto io_source = Glib::IOSource::create(channel, Glib::IO_IN | Glib::IO_HUP);
io_source->connect(sigc::ptr_fun(& io_handler));
io_source->attach(Glib::MainContext::get_default());

This method is not thread-safe. You should call it, or manipulate the returned sigc::connection object, only from the thread where the SignalIO object's MainContext runs.

Parameters
slotA slot to call when polling channel results in an event that matches condition. The event will be passed as a parameter to slot. If io_handler() returns false the handler is disconnected.
channelThe IOChannel object to watch.
conditionThe conditions to watch for.
priorityThe priority of the new event source.
Returns
A connection handle, which can be used to disconnect the handler.