<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Constructs a new SyncEvent object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.syncevent.html">SyncEvent</a></div> <div class="next" style="text-align: right; float: right;"><a href="syncevent.fire.html">SyncEvent::fire</a></div> <div class="up"><a href="class.syncevent.html">SyncEvent</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="syncevent.construct" class="refentry"> <div class="refnamediv"> <h1 class="refname">SyncEvent::__construct</h1> <p class="verinfo">(PECL sync >= 1.0.0)</p><p class="refpurpose"><span class="refname">SyncEvent::__construct</span> — <span class="dc-title">Constructs a new SyncEvent object</span></p> </div> <div class="refsect1 description" id="refsect1-syncevent.construct-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>SyncEvent::__construct</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$manual</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$prefire</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span> ]]] )</div> <p class="para rdfs-comment"> Constructs a named or unnamed event object. </p> </div> <div class="refsect1 parameters" id="refsect1-syncevent.construct-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">name</code></dt> <dd> <p class="para"> The name of the event if this is a named event object. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If the name already exists, it must be able to be opened by the current user that the process is running as or an exception will be thrown with a meaningless error message. </p> </p></blockquote> </dd> <dt> <code class="parameter">manual</code></dt> <dd> <p class="para"> Specifies whether or not the event object must be reset manually. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Manual reset event objects allow all waiting processes through until the object is reset. </p> </p></blockquote> </dd> <dt> <code class="parameter">prefire</code></dt> <dd> <p class="para"> Specifies whether or not to prefire (signal) the event object. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Only has impact if the calling process/thread is the first to create the object. </p> </p></blockquote> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-syncevent.construct-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The new SyncEvent object. An exception is thrown if the event object cannot be created or opened. </p> </div> <div class="refsect1 examples" id="refsect1-syncevent.construct-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-4597"> <p><strong>Example #1 <span class="function"><strong>SyncEvent::__construct()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// In a web application:<br /></span><span style="color: #0000BB">$event </span><span style="color: #007700">= new </span><span style="color: #0000BB">SyncEvent</span><span style="color: #007700">(</span><span style="color: #DD0000">"GetAppReport"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$event</span><span style="color: #007700">-></span><span style="color: #0000BB">fire</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// In a cron job:<br /></span><span style="color: #0000BB">$event </span><span style="color: #007700">= new </span><span style="color: #0000BB">SyncEvent</span><span style="color: #007700">(</span><span style="color: #DD0000">"GetAppReport"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$event</span><span style="color: #007700">-></span><span style="color: #0000BB">wait</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </div> <div class="refsect1 changelog" id="refsect1-syncevent.construct-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>1.1.0</td> <td> <p class="para"> Added <code class="parameter">prefire</code>. </p> </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 seealso" id="refsect1-syncevent.construct-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"><span class="methodname"><a href="syncevent.fire.html" class="methodname" rel="rdfs-seeAlso">SyncEvent::fire()</a> - Fires/sets the event</span></li> <li class="member"><span class="methodname"><a href="syncevent.reset.html" class="methodname" rel="rdfs-seeAlso">SyncEvent::reset()</a> - Resets a manual event</span></li> <li class="member"><span class="methodname"><a href="syncevent.wait.html" class="methodname" rel="rdfs-seeAlso">SyncEvent::wait()</a> - Waits for the event to be fired/set</span></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.syncevent.html">SyncEvent</a></div> <div class="next" style="text-align: right; float: right;"><a href="syncevent.fire.html">SyncEvent::fire</a></div> <div class="up"><a href="class.syncevent.html">SyncEvent</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>