<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.11"/> <title>glibmm: Glib::Dispatcher Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="doxygen-extra.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">glibmm  <span id="projectnumber">2.60.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.11 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceGlib.html">Glib</a></li><li class="navelem"><a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="classGlib_1_1Dispatcher-members.html">List of all members</a> </div> <div class="headertitle"> <div class="title">Glib::Dispatcher Class Reference<div class="ingroups"><a class="el" href="group__Threads.html">Threads</a></div></div> </div> </div><!--header--> <div class="contents"> <p>Signal class for inter-thread communication. <a href="classGlib_1_1Dispatcher.html#details">More...</a></p> <p><code>#include <glibmm/dispatcher.h></code></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:a1883255c63f36e1d218ccf3f1abfa992"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a1883255c63f36e1d218ccf3f1abfa992">Dispatcher</a> ()</td></tr> <tr class="memdesc:a1883255c63f36e1d218ccf3f1abfa992"><td class="mdescLeft"> </td><td class="mdescRight">Create new <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> instance using the default main context. <a href="#a1883255c63f36e1d218ccf3f1abfa992">More...</a><br /></td></tr> <tr class="separator:a1883255c63f36e1d218ccf3f1abfa992"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a3595a55dc1ded7ab29bc12fc43eb9f52"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a3595a55dc1ded7ab29bc12fc43eb9f52">Dispatcher</a> (const <a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>&)=delete</td></tr> <tr class="separator:a3595a55dc1ded7ab29bc12fc43eb9f52"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a3622fc7da1b70860b0cb3ac4abb55070"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a3622fc7da1b70860b0cb3ac4abb55070">operator=</a> (const <a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>&)=delete</td></tr> <tr class="separator:a3622fc7da1b70860b0cb3ac4abb55070"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a14692fe3e39140fc164cbd03149a7ce1"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a14692fe3e39140fc164cbd03149a7ce1">Dispatcher</a> (const <a class="el" href="classGlib_1_1RefPtr.html">Glib::RefPtr</a>< <a class="el" href="classGlib_1_1MainContext.html">MainContext</a> >& context)</td></tr> <tr class="memdesc:a14692fe3e39140fc164cbd03149a7ce1"><td class="mdescLeft"> </td><td class="mdescRight">Create new <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> instance using an arbitrary main context. <a href="#a14692fe3e39140fc164cbd03149a7ce1">More...</a><br /></td></tr> <tr class="separator:a14692fe3e39140fc164cbd03149a7ce1"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:af9484ae270bc15667fff210165d5f1bd"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#af9484ae270bc15667fff210165d5f1bd">~Dispatcher</a> () noexcept</td></tr> <tr class="separator:af9484ae270bc15667fff210165d5f1bd"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a07b89c90f931db118c8c184d0615ce92"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a07b89c90f931db118c8c184d0615ce92">emit</a> ()</td></tr> <tr class="separator:a07b89c90f931db118c8c184d0615ce92"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a4610275deedf1324bf71afde1c8c71ea"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a4610275deedf1324bf71afde1c8c71ea">operator()</a> ()</td></tr> <tr class="separator:a4610275deedf1324bf71afde1c8c71ea"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a63645395ac79c03b5ec9e81d8099dea7"><td class="memItemLeft" align="right" valign="top"><a class="elRef" href="../../../libsigc++-2.0/reference/html/structsigc_1_1connection.html">sigc::connection</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a63645395ac79c03b5ec9e81d8099dea7">connect</a> (const <a class="elRef" href="../../../libsigc++-2.0/reference/html/classsigc_1_1slot.html">sigc::slot</a>< void >& slot)</td></tr> <tr class="separator:a63645395ac79c03b5ec9e81d8099dea7"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a2e486005033e1928bb1afc63fa2ec053"><td class="memItemLeft" align="right" valign="top"><a class="elRef" href="../../../libsigc++-2.0/reference/html/structsigc_1_1connection.html">sigc::connection</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a2e486005033e1928bb1afc63fa2ec053">connect</a> (<a class="elRef" href="../../../libsigc++-2.0/reference/html/classsigc_1_1slot.html">sigc::slot</a>< void >&& slot)</td></tr> <tr class="separator:a2e486005033e1928bb1afc63fa2ec053"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Signal class for inter-thread communication. </p> <p><a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Glib::Dispatcher</a> works similar to sigc::signal<void>. But unlike normal signals, the notification happens asynchronously through a pipe. This is a simple and efficient way of communicating between threads, and especially useful in a thread model with a single GUI thread.</p> <p>No mutex locking is involved, apart from the operating system's internal I/O locking. That implies some usage rules:</p> <ul> <li>Only one thread may connect to the signal and receive notification, but multiple senders are allowed even without locking. </li> <li>The GLib main loop must run in the receiving thread (this will be the GUI thread usually). </li> <li>The <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> object must be instantiated by the receiver thread. </li> <li>The <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> object should be instantiated before creating any of the sender threads, if you want to avoid extra locking. </li> <li>The <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> object must be deleted by the receiver thread. </li> <li>All <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> objects instantiated by the same receiver thread must use the same main context.</li> </ul> <p>Notes about performance:</p> <ul> <li>After instantiation, <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Glib::Dispatcher</a> will never lock any mutexes on its own. The interaction with the GLib main loop might involve locking on the <em>receiver</em> side. The <em>sender</em> side, however, is guaranteed not to lock, except for internal locking in the <code>write()</code> system call. </li> <li>All <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> instances of a receiver thread share the same pipe. That is, if you use <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Glib::Dispatcher</a> only to notify the GUI thread, only one pipe is created no matter how many <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> objects you have.</li> </ul> <p>Using <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Glib::Dispatcher</a> on Windows:</p> <p><a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Glib::Dispatcher</a> also works on win32-based systems. Unfortunately though, the implementation cannot use a pipe on win32 and therefore does have to lock a mutex on emission, too. However, the impact on performance is likely minor and the notification still happens asynchronously. Apart from the additional lock the behavior matches the Unix implementation. </p> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="thread_2dispatcher_8cc-example.html#_a3">thread/dispatcher.cc</a>.</dd> </dl></div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a class="anchor" id="a1883255c63f36e1d218ccf3f1abfa992"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Glib::Dispatcher::Dispatcher </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Create new <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> instance using the default main context. </p> <dl class="exception"><dt>Exceptions</dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors. ">Glib::FileError</a></td><td></td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a3595a55dc1ded7ab29bc12fc43eb9f52"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">Glib::Dispatcher::Dispatcher </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>& </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">delete</span></span> </td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a14692fe3e39140fc164cbd03149a7ce1"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">Glib::Dispatcher::Dispatcher </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGlib_1_1RefPtr.html">Glib::RefPtr</a>< <a class="el" href="classGlib_1_1MainContext.html">MainContext</a> >& </td> <td class="paramname"><em>context</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">explicit</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Create new <a class="el" href="classGlib_1_1Dispatcher.html" title="Signal class for inter-thread communication. ">Dispatcher</a> instance using an arbitrary main context. </p> <dl class="exception"><dt>Exceptions</dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors. ">Glib::FileError</a></td><td></td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="af9484ae270bc15667fff210165d5f1bd"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">Glib::Dispatcher::~Dispatcher </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">noexcept</span></span> </td> </tr> </table> </div><div class="memdoc"> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a class="anchor" id="a63645395ac79c03b5ec9e81d8099dea7"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="elRef" href="../../../libsigc++-2.0/reference/html/structsigc_1_1connection.html">sigc::connection</a> Glib::Dispatcher::connect </td> <td>(</td> <td class="paramtype">const <a class="elRef" href="../../../libsigc++-2.0/reference/html/classsigc_1_1slot.html">sigc::slot</a>< void > & </td> <td class="paramname"><em>slot</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a2e486005033e1928bb1afc63fa2ec053"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="elRef" href="../../../libsigc++-2.0/reference/html/structsigc_1_1connection.html">sigc::connection</a> Glib::Dispatcher::connect </td> <td>(</td> <td class="paramtype"><a class="elRef" href="../../../libsigc++-2.0/reference/html/classsigc_1_1slot.html">sigc::slot</a>< void > && </td> <td class="paramname"><em>slot</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <dl class="since_2_48"><dt><b><a class="el" href="since_2_48.html#_since_2_48000001">Since glibmm 2.48:</a></b></dt><dd></dd></dl> </div> </div> <a class="anchor" id="a07b89c90f931db118c8c184d0615ce92"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Glib::Dispatcher::emit </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a4610275deedf1324bf71afde1c8c71ea"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Glib::Dispatcher::operator() </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a3622fc7da1b70860b0cb3ac4abb55070"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>& Glib::Dispatcher::operator= </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>& </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">delete</span></span> </td> </tr> </table> </div><div class="memdoc"> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Tue Mar 19 2019 09:56:45 for glibmm by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.11 </small></address> </body> </html>