Go to file
2020-07-31 15:44:40 +02:00
.github Upload code coverage 2020-07-31 15:12:12 +02:00
examples First commit 2020-07-31 15:09:34 +02:00
lib First commit 2020-07-31 15:09:34 +02:00
test First commit 2020-07-31 15:09:34 +02:00
.gitignore First commit 2020-07-31 15:09:34 +02:00
.php_cs.dist First commit 2020-07-31 15:09:34 +02:00
composer.json First commit 2020-07-31 15:09:34 +02:00
LICENSE First commit 2020-07-31 15:09:34 +02:00
phpunit.xml.dist First commit 2020-07-31 15:09:34 +02:00
psalm.xml First commit 2020-07-31 15:09:34 +02:00
README.md Update 2020-07-31 15:44:40 +02:00

AsyncConstruct

Build status codecov License

danog/asyncConstruct provides async class constructor and wakeup functions for AMPHP.

Installation

composer require danog/async-construct

API

AsyncConstruct

Example

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 yielded, will wait for and return the return value of the constructor.

inited()

Returns a boolean, indicating whether the class was initialized or not.

BlockingConstruct

Example

Exactly like AsyncConstruct, except that the blocking init() function will be automatically called on construction.

AsyncWakeup

Example

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 yielded, 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

Example

Exactly like AsyncWakeup, except that the blocking wakeup() function will be automatically called on wakeup.