PHP Classes

File: docs/api/files/Factory.php.txt

Recommend this page to a friend!
  Classes of AlexanderC   Threadator   docs/api/files/Factory.php.txt   Download  
File: docs/api/files/Factory.php.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: Threadator
Create threads and send messages between them
Author: By
Last change: Update of docs/api/files/Factory.php.txt
Date: 5 months ago
Size: 1,110 bytes
 

Contents

Class file image Download
<?php /** * @author AlexanderC <self@alexanderc.me> * @date 4/7/14 * @time 9:09 PM */ namespace Threadator; use Threadator\Implementation\CallableThread; class Factory { /** * @var Runtime */ protected $runtime; /** * @param Runtime $runtime */ public function __construct(Runtime $runtime) { $this->runtime = $runtime; } /** * @return \Threadator\Runtime */ public function getRuntime() { return $this->runtime; } /** * @param string $threadClass * @return Thread * @throws \BadMethodCallException */ public function create($threadClass) { if(!is_subclass_of($threadClass, Thread::class)) { throw new \BadMethodCallException("Threaded class should be an instance of Thread"); } return new $threadClass($this->runtime); } /** * @param callable $callable * @return $this */ public function createCallable(callable $callable) { return (new CallableThread($this->runtime))->setCallable($callable); } }