Skip to content

Commit 6d5761f

Browse files
committed
* Re-working thread execution paradigms.
** Agents are now meaningful, maintaining a Parallel\Runtime, and executing Jobs (which have been much simplified).
1 parent 8fcf1a2 commit 6d5761f

File tree

5 files changed

+271
-245
lines changed

5 files changed

+271
-245
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "library",
55
"require":
66
{
7-
"php": ">=7.2",
7+
"php": ">=7.3",
88
"ext-parallel": "^1.1",
99
"nxsys/core": "^0.4.0"
1010
},

src/Agent/BaseAgent.php

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
* $Id$
55
*
66
* DESCRIPTION
7-
* A Core file for Aether.sh
7+
*
88
*
9-
* @link http://nxsys.org/spaces/aether
109
* @link https://onx.zulipchat.com
1110
*
12-
* @package Aether
13-
* @subpackage System
14-
* @license http://nxsys.org/spaces/aether/wiki/license
11+
* @package Parallax
1512
* 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.
1714
*
18-
* @author Chris R. Feamster <cfeamster@f2developments.com>
15+
* @author William Graber <wgraber@nxs.systems>
1916
* @author $LastChangedBy$
2017
*
2118
* @version $Revision$
@@ -29,20 +26,51 @@
2926
use NxSys\Toolkits\Parallax\Job\BaseJob;
3027

3128
/** 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;
3337

3438
/** Library Dependencies **/
3539
use NxSys\Core\ExtensibleSystemClasses as CoreEsc;
3640

41+
const DEFAULT_CHANNEL_CAPACITY = 1024;
42+
3743
/**
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+
*
4445
*/
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

Comments
 (0)