3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WebWorker extends Worker { public function __construct(SafeLog $logger) { $this->logger = $logger; } protected $logger; } /* the collectable class implements machinery for Pool::collect */ class WebWork extends Collectable { public function run() { $this->worker ->logger ->log("%s executing in Thread #%lu", __CLASS__, $this->worker->getThreadId()); $this->setGarbage(); } } class SafeLog extends Stackable { protected function log($message, $args = []) { $args = func_get_args(); if (($message = array_shift($args))) { echo vsprintf( "{$message}\n", $args); } } } $pool = new Pool(8, \WebWorker::class, [new SafeLog()]); $pool->submit($w=new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->submit(new WebWork()); $pool->shutdown(); $pool->collect(function($work){ return $work->isGarbage(); }); var_dump($pool); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EbUOh
function name:  (null)
number of ops:  93
compiled vars:  !0 = $pool, !1 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'webworker', 'worker'
   12     1        DECLARE_CLASS                                            'webwork', 'collectable'
   22     2        DECLARE_CLASS                                            'safelog', 'stackable'
   34     3        NEW                                              $2      'Pool'
          4        SEND_VAL_EX                                              8
          5        SEND_VAL_EX                                              'WebWorker'
          6        NEW                                              $3      'SafeLog'
          7        DO_FCALL                                      0          
          8        INIT_ARRAY                                       ~5      $3
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !0, $2
   36    12        INIT_METHOD_CALL                                         !0, 'submit'
         13        NEW                                              $8      'WebWork'
         14        DO_FCALL                                      0          
         15        ASSIGN                                           ~10     !1, $8
         16        SEND_VAL_EX                                              ~10
         17        DO_FCALL                                      0          
   37    18        INIT_METHOD_CALL                                         !0, 'submit'
         19        NEW                                              $12     'WebWork'
         20        DO_FCALL                                      0          
         21        SEND_VAR_NO_REF_EX                                       $12
         22        DO_FCALL                                      0          
   38    23        INIT_METHOD_CALL                                         !0, 'submit'
         24        NEW                                              $15     'WebWork'
         25        DO_FCALL                                      0          
         26        SEND_VAR_NO_REF_EX                                       $15
         27        DO_FCALL                                      0          
   39    28        INIT_METHOD_CALL                                         !0, 'submit'
         29        NEW                                              $18     'WebWork'
         30        DO_FCALL                                      0          
         31        SEND_VAR_NO_REF_EX                                       $18
         32        DO_FCALL                                      0          
   40    33        INIT_METHOD_CALL                                         !0, 'submit'
         34        NEW                                              $21     'WebWork'
         35        DO_FCALL                                      0          
         36        SEND_VAR_NO_REF_EX                                       $21
         37        DO_FCALL                                      0          
   41    38        INIT_METHOD_CALL                                         !0, 'submit'
         39        NEW                                              $24     'WebWork'
         40        DO_FCALL                                      0          
         41        SEND_VAR_NO_REF_EX                                       $24
         42        DO_FCALL                                      0          
   42    43        INIT_METHOD_CALL                                         !0, 'submit'
         44        NEW                                              $27     'WebWork'
         45        DO_FCALL                                      0          
         46        SEND_VAR_NO_REF_EX                                       $27
         47        DO_FCALL                                      0          
   43    48        INIT_METHOD_CALL                                         !0, 'submit'
         49        NEW                                              $30     'WebWork'
         50        DO_FCALL                                      0          
         51        SEND_VAR_NO_REF_EX                                       $30
         52        DO_FCALL                                      0          
   44    53        INIT_METHOD_CALL                                         !0, 'submit'
         54        NEW                                              $33     'WebWork'
         55        DO_FCALL                                      0          
         56        SEND_VAR_NO_REF_EX                                       $33
         57        DO_FCALL                                      0          
   45    58        INIT_METHOD_CALL                                         !0, 'submit'
         59        NEW                                              $36     'WebWork'
         60        DO_FCALL                                      0          
         61        SEND_VAR_NO_REF_EX                                       $36
         62        DO_FCALL                                      0          
   46    63        INIT_METHOD_CALL                                         !0, 'submit'
         64        NEW                                              $39     'WebWork'
         65        DO_FCALL                                      0          
         66        SEND_VAR_NO_REF_EX                                       $39
         67        DO_FCALL                                      0          
   47    68        INIT_METHOD_CALL                                         !0, 'submit'
         69        NEW                                              $42     'WebWork'
         70        DO_FCALL                                      0          
         71        SEND_VAR_NO_REF_EX                                       $42
         72        DO_FCALL                                      0          
   48    73        INIT_METHOD_CALL                                         !0, 'submit'
         74        NEW                                              $45     'WebWork'
         75        DO_FCALL                                      0          
         76        SEND_VAR_NO_REF_EX                                       $45
         77        DO_FCALL                                      0          
   49    78        INIT_METHOD_CALL                                         !0, 'submit'
         79        NEW                                              $48     'WebWork'
         80        DO_FCALL                                      0          
         81        SEND_VAR_NO_REF_EX                                       $48
         82        DO_FCALL                                      0          
   50    83        INIT_METHOD_CALL                                         !0, 'shutdown'
         84        DO_FCALL                                      0          
   52    85        INIT_METHOD_CALL                                         !0, 'collect'
         86        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEbUOh%3A52%243'
   54    87        SEND_VAL_EX                                              ~52
         88        DO_FCALL                                      0          
   56    89        INIT_FCALL                                               'var_dump'
         90        SEND_VAR                                                 !0
         91        DO_ICALL                                                 
   57    92      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEbUOh%3A52%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EbUOh
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $work
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
   53     1        INIT_METHOD_CALL                                         !0, 'isGarbage'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   54     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEbUOh%3A52%243

Class WebWorker:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EbUOh
function name:  __construct
number of ops:  4
compiled vars:  !0 = $logger
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN_OBJ                                               'logger'
          2        OP_DATA                                                  !0
    6     3      > RETURN                                                   null

End of function __construct

End of class WebWorker.

Class WebWork:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EbUOh
function name:  run
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'worker'
   15     1        FETCH_OBJ_R                                      ~1      ~0, 'logger'
   16     2        INIT_METHOD_CALL                                         ~1, 'log'
          3        SEND_VAL_EX                                              '%25s+executing+in+Thread+%23%25lu'
   17     4        SEND_VAL_EX                                              'WebWork'
          5        FETCH_OBJ_R                                      ~2      'worker'
          6        INIT_METHOD_CALL                                         ~2, 'getThreadId'
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR_NO_REF_EX                                       $3
          9        DO_FCALL                                      0          
   18    10        INIT_METHOD_CALL                                         'setGarbage'
         11        DO_FCALL                                      0          
   19    12      > RETURN                                                   null

End of function run

End of class WebWork.

Class SafeLog:
Function log:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/EbUOh
function name:  log
number of ops:  17
compiled vars:  !0 = $message, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   25     2        FUNC_GET_ARGS                                    ~2      
          3        ASSIGN                                                   !1, ~2
   27     4        INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !1
          6        DO_ICALL                                         $4      
          7        ASSIGN                                           ~5      !0, $4
          8      > JMPZ                                                     ~5, ->16
   28     9    >   INIT_FCALL                                               'vsprintf'
   29    10        NOP                                                      
         11        FAST_CONCAT                                      ~6      !0, '%0A'
         12        SEND_VAL                                                 ~6
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $7      
         15        ECHO                                                     $7
   31    16    > > RETURN                                                   null

End of function log

End of class SafeLog.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.47 ms | 1413 KiB | 19 Q