File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace WyriHaximus \React \Parallel ;
4+
5+ use parallel \Runtime as ParallelRuntime ;
6+ use React \Promise \PromiseInterface ;
7+
8+ final class Runtime
9+ {
10+ /** @var string */
11+ private $ id ;
12+
13+ /** @var ParallelRuntime */
14+ private $ runtime ;
15+
16+ /** @var FutureToPromiseConverter */
17+ private $ futureToPromiseConverter ;
18+
19+ public function __construct (FutureToPromiseConverter $ futureToPromiseConverter , string $ autoload )
20+ {
21+ $ this ->runtime = new ParallelRuntime ($ autoload );
22+ $ this ->id = spl_object_hash ($ this ->runtime );
23+ $ this ->futureToPromiseConverter = $ futureToPromiseConverter ;
24+ }
25+
26+ public function run (callable $ callable , ...$ args ): PromiseInterface
27+ {
28+ return $ this ->futureToPromiseConverter ->convert (
29+ $ this ->runtime ->run ($ callable , $ args )
30+ );
31+ }
32+
33+ public function close ()
34+ {
35+ $ this ->runtime ->close ();
36+ }
37+
38+ public function kill ()
39+ {
40+ $ this ->runtime ->kill ();
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments