Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > 7f3e5f74d754b480ec33648905c4afae > files > 157

glibmm2.4-doc-2.22.1-1mdv2010.0.x86_64.rpm

<!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"/>
<title>glibmm: Glib::Dispatcher Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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 class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="namespaceGlib.html">Glib</a>::<a class="el" href="classGlib_1_1Dispatcher.html">Dispatcher</a>
  </div>
</div>
<div class="contents">
<h1>Glib::Dispatcher Class Reference<br/>
<small>
[<a class="el" href="group__Threads.html">Threads</a>]</small>
</h1><!-- doxytag: class="Glib::Dispatcher" -->
<p>Signal class for inter-thread communication. <a href="#_details">More...</a></p>
<div class="dynheader">
Collaboration diagram for Glib::Dispatcher:</div>
<div class="dynsection">
<div class="center"><img src="classGlib_1_1Dispatcher__coll__graph.png" border="0" usemap="#Glib_1_1Dispatcher_coll__map" alt="Collaboration graph"/></div>
<map name="Glib_1_1Dispatcher_coll__map" id="Glib_1_1Dispatcher_coll__map">
<area shape="rect" href="../../../libsigc++-2.0/reference/html/classsigc_1_1signal.html" title="sigc::signal\&lt; void \&gt;" alt="" coords="2515,56,2651,85"/><area shape="rect" href="../../../libsigc++-2.0/reference/html/structsigc_1_1signal__base.html" title="sigc::signal_base" alt="" coords="163,61,285,91"/><area shape="rect" href="../../../libsigc++-2.0/reference/html/classsigc_1_1signal7.html" title="signal7\&lt; T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7, T_accumulator \&gt;" alt="" coords="337,61,900,91"/><area shape="rect" href="../../../libsigc++-2.0/reference/html/structsigc_1_1trackable.html" title="sigc::trackable" alt="" coords="5,61,112,91"/><area shape="rect" href="../../../libsigc++-2.0/reference/html/classsigc_1_1signal.html" title="sigc::signal\&lt; T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 \&gt;" alt="" coords="1923,85,2419,115"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="classGlib_1_1Dispatcher-members.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a1883255c63f36e1d218ccf3f1abfa992">Dispatcher</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</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"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</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>&lt; <a class="el" href="classGlib_1_1MainContext.html">MainContext</a> &gt;&amp; context)</td></tr>
<tr><td class="mdescLeft">&#160;</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"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a6d220afa9063f8cf1364d5a1c73eb010">~Dispatcher</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a07b89c90f931db118c8c184d0615ce92">emit</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a4610275deedf1324bf71afde1c8c71ea">operator()</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">sigc::connection&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dispatcher.html#a63645395ac79c03b5ec9e81d8099dea7">connect</a> (const sigc::slot&lt; void &gt;&amp;<a class="elRef" href="../../../libsigc++-2.0/reference/html/classsigc_1_1slot.html">slot</a>)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<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&lt;void&gt;. 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>
</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>
<p><a class="el" href="thread_2dispatcher_8cc-example.html#_a2">thread/dispatcher.cc</a>.</p>
</dd>
</dl><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a1883255c63f36e1d218ccf3f1abfa992"></a><!-- doxytag: member="Glib::Dispatcher::Dispatcher" ref="a1883255c63f36e1d218ccf3f1abfa992" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Glib::Dispatcher::Dispatcher </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&#160;)&#160;</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><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors.">Glib::FileError</a></em>&#160;</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a14692fe3e39140fc164cbd03149a7ce1"></a><!-- doxytag: member="Glib::Dispatcher::Dispatcher" ref="a14692fe3e39140fc164cbd03149a7ce1" args="(const Glib::RefPtr&lt; MainContext &gt; &amp;context)" -->
<div class="memitem">
<div class="memproto">
      <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>&lt; <a class="el" href="classGlib_1_1MainContext.html">MainContext</a> &gt;&amp;&#160;</td>
          <td class="paramname"> <em>context</em></td>
          <td>&#160;)&#160;</td>
          <td><code> [explicit]</code></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><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors.">Glib::FileError</a></em>&#160;</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a6d220afa9063f8cf1364d5a1c73eb010"></a><!-- doxytag: member="Glib::Dispatcher::~Dispatcher" ref="a6d220afa9063f8cf1364d5a1c73eb010" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Glib::Dispatcher::~Dispatcher </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a63645395ac79c03b5ec9e81d8099dea7"></a><!-- doxytag: member="Glib::Dispatcher::connect" ref="a63645395ac79c03b5ec9e81d8099dea7" args="(const sigc::slot&lt; void &gt; &amp;slot)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sigc::connection Glib::Dispatcher::connect </td>
          <td>(</td>
          <td class="paramtype">const sigc::slot&lt; void &gt; &amp;&#160;</td>
          <td class="paramname"> <em>slot</em></td>
          <td>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a07b89c90f931db118c8c184d0615ce92"></a><!-- doxytag: member="Glib::Dispatcher::emit" ref="a07b89c90f931db118c8c184d0615ce92" args="()" -->
<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>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a4610275deedf1324bf71afde1c8c71ea"></a><!-- doxytag: member="Glib::Dispatcher::operator()" ref="a4610275deedf1324bf71afde1c8c71ea" args="()" -->
<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>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>glibmm/dispatcher.h</li>
</ul>
</div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Mon Sep 21 11:07:26 2009 for glibmm by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>