glibmm: Glib::SignalIO Class Reference

glibmm 2.66.9

Public Member Functions | List of all members
Glib::SignalIO Class Reference
The Main Event Loop

`#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.
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.

## Member Function Documentation

## ◆ connect() [1/2]

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) { ... }
Glib::signal_io().connect(sigc::ptr_fun(&io_handler), channel, Glib::IO_IN | Glib::IO_HUP);
Glib::SignalIO::connect
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.
Glib::signal_io
SignalIO signal_io()
Convenience I/O signal.
Glib::IOCondition
IOCondition
A bitwise combination representing a condition to watch for on an event source.
Definition iochannel.h:237
sigc::ptr_fun
pointer_functor0< T_return > ptr_fun(T_return(*_A_func)())
Glib::IO_HUP
@ IO_HUP
Hung up (the connection has been broken, usually for pipes and sockets).
Definition iochannel.h:242
Glib::IO_IN
@ IO_IN
A bitwise combination representing an I/O condition to watch for on an event source.
Definition iochannel.h:238

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());
Glib::MainContext::get_default
static Glib::RefPtr< MainContext > get_default()
Returns the global default main context.
Glib::Source::create
static Glib::RefPtr< Source > create()

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

  Slots | A 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.
  channel | The IOChannel object to watch.
  condition | The conditions to watch for.
  priority | The priority of the new event source.

Returns
  A connection handle, which can be used to disconnect the handler.

## ◆ connect() [2/2]

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) { ... }
Glib::signal_io().connect(sigc::ptr_fun(&io_handler), fd, Glib::IO_IN | Glib::IO_HUP);

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

  Slots | A 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.
  fd | The file descriptor (or a `HANDLE` on Win32 systems) to watch.
  condition | The conditions to watch for.
  priority | The priority of the new event source.

Returns
  A connection handle, which can be used to disconnect the handler.