reactphp / promise

Promises/A implementation for PHP.
https://reactphp.org/promise/
MIT License
2.38k stars 146 forks source link

please tell me whether you can track the performance of the promise on time? #126

Closed StasToken closed 6 years ago

StasToken commented 6 years ago

hello - please tell me whether you can track the performance of the promise on time? for example we have the terms of which reject - if the operation was performed for more than 60 seconds resolve - if the operation was performed less than 60 seconds I know that in nodejs this can be done, but is it possible to do this on PHP if so how is there an example?

clue commented 6 years ago

Hi @StasToken! I'm not sure I follow what you're trying to do, it sounds like you may be looking for a timeout() function? Have you seen https://github.com/reactphp/promise-timer#timeout yet?

You can use this like this:

$promise = anyOperation();

\React\Promise\Timer\timeout($promise, 60, $loop)->then(function ($result) {
    // resolved within 60s
    var_dump($result);
});

I hope this helps :+1:

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this :+1:

StasToken commented 6 years ago

no works - timeout Code example: https://pastebin.com/TTkcjpcm Does not work timeout it can not find it, maybe I'm not connecting it right? can a complete example be possible if it does not make it difficult for you? I'm still a novice in this business

PHP Fatal error: Uncaught Error: Call to undefined function React\Promise\Timer\timeout() in...

StasToken commented 6 years ago

I'm stupid - all work...