GPhpThreadIntercom
in package
Process intercommunication class.
A pipe inter-process communication method is used, based on asynchronous or synchronous communication.
Table of Contents
Methods
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor. May try automatically to delete the pipe file.
- getAutoDeletionFlag() : bool
- Returns the state of the option automatic deletion of the pipe file.
- isInitialized() : bool
- Checks if the intercom is initialized and ready for use.
- isReceivingDataAvailable() : mixed
- Checks if there is pending data for receiving.
- receive() : string|null
- Receives data from the intercom.
- send() : bool
- Sends data through the intercom.
- setAutoDeletionFlag() : void
- Sets the automatic deletion option for the pipe file during the destruction of current instance.
Methods
__construct()
Constructor.
public
__construct(string $filePath[, bool $isReadMode = true ][, bool $autoDeletion = false ]) : mixed
Parameters
- $filePath : string
-
The file that is going to store the pipe.
- $isReadMode : bool = true
-
Indicates if the param is going to be read only
- $autoDeletion : bool = false
-
If it is set during the destruction of the GPhpThreadIntercom instance the pipe file will be also removed.
__destruct()
Destructor. May try automatically to delete the pipe file.
public
__destruct() : mixed
getAutoDeletionFlag()
Returns the state of the option automatic deletion of the pipe file.
public
getAutoDeletionFlag() : bool
Return values
boolisInitialized()
Checks if the intercom is initialized and ready for use.
public
isInitialized() : bool
Return values
boolisReceivingDataAvailable()
Checks if there is pending data for receiving.
public
isReceivingDataAvailable() : mixed
Return values
mixed —Returns 0 or false if there is no data up to 15 ms after the method is called. Otherwise returns the number of contained stream resources (usually 1).
receive()
Receives data from the intercom.
public
receive([int $timeout = 700 ]) : string|null
Parameters
- $timeout : int = 700
-
The maximum time period in milliseconds during which to wait for data to arrive.
Return values
string|null —If there is no data up to 700 ms after the method is called it returns NULL otherwise returns the data string itself.
send()
Sends data through the intercom.
public
send(string $dataString, int $dataLength) : bool
Parameters
- $dataString : string
-
The data to be sent
- $dataLength : int
-
The length of the data
Return values
bool —On success returns true otherwise false is returned.
setAutoDeletionFlag()
Sets the automatic deletion option for the pipe file during the destruction of current instance.
public
setAutoDeletionFlag(bool $booleanValue) : void
Parameters
- $booleanValue : bool