php-doc-en/reference/sync/syncsharedmemory/construct.xml
2018-01-25 15:56:34 +00:00

117 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="syncsharedmemory.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SyncSharedMemory::__construct</refname>
<refpurpose>Constructs a new SyncSharedMemory object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <methodname>SyncSharedMemory::__construct</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
</methodsynopsis>
<para>
Constructs a named shared memory object.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The name of the shared memory object.
</para>
<note>
<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.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
The size, in bytes, of shared memory to reserve.
</para>
<note>
<para>
The amount of memory cannot be resized later. Request sufficient storage up front.
</para>
</note>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The new SyncSharedMemory object. An exception is thrown if the shared memory
object cannot be created or opened.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>SyncSharedMemory::__construct</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// You will probably need to protect shared memory with other synchronization objects.
// Shared memory goes away when the last reference to it disappears.
$mem = new SyncSharedMemory("AppReportName", 1024);
if ($mem->first())
{
// Do first time initialization work here.
}
$result = $mem->write(json_encode(array("name" => "my_report.txt")));
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><methodname>SyncSharedMemory::first</methodname></member>
<member><methodname>SyncSharedMemory::size</methodname></member>
<member><methodname>SyncSharedMemory::write</methodname></member>
<member><methodname>SyncSharedMemory::read</methodname></member>
</simplelist>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->