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
파일 보기 프로젝트 열기: icicleio/concurrent

공개 메소드들

메소드 설명
__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 )