This is automatic generated document for things in Swow\SharedBuffer class
Class SharedBuffer
A shared memory byte buffer with named and anonymous mappings.
An anonymous buffer is visible to threads of this process and to a forked child. A named buffer is visible to another process that attaches the same name. The buffer does not lock. The caller coordinates access. The typed methods use offsetBytes as a byte offset and count as an element count. The endian argument selects the byte order.
Constants
Store and load typed values in big-endian order.
Store and load typed values in little-endian order.
Use the byte order of this machine.
Methods
Static method attachNamed
Attach a named buffer.
Static method createNamed
Create a named buffer.
Param string $name mapping name Param int $size size in bytes Param int $alignment alignment in bytes, a power of two from 8 to 4096 Param int $flags bit 0 removes the name when the last handle releases the buffer
Throws \ValueError when the alignment is not valid Throws \Swow\SyncException when the name exists or the buffer cannot be created
Static method unlink
Remove a name. An existing mapping stays valid.
Method __construct
Create an anonymous buffer.
Param int $size size in bytes Param int $alignment alignment in bytes, a power of two from 8 to 4096
Throws \ValueError when the size is not positive or the alignment is not valid Throws \Swow\SyncException when the buffer cannot be created
Method __debugInfo
Return debug information.
Method __serialize
Serialize the buffer by name or shared object id.
Method __unserialize
Restore the buffer from a name or shared object id.
Method clear
Set all bytes to zero.
Method copyFrom
Copy bytes between buffers.
Method fill
Fill bytes with one value.
Method getAlignment
Return the alignment in bytes.
Method getName
Return the name, or null for an anonymous buffer.
Method getRefCount
Return the reference count of the mapping.
The threads and the forked children that map the same buffer share the count, so it is not the number of handles in this process.
Method getSharedId
Return the shared object id.
Method getSize
Return the buffer size in bytes.
Method read
Copy bytes out of the buffer.
Method slice
Return a view of a byte range of this buffer.
The view holds a reference to this buffer, and it cannot be serialized.
Param int $offset offset in bytes Param int $size size in bytes
Throws \ValueError when the range is outside the buffer Throws \Swow\SyncException when the view cannot be created
Method viewF32
Load 32-bit float values at a byte offset.
Method viewF64
Load 64-bit float values at a byte offset.
Method viewI16
Load signed 16-bit integers at a byte offset.
Method viewI32
Load signed 32-bit integers at a byte offset.
Method viewI64
Load signed 64-bit integers at a byte offset.
Method viewI8
Load signed 8-bit integers at a byte offset.
Method viewU16
Load unsigned 16-bit integers at a byte offset.
Method viewU32
Load unsigned 32-bit integers at a byte offset.
Method viewU64
Load unsigned 64-bit integers at a byte offset.
Method viewU8
Load unsigned 8-bit integers at a byte offset.
Method write
Copy bytes into the buffer.
Method writeF32
Store 32-bit float values at a byte offset.
Method writeF64
Store 64-bit float values at a byte offset.
Method writeI16
Store signed 16-bit integers at a byte offset.
Method writeI32
Store signed 32-bit integers at a byte offset.
Method writeI64
Store signed 64-bit integers at a byte offset.
Method writeI8
Store signed 8-bit integers at a byte offset.
Method writeU16
Store unsigned 16-bit integers at a byte offset.
Method writeU32
Store unsigned 32-bit integers at a byte offset.
Method writeU64
Store unsigned 64-bit integers at a byte offset.
Method writeU8
Store unsigned 8-bit integers at a byte offset.