PHP Класс Icicle\Concurrent\Sync\SharedMemoryParcel

A shared object is a container that stores an object inside shared memory. The object can be accessed and mutated by any thread or process. The shared object handle itself is serializable and can be sent to any thread or process to give access to the value that is shared in the container. Because each shared object uses its own shared memory segment, it is much more efficient to store a larger object containing many values inside a single shared container than to use many small shared containers. Note that accessing a shared object is not atomic. Access to a shared object should be protected with a mutex to preserve data integrity. When used with forking, the object must be created prior to forking for both processes to access the synchronized object.
См. также: http://php.net/manual/en/book.shmop.php The shared memory extension.
См. также: http://man7.org/linux/man-pages/man2/shmctl.2.html How shared memory works on Linux.
См. также: https://msdn.microsoft.com/en-us/library/ms810613.aspx How shared memory works on Windows.
Наследование: implements Icicle\Concurrent\Sync\Parcel, implements Serializable
Показать файл Открыть проект

Открытые методы

Метод Описание
__clone ( )
__construct ( mixed $value, integer $size = 16384, integer $permissions = 384 ) Creates a new local object container.
__debugInfo ( ) : array Gets information about the object for debugging purposes.
free ( ) Frees the shared object from memory.
isFreed ( ) : boolean Checks if the object has been freed.
serialize ( ) : string Serializes the local object handle.
synchronized ( callable $callback ) : Generator
unserialize ( string $serialized ) Unserializes the local object handle.
unwrap ( )

Защищенные методы

Метод Описание
wrap ( $value ) If the value requires more memory to store than currently allocated, a new shared memory segment will be allocated with a larger size to store the value in. The previous memory segment will be cleaned up and marked for deletion. Other processes and threads will be notified of the new memory segment on the next read attempt. Once all running processes and threads disconnect from the old segment, it will be freed by the OS.

Приватные методы

Метод Описание
getHeader ( ) : array Reads and returns the data header at the current memory segment.
handleMovedMemory ( ) Updates the current memory segment handle, handling any moves made on the data.
init ( mixed $value, integer $size = 16384, integer $permissions = 384 )
memDelete ( ) Requests the shared memory segment to be deleted.
memGet ( integer $offset, integer $size ) : string Reads binary data from shared memory.
memOpen ( integer $key, string $mode, integer $permissions, integer $size ) Opens a shared memory handle.
memSet ( integer $offset, string $data ) Writes binary data to shared memory.
setHeader ( integer $state, integer $size, integer $permissions ) Sets the header data for the current memory segment.

Описание методов

__clone() публичный Метод

public __clone ( )

__construct() публичный Метод

The object given will be assigned a new object ID and will have a reference to it stored in memory local to the thread.
public __construct ( mixed $value, integer $size = 16384, integer $permissions = 384 )
$value mixed The value to store in the container.
$size integer The number of bytes to allocate for the object. If not specified defaults to 16384 bytes.
$permissions integer The access permissions to set for the object. If not specified defaults to 0600.

__debugInfo() публичный Метод

Gets information about the object for debugging purposes.
public __debugInfo ( ) : array
Результат array An array of debugging information.

free() публичный Метод

The memory containing the shared value will be invalidated. When all process disconnect from the object, the shared memory block will be destroyed by the OS. Calling free() on an object already freed will have no effect.
public free ( )

isFreed() публичный Метод

Note that this does not check if the object has been destroyed; it only checks if this handle has freed its reference to the object.
public isFreed ( ) : boolean
Результат boolean True if the object is freed, otherwise false.

serialize() публичный Метод

Note that this does not serialize the object that is referenced, just the object handle.
public serialize ( ) : string
Результат string The serialized object handle.

synchronized() публичный Метод

public synchronized ( callable $callback ) : Generator
$callback callable
Результат Generator

unserialize() публичный Метод

Unserializes the local object handle.
public unserialize ( string $serialized )
$serialized string The serialized object handle.

unwrap() публичный Метод

public unwrap ( )

wrap() защищенный Метод

If the value requires more memory to store than currently allocated, a new shared memory segment will be allocated with a larger size to store the value in. The previous memory segment will be cleaned up and marked for deletion. Other processes and threads will be notified of the new memory segment on the next read attempt. Once all running processes and threads disconnect from the old segment, it will be freed by the OS.
protected wrap ( $value )