Amp\Parallel\Sync\SharedMemoryParcel class SharedMemoryParcel implements Amp\Parallel\Sync\Parcel

Summary

Properties

Methods

Properties

Methods

create — public function create(string $id, mixed $value, int $size = 8192, int $permissions = 0600): Amp\Parallel\Sync\SharedMemoryParcel
No documentation.
Type Parameter Description Default Value
string $id No documentation. none
mixed $value No documentation. none
int $size The initial size in bytes of the shared memory segment. It will automatically be expanded as necessary. 8192
int $permissions Permissions to access the semaphore. Use file permission format specified as 0xxx. 0600
use — public function use(string $id): Amp\Parallel\Sync\SharedMemoryParcel
No documentation.
Type Parameter Description Default Value
string $id No documentation. none
unwrap — public function unwrap(): Amp\Promise
No documentation.
wrap — protected function 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.

Type Parameter Description Default Value
mixed $value No documentation. none
synchronized — public function synchronized(callable $callback): Amp\Promise
No documentation.
Type Parameter Description Default Value
callable $callback No documentation. none
__destruct — public function __destruct()

Frees the shared object from memory.

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.