-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove dependence on
global
keyword, use static class
- this is for mimicking the `ext-parallel` extension execution behavior of passing user defined globals around in threads.
- Loading branch information
1 parent
1180bfa
commit f709ef0
Showing
5 changed files
with
60 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Async\Spawn; | ||
|
||
class Globals | ||
{ | ||
/** | ||
* User `defined` **global** variables | ||
* | ||
* @var array[] | ||
*/ | ||
protected static $defined; | ||
|
||
protected static $isChannel = false; | ||
|
||
/** | ||
* Returns an array of **Future** `user defined` *global* variables. | ||
* | ||
* @return array[]|null | ||
*/ | ||
public static function get(): ?array | ||
{ | ||
return self::$defined; | ||
} | ||
|
||
public static function set(?string $key, $value): void | ||
{ | ||
if (isset($key)) | ||
self::$defined[$key] = $value; | ||
} | ||
|
||
public static function channelling(): void | ||
{ | ||
self::$isChannel = true; | ||
} | ||
|
||
public static function isChannelling(): bool | ||
{ | ||
return self::$isChannel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters