Download the PHP package danog/async-construct without Composer
On this page you can find all versions of the php package danog/async-construct. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danog/async-construct
More information about danog/async-construct
Files in danog/async-construct
Package async-construct
Short Description Async class constructor and wakeup functions for AMPHP.
License MIT
Homepage https://github.com/danog/asyncConstruct
Informations about the package async-construct
AsyncConstruct
danog/asyncConstruct
provides async class constructor and wakeup functions for AMPHP.
Installation
API
- Async
- AsyncConstruct
- AsyncWakeup
- Blocking
- BlockingConstruct
- BlockingWakeup
AsyncConstruct
Simply use
this trait in your class, and define a __construct_async
async method.
The trait will automatically run the async method on construction, and expose a set of APIs to wait on the result of the constructor for initialization.
init()
Will blockingly wait for execution of the async constructor, returning its return value.
initAsynchronously()
Will return a promise that, when yield
ed, will wait for and return the return value of the constructor.
inited()
Returns a boolean, indicating whether the class was initialized or not.
BlockingConstruct
Exactly like AsyncConstruct, except that the blocking init()
function will be automatically called on construction.
AsyncWakeup
Simply use
this trait in your class, and define a __wakeup_async
async method.
The trait will automatically run the async method on deserialization, and expose a set of APIs to wait on the result of the wakeup function for re-initialization.
wakeup()
Will blockingly wait for execution of the async wakeup function, returning its return value.
wakeupAsynchronously()
Will return a promise that, when yield
ed, will wait for and return the return value of the wakeup function.
wokenUp()
Returns a boolean, indicating whether the class was initialized or not.
BlockingWakeup
Exactly like AsyncWakeup, except that the blocking wakeup()
function will be automatically called on wakeup.