- PHP Manual
- SyncSharedMemory
- Constructs a new SyncSharedMemory object
SyncSharedMemory::__construct
(PECL sync >= 1.1.0)
SyncSharedMemory::__construct — Constructs a new SyncSharedMemory object
Beschreibung
$name
, int $size
)Constructs a named shared memory object.
Parameter-Liste
-
name
-
The name of the shared memory object.
Hinweis:
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.
-
size
-
The size, in bytes, of shared memory to reserve.
Hinweis:
The amount of memory cannot be resized later. Request sufficient storage up front.
Rückgabewerte
The new SyncSharedMemory object.
Fehler/Exceptions
An exception is thrown if the shared memory object cannot be created or opened.
Beispiele
Beispiel #1 SyncSharedMemory::__construct() example
<?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")));
?>
Siehe auch
- SyncSharedMemory::first() - Check to see if the object is the first instance system-wide of named shared memory
- SyncSharedMemory::size() - Returns the size of the named shared memory
- SyncSharedMemory::write() - Copy data to named shared memory
- SyncSharedMemory::read() - Copy data from named shared memory