libasynql  3.2.0
Asynchronous MySQL access library for PocketMine plugins.
SqlThreadPool Class Reference
Inheritance diagram for SqlThreadPool:
SqlThread

Public Member Functions

 __construct (callable $workerFactory, int $workerLimit)
 
 join ()
 
 stopRunning ()
 
 addQuery (int $queryId, int $mode, string $query, array $params)
 
 readResults (array &$callbacks)
 
 connCreated ()
 
 hasConnError ()
 
 getConnError ()
 
 getLoad ()
 

Additional Inherited Members

- Data Fields inherited from SqlThread
const MODE_GENERIC = 0
 
const MODE_CHANGE = 1
 
const MODE_INSERT = 2
 
const MODE_SELECT = 3
 

Detailed Description

Definition at line 29 of file SqlThreadPool.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( callable  $workerFactory,
int  $workerLimit 
)

SqlThreadPool constructor.

Parameters
callable$workerFactorycreate a child worker: function(?Threaded $bufferSend = null, ?Threaded $bufferRecv = null) : BaseSqlThread{}
int$workerLimitthe maximum number of workers to create. Workers are created lazily.

Definition at line 47 of file SqlThreadPool.php.

Member Function Documentation

◆ addQuery()

addQuery ( int  $queryId,
int  $mode,
string  $query,
array  $params 
)

Adds a query to the queue.

Parameters
int$queryId
int$mode
string$query
mixed[]$params

Implements SqlThread.

Definition at line 71 of file SqlThreadPool.php.

◆ connCreated()

connCreated ( )

Checks if the initial connection has been made, no matter successful or not.

Returns
bool

Implements SqlThread.

Definition at line 96 of file SqlThreadPool.php.

◆ getConnError()

getConnError ( )

Gets the error of the initial connection.

Returns
null|string

Implements SqlThread.

Definition at line 104 of file SqlThreadPool.php.

◆ getLoad()

getLoad ( )

Definition at line 108 of file SqlThreadPool.php.

◆ hasConnError()

hasConnError ( )

Checks if the initial connection failed.

Returns
bool

Implements SqlThread.

Definition at line 100 of file SqlThreadPool.php.

◆ join()

join ( )

Joins the thread

See also
https://php.net/thread.join Thread::join

Implements SqlThread.

Definition at line 59 of file SqlThreadPool.php.

◆ readResults()

readResults ( array &  $callbacks)

Handles the results that this query has completed

Parameters
callable[]$callbacks

Implements SqlThread.

Definition at line 85 of file SqlThreadPool.php.

◆ stopRunning()

stopRunning ( )

Signals the thread to stop waiting for queries when the send buffer is cleared.

Implements SqlThread.

Definition at line 65 of file SqlThreadPool.php.


The documentation for this class was generated from the following file: