Exemple #1
0
 public function run()
 {
     /* read once, see above ... */
     if ($storage = $this->storage) {
         $this->stored = $storage->getUniqueId();
         $storage->addToObject($this->stored, array(rand() * 120));
         /*
         * This stackable, being executed by a worker to manipulate a global object, created in another thread ...
         * Is now going to create a thread and pass it a reference to the global object
         * The thread 
         	created by the stackable 
         	executing in the worker 
         	can reference the same objects 
         * that all the things I just said can ...
         */
         $thread = new MyThread($storage);
         if ($thread->start()) {
             $thread->join();
             $this->tstored = $thread->getStorageId();
             /* @NOTE doesnt matter what reference to the stackable is passed to the thread */
         }
     }
 }