Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 6605

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsystemsemaphore.cpp -->
  <title>Qt 4.8: QSystemSemaphore Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtcore.html">QtCore</a></li>
<li>QSystemSemaphore</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#platform-specific-behavior">Platform-Specific Behavior</a></li>
</ul>
</div>
<h1 class="title">QSystemSemaphore Class Reference</h1>
<!-- $$$QSystemSemaphore-brief -->
<p>The QSystemSemaphore class provides a general counting system semaphore. <a href="#details">More...</a></p>
<!-- @@@QSystemSemaphore -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QSystemSemaphore&gt;</span></pre><p>This class was introduced in Qt 4.4.</p>
<ul>
<li><a href="qsystemsemaphore-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#AccessMode-enum">AccessMode</a></b> { Open, Create }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#SystemSemaphoreError-enum">SystemSemaphoreError</a></b> { NoError, PermissionDenied, KeyError, AlreadyExists, ..., UnknownError }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#QSystemSemaphore">QSystemSemaphore</a></b> ( const QString &amp; <i>key</i>, int <i>initialValue</i> = 0, AccessMode <i>mode</i> = Open )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#dtor.QSystemSemaphore">~QSystemSemaphore</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#acquire">acquire</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> SystemSemaphoreError </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#error">error</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#errorString">errorString</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#key">key</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#release">release</a></b> ( int <i>n</i> = 1 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsystemsemaphore.html#setKey">setKey</a></b> ( const QString &amp; <i>key</i>, int <i>initialValue</i> = 0, AccessMode <i>mode</i> = Open )</td></tr>
</table>
<a name="details"></a>
<!-- $$$QSystemSemaphore-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QSystemSemaphore class provides a general counting system semaphore.</p>
<p>A semaphore is a generalization of a mutex. While a mutex can be locked only once, a semaphore can be acquired multiple times. Typically, a semaphore is used to protect a certain number of identical resources.</p>
<p>Like its lighter counterpart <a href="qsemaphore.html">QSemaphore</a>, a QSystemSemaphore can be accessed from multiple <a href="qthread.html">threads</a>. Unlike <a href="qsemaphore.html">QSemaphore</a>, a QSystemSemaphore can also be accessed from multiple <a href="qprocess.html">processes</a>. This means QSystemSemaphore is a much heavier class, so if your application doesn't need to access your semaphores across multiple processes, you will probably want to use <a href="qsemaphore.html">QSemaphore</a>.</p>
<p>Semaphores support two fundamental operations, <a href="qsystemsemaphore.html#acquire">acquire</a>() and <a href="qsystemsemaphore.html#release">release</a>():</p>
<p><a href="qsystemsemaphore.html#acquire">acquire</a>() tries to acquire one resource. If there isn't a resource available, the call blocks until a resource becomes available. Then the resource is acquired and the call returns.</p>
<p><a href="qsystemsemaphore.html#release">release</a>() releases one resource so it can be acquired by another process. The function can also be called with a parameter n &gt; 1, which releases n resources.</p>
<p>A system semaphore is created with a string key that other processes can use to use the same semaphore.</p>
<p>Example: Create a system semaphore</p>
<pre class="cpp"> <span class="type">QSystemSemaphore</span> sem(<span class="string">&quot;market&quot;</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="type">QSystemSemaphore</span><span class="operator">::</span>Create);
                              <span class="comment">// resources available == 3</span>
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#acquire">acquire</a>();               <span class="comment">// resources available == 2</span>
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#acquire">acquire</a>();               <span class="comment">// resources available == 1</span>
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#acquire">acquire</a>();               <span class="comment">// resources available == 0</span>
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#release">release</a>();               <span class="comment">// resources available == 1</span>
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#release">release</a>(<span class="number">2</span>);              <span class="comment">// resources available == 3</span></pre>
<p>A typical application of system semaphores is for controlling access to a circular buffer shared by a producer process and a consumer processes.</p>
<a name="platform-specific-behavior"></a>
<h3>Platform-Specific Behavior</h3>
<p>When using this class, be aware of the following platform differences:</p>
<p><b>Windows:</b> QSystemSemaphore does not own its underlying system semaphore. Windows owns it. This means that when all instances of QSystemSemaphore for a particular key have been destroyed, either by having their destructors called, or because one or more processes crash, Windows removes the underlying system semaphore.</p>
<p><b>Unix:</b></p>
<ul>
<li>QSystemSemaphore owns the underlying system semaphore in Unix systems. This means that the last process having an instance of QSystemSemaphore for a particular key must remove the underlying system semaphore in its destructor. If the last process crashes without running the QSystemSemaphore destructor, Unix does not automatically remove the underlying system semaphore, and the semaphore survives the crash. A subsequent process that constructs a QSystemSemaphore with the same key will then be given the existing system semaphore. In that case, if the QSystemSemaphore constructor has specified its <a href="qsystemsemaphore.html#AccessMode-enum">access mode</a> as <a href="qsystemsemaphore.html#AccessMode-enum">Open</a>, its initial resource count will not be reset to the one provided but remain set to the value it received in the crashed process. To protect against this, the first process to create a semaphore for a particular key (usually a server), must pass its <a href="qsystemsemaphore.html#AccessMode-enum">access mode</a> as <a href="qsystemsemaphore.html#AccessMode-enum">Create</a>, which will force Unix to reset the resource count in the underlying system semaphore.</li>
<li>When a process using QSystemSemaphore terminates for any reason, Unix automatically reverses the effect of all acquire operations that were not released. Thus if the process acquires a resource and then exits without releasing it, Unix will release that resource.</li>
<li>Symbian: QSystemSemaphore behaves the same as Windows semaphores. In other words, the operating system owns the semaphore and ignores <a href="qsystemsemaphore.html#AccessMode-enum">QSystemSemaphore::AccessMode</a>.</li>
</ul>
</div>
<p><b>See also </b><a href="qsharedmemory.html">QSharedMemory</a> and <a href="qsemaphore.html">QSemaphore</a>.</p>
<!-- @@@QSystemSemaphore -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$AccessMode$$$Open$$$Create -->
<h3 class="fn"><a name="AccessMode-enum"></a>enum QSystemSemaphore::<span class="name">AccessMode</span></h3>
<p>This enum is used by the constructor and <a href="qsystemsemaphore.html#setKey">setKey</a>(). Its purpose is to enable handling the problem in Unix implementations of semaphores that survive a crash. In Unix, when a semaphore survives a crash, we need a way to force it to reset its resource count, when the system reuses the semaphore. In Windows and in Symbian, where semaphores can't survive a crash, this enum has no effect.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::Open</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">If the semaphore already exists, its initial resource count is not reset. If the semaphore does not already exist, it is created and its initial resource count set.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::Create</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign"><a href="qsystemsemaphore.html">QSystemSemaphore</a> takes ownership of the semaphore and sets its resource count to the requested value, regardless of whether the semaphore already exists by having survived a crash. This value should be passed to the constructor, when the first semaphore for a particular key is constructed and you know that if the semaphore already exists it could only be because of a crash. In Windows and in Symbian, where a semaphore can't survive a crash, Create and Open have the same behavior.</td></tr>
</table>
<!-- @@@AccessMode -->
<!-- $$$SystemSemaphoreError$$$NoError$$$PermissionDenied$$$KeyError$$$AlreadyExists$$$NotFound$$$OutOfResources$$$UnknownError -->
<h3 class="fn"><a name="SystemSemaphoreError-enum"></a>enum QSystemSemaphore::<span class="name">SystemSemaphoreError</span></h3>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::NoError</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">No error occurred.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::PermissionDenied</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The operation failed because the caller didn't have the required permissions.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::KeyError</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The operation failed because of an invalid key.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::AlreadyExists</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">The operation failed because a system semaphore with the specified key already existed.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::NotFound</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">The operation failed because a system semaphore with the specified key could not be found.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::OutOfResources</tt></td><td class="topAlign"><tt>5</tt></td><td class="topAlign">The operation failed because there was not enough memory available to fill the request.</td></tr>
<tr><td class="topAlign"><tt>QSystemSemaphore::UnknownError</tt></td><td class="topAlign"><tt>6</tt></td><td class="topAlign">Something else happened and it was bad.</td></tr>
</table>
<!-- @@@SystemSemaphoreError -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QSystemSemaphore[overload1]$$$QSystemSemaphoreconstQString&intAccessMode -->
<h3 class="fn"><a name="QSystemSemaphore"></a>QSystemSemaphore::<span class="name">QSystemSemaphore</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>key</i>, <span class="type">int</span> <i>initialValue</i> = 0, <span class="type"><a href="qsystemsemaphore.html#AccessMode-enum">AccessMode</a></span> <i>mode</i> = Open )</h3>
<p>Requests a system semaphore for the specified <i>key</i>. The parameters <i>initialValue</i> and <i>mode</i> are used according to the following rules, which are system dependent.</p>
<p>In Unix, if the <i>mode</i> is <a href="qsystemsemaphore.html#AccessMode-enum">Open</a> and the system already has a semaphore identified by <i>key</i>, that semaphore is used, and the semaphore's resource count is not changed, i.e&#x2e;, <i>initialValue</i> is ignored. But if the system does not already have a semaphore identified by <i>key</i>, it creates a new semaphore for that key and sets its resource count to <i>initialValue</i>.</p>
<p>In Unix, if the <i>mode</i> is <a href="qsystemsemaphore.html#AccessMode-enum">Create</a> and the system already has a semaphore identified by <i>key</i>, that semaphore is used, and its resource count is set to <i>initialValue</i>. If the system does not already have a semaphore identified by <i>key</i>, it creates a new semaphore for that key and sets its resource count to <i>initialValue</i>.</p>
<p>In QNX, if the <i>mode</i> is <a href="qsystemsemaphore.html#AccessMode-enum">Create</a> and the system already has a semaphore identified by <i>key</i>, that semaphore will be deleted and the new one will be created for that key with a resource count set to <i>initialValue</i>.</p>
<p>In Windows and in Symbian, <i>mode</i> is ignored, and the system always tries to create a semaphore for the specified <i>key</i>. If the system does not already have a semaphore identified as <i>key</i>, it creates the semaphore and sets its resource count to <i>initialValue</i>. But if the system already has a semaphore identified as <i>key</i> it uses that semaphore and ignores <i>initialValue</i>.</p>
<p>The <a href="qsystemsemaphore.html#AccessMode-enum">mode</a> parameter is only used in Unix systems to handle the case where a semaphore survives a process crash. In that case, the next process to allocate a semaphore with the same <i>key</i> will get the semaphore that survived the crash, and unless <i>mode</i> is <a href="qsystemsemaphore.html#AccessMode-enum">Create</a>, the resource count will not be reset to <i>initialValue</i> but will retain the initial value it had been given by the crashed process.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#acquire">acquire</a>() and <a href="qsystemsemaphore.html#key">key</a>().</p>
<!-- @@@QSystemSemaphore -->
<!-- $$$~QSystemSemaphore[overload1]$$$~QSystemSemaphore -->
<h3 class="fn"><a name="dtor.QSystemSemaphore"></a>QSystemSemaphore::<span class="name">~QSystemSemaphore</span> ()</h3>
<p>The destructor destroys the <a href="qsystemsemaphore.html">QSystemSemaphore</a> object, but the underlying system semaphore is not removed from the system unless this instance of <a href="qsystemsemaphore.html">QSystemSemaphore</a> is the last one existing for that system semaphore.</p>
<p>Two important side effects of the destructor depend on the system. In Windows, if <a href="qsystemsemaphore.html#acquire">acquire</a>() has been called for this semaphore but not <a href="qsystemsemaphore.html#release">release</a>(), <a href="qsystemsemaphore.html#release">release</a>() will not be called by the destructor, nor will the resource be released when the process exits normally. This would be a program bug which could be the cause of a deadlock in another process trying to acquire the same resource. In Unix, acquired resources that are not released before the destructor is called are automatically released when the process exits.</p>
<!-- @@@~QSystemSemaphore -->
<!-- $$$acquire[overload1]$$$acquire -->
<h3 class="fn"><a name="acquire"></a><span class="type">bool</span> QSystemSemaphore::<span class="name">acquire</span> ()</h3>
<p>Acquires one of the resources guarded by this semaphore, if there is one available, and returns true. If all the resources guarded by this semaphore have already been acquired, the call blocks until one of them is released by another process or thread having a semaphore with the same key.</p>
<p>If false is returned, a system error has occurred. Call <a href="qsystemsemaphore.html#error">error</a>() to get a value of <a href="qsystemsemaphore.html#SystemSemaphoreError-enum">QSystemSemaphore::SystemSemaphoreError</a> that indicates which error occurred.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#release">release</a>().</p>
<!-- @@@acquire -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn"><a name="error"></a><span class="type"><a href="qsystemsemaphore.html#SystemSemaphoreError-enum">SystemSemaphoreError</a></span> QSystemSemaphore::<span class="name">error</span> () const</h3>
<p>Returns a value indicating whether an error occurred, and, if so, which error it was.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#errorString">errorString</a>().</p>
<!-- @@@error -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QSystemSemaphore::<span class="name">errorString</span> () const</h3>
<p>Returns a text description of the last error that occurred. If <a href="qsystemsemaphore.html#error">error</a>() returns an <a href="qsystemsemaphore.html#SystemSemaphoreError-enum">error value</a>, call this function to get a text string that describes the error.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#error">error</a>().</p>
<!-- @@@errorString -->
<!-- $$$key[overload1]$$$key -->
<h3 class="fn"><a name="key"></a><span class="type"><a href="qstring.html">QString</a></span> QSystemSemaphore::<span class="name">key</span> () const</h3>
<p>Returns the key assigned to this system semaphore. The key is the name by which the semaphore can be accessed from other processes.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#setKey">setKey</a>().</p>
<!-- @@@key -->
<!-- $$$release[overload1]$$$releaseint -->
<h3 class="fn"><a name="release"></a><span class="type">bool</span> QSystemSemaphore::<span class="name">release</span> ( <span class="type">int</span> <i>n</i> = 1 )</h3>
<p>Releases <i>n</i> resources guarded by the semaphore. Returns true unless there is a system error.</p>
<p>Example: Create a system semaphore having five resources; acquire them all and then release them all.</p>
<pre class="cpp"> <span class="type"><a href="qsystemsemaphore.html">QSystemSemaphore</a></span> sem(<span class="string">&quot;market&quot;</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="type"><a href="qsystemsemaphore.html">QSystemSemaphore</a></span><span class="operator">::</span>Create);
 sem<span class="operator">.</span><a href="qsystemsemaphore.html#acquire">acquire</a>(<span class="number">5</span>);           <span class="comment">// acquire all 5 resources</span>
 sem<span class="operator">.</span>release(<span class="number">5</span>);           <span class="comment">// release the 5 resources</span></pre>
<p>This function can also &quot;create&quot; resources. For example, immediately following the sequence of statements above, suppose we add the statement:</p>
<pre class="cpp"> sem<span class="operator">.</span>release(<span class="number">10</span>);          <span class="comment">// &quot;create&quot; 10 new resources</span></pre>
<p>Ten new resources are now guarded by the semaphore, in addition to the five that already existed. You would not normally use this function to create more resources.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#acquire">acquire</a>().</p>
<!-- @@@release -->
<!-- $$$setKey[overload1]$$$setKeyconstQString&intAccessMode -->
<h3 class="fn"><a name="setKey"></a><span class="type">void</span> QSystemSemaphore::<span class="name">setKey</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>key</i>, <span class="type">int</span> <i>initialValue</i> = 0, <span class="type"><a href="qsystemsemaphore.html#AccessMode-enum">AccessMode</a></span> <i>mode</i> = Open )</h3>
<p>This function works the same as the constructor. It reconstructs this <a href="qsystemsemaphore.html">QSystemSemaphore</a> object. If the new <i>key</i> is different from the old key, calling this function is like calling the destructor of the semaphore with the old key, then calling the constructor to create a new semaphore with the new <i>key</i>. The <i>initialValue</i> and <i>mode</i> parameters are as defined for the constructor.</p>
<p><b>See also </b><a href="qsystemsemaphore.html#QSystemSemaphore">QSystemSemaphore</a>() and <a href="qsystemsemaphore.html#key">key</a>().</p>
<!-- @@@setKey -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Qt and respective logos are trademarks of The Qt Company Ltd 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>