|
4 | 4 | * $Id$ |
5 | 5 | * |
6 | 6 | * DESCRIPTION |
7 | | - * A Core file for Aether.sh |
| 7 | + * |
8 | 8 | * |
9 | | - * @link http://nxsys.org/spaces/aether |
10 | 9 | * @link https://onx.zulipchat.com |
11 | 10 | * |
12 | | - * @package Aether |
13 | | - * @subpackage System |
14 | | - * @license http://nxsys.org/spaces/aether/wiki/license |
| 11 | + * @package Parallax |
15 | 12 | * Please see the license.txt file or the url above for full copyright and license information. |
16 | | - * @copyright Copyright 2018 Nexus Systems, inc. |
| 13 | + * @copyright Copyright 2019 Nexus Systems, inc. |
17 | 14 | * |
18 | | - * @author Chris R. Feamster <cfeamster@f2developments.com> |
| 15 | + * @author William Graber <wgraber@nxs.systems> |
19 | 16 | * @author $LastChangedBy$ |
20 | 17 | * |
21 | 18 | * @version $Revision$ |
|
29 | 26 | use NxSys\Toolkits\Parallax\Job\BaseJob; |
30 | 27 |
|
31 | 28 | /** Framework Dependencies **/ |
32 | | -use Worker; |
| 29 | +use parallel\Runtime as Thread_Runtime; |
| 30 | +use parallel\Channel as Thread_Channel; |
| 31 | + |
| 32 | +//.... |
| 33 | +use SplQueue; |
| 34 | +use Exception; |
| 35 | +use Throwable; |
| 36 | +use Closure; |
33 | 37 |
|
34 | 38 | /** Library Dependencies **/ |
35 | 39 | use NxSys\Core\ExtensibleSystemClasses as CoreEsc; |
36 | 40 |
|
| 41 | +const DEFAULT_CHANNEL_CAPACITY = 1024; |
| 42 | + |
37 | 43 | /** |
38 | | - * Undocumented class |
39 | | - * |
40 | | - * Why does this exist? What does this do? |
41 | | - * |
42 | | - * @throws NxSys\Toolkits\Parallax\IException Well, does it? |
43 | | - * @author Chris R. Feamster <cfeamster@f2developments.com> |
| 44 | + * |
44 | 45 | */ |
45 | | - class BaseAgent implements IAgent |
46 | | - { |
47 | | - |
48 | | - } |
| 46 | +class BaseAgent |
| 47 | +{ |
| 48 | + protected $hThreadRuntime = False; |
| 49 | + |
| 50 | + public function __construct() |
| 51 | + { |
| 52 | + if (!$this->hThreadRuntime) |
| 53 | + { |
| 54 | + $this->hThreadRuntime=new Thread_Runtime(__DIR__.'\..\..\vendor\autoload.php'); |
| 55 | + } |
| 56 | + |
| 57 | + $this->oInData=new Thread_Channel(DEFAULT_CHANNEL_CAPACITY); |
| 58 | + $this->oOutData=new Thread_Channel(DEFAULT_CHANNEL_CAPACITY); |
| 59 | + |
| 60 | + $this->cExecute = function (BaseJob $oJob, Thread_Channel $oInData, Thread_Channel $oOutData, $aArguments = []) |
| 61 | + { |
| 62 | + $oJob->setInputChannel($oInData); |
| 63 | + $oJob->setOutputChannel($oOutData); |
| 64 | + $oJob->initialize(); |
| 65 | + return $oJob->run($aArguments); |
| 66 | + }; |
| 67 | + } |
| 68 | + |
| 69 | + |
| 70 | + public function run(BaseJob $oJob, array $aArguments = []) |
| 71 | + { |
| 72 | + $oResult = $this->hThreadRuntime->run($this->cExecute, [$oJob, $this->oInData, $this->oOutData, $aArguments]); |
| 73 | + return $oResult; |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments