This is automatic generated document for things in Swow\Buffer class

Class Buffer

Constants

public COMMON_SIZE = 8192 public PAGE_SIZE = 4096

This constant holds page size of this machine, it’s platform-dependent.

At Linux mips64 and macOS arm64 platforms, this constant may have a value 16384

Methods

Static method alignSize

public static function alignSize ( int $size , int $alignment ) : int

Method __construct

public function __construct ( int $size )

Method __debugInfo

public function __debugInfo ( ) : array<string, mixed>

Returns array<string, mixed> debug information for var_dump

Method __serialize

public function __serialize ( ) : array

Method __toString

public function __toString ( ) : string

Method __unserialize

public function __unserialize ( array $data ) : void

Method alloc

public function alloc ( int $size ) : void

Method append

public function append ( \Stringable|string $string , int<0, max> $start , int<-1, max> $length ) : int

append $string to the end of buffer

$start and $length is for input $string

Returns int bytes written

Throws \ValueError when specified $start, $offset or $length not in range

Method clear

public function clear ( ) : void

Method close

public function close ( ) : void

Method dupString

public function dupString ( ) : string

Method extend

public function extend ( int $recommendSize ) : void

Param int $recommendSize [optional] = $this->getSize() * 2

Method fetchString

public function fetchString ( ) : string

Method getAvailableSize

public function getAvailableSize ( ) : int

Method getLength

public function getLength ( ) : int

Method getLocker

public function getLocker ( ) : Coroutine

Method getSize

public function getSize ( ) : int

Method isAvailable

public function isAvailable ( ) : bool

Method isEmpty

public function isEmpty ( ) : bool

Method isFull

public function isFull ( ) : bool

Method isLocked

public function isLocked ( ) : bool

Method lock

public function lock ( ) : void

Method mallocTrim

public function mallocTrim ( ) : void

Method prepare

public function prepare ( int $appendLength ) : void

Method read

public function read ( int<0, max> $start , int<-1, max> $length ) : string

read at max $length bytes data from start

Returns string data read

Throws \ValueError when specified $start and $length not in range

Method realloc

public function realloc ( int $size ) : void

Method toString

public function toString ( ) : string

Method truncate

public function truncate ( int $length ) : int

Returns int length of buffer after truncate

Method truncateFrom

public function truncateFrom ( int $offset , int $length ) : int

Param int $offset [optional] = $this->getOffset()

Returns int length of buffer after truncate

Method tryLock

public function tryLock ( ) : bool

Method unlock

public function unlock ( ) : void

Method write

public function write ( int<0, max> $offset , \Stringable|string $string , int<0, max> $start , int<-1, max> $length ) : int

write $string to buffer

$start and $length is for input $string $offset is for output $buffer

Returns int bytes written

Throws \ValueError when specified $start, $offset or $length not in range


Copyright 2022 the Swow contributors