Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 259

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Semaphores</title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Semaphores</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#OO Languages Semaphores&nbsp;">OO Languages Semaphores&nbsp;</a></li><li><a href ="#db4o Semaphore">db4o Semaphore</a></li></ul></li></ul></div></div></div>


<p>db4o Semaphores are named flags that can only be owned by one client/transaction at one time. They are supplied to be used as locks for exclusive access to code blocks in applications and to signal states from one client to the server and to all other clients.</p>

<p>The naming of semaphores is up to the application. Any string can be used.</p>

<p>Semaphores are freed automatically when a client disconnects correctly or when a clients presence is no longer detected by the server, that constantly monitors all client connections.</p>

<p>Semaphores can be set and released with the following two methods:</p>



<span name="cs_wiki_filter" csw_filters="net">

<p>.NET: </p>
<p><code>IExtObjectContainer#SetSemaphore(string name, int waitMilliSeconds);<br>IExtObjectContainer#ReleaseSemaphore(string name); </code></p>

</span>
<a name="OO Languages Semaphores&nbsp;"></a><h2>OO Languages Semaphores&nbsp;</h2>
The concept of db4o semaphores is very similar to the concept of synchronization in OO programming languages: 


<span name="cs_wiki_filter" csw_filters="net">

<p>.NET: </p>
<p><code>lock(monitorObject){ <br><br>// exclusive code block here<br>
<br>}</code></p>

</span>

<a name="db4o Semaphore"></a><h2>db4o Semaphore</h2>


<span name="cs_wiki_filter" csw_filters="net">

<p>.NET: </p>
<p><code>if(objectContainer.Ext().SetSemaphore(semaphoreName, 1000){<br><br>// exclusive code block here<br>objectContainer.Ext().ReleaseSemaphore(semaphoreName);<br>} </code></p>

</span>

<p>Although the principle of semaphores is very simple they are powerful enough for a wide range of usecases.</p>
<p><div class="childTopicList">More Reading:<ul>
<li><p><a href="semaphores/locking_objects.html" class="wikiLink">Locking Objects</a></p></li>
<li><p><a href="semaphores/ensuring_singletons.html" class="wikiLink">Ensuring Singletons</a></p></li>
<li><p><a href="semaphores/limiting_the_number_of_users.html" class="wikiLink">Limiting the Number of Users</a></p></li>
<li><p><a href="semaphores/controlling_login_information.html" class="wikiLink">Controlling Login Information</a></p></li>
</ul></div>
&nbsp;</p></div>
    </div>
    <div id="footer">
					This revision (10) was last Modified 2006-12-14T19:01:06 by Tetyana.
				</div>
  </body>
</html>