Created
September 10, 2019 15:29
-
-
Save bubba-h57/0c4d5261618aafb55519290292130f5b to your computer and use it in GitHub Desktop.
Stub File for PHP extension parallel
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
<?php declare(strict_types=1); | |
/** | |
* A helper file for providing autocomplete information for your IDE. | |
* | |
* This file should not be included in your code, only analyzed by your IDE! | |
* | |
* @author Bubba Hines <bubba@stechstudio.com> | |
*/ | |
namespace parallel { | |
class Future | |
{ | |
/** | |
* Resolution | |
* The returned value of the closure, or void. | |
* | |
* @return mixed | |
*/ | |
public function value() | |
{ | |
} | |
/** | |
* State | |
* | |
* Whether this task was cancelled. | |
*/ | |
public function cancelled(): bool | |
{ | |
} | |
/** | |
* State | |
* | |
* Whether this task is done. | |
*/ | |
public function done(): bool | |
{ | |
} | |
/** | |
* Cancellation | |
* | |
* Command to cancel this task | |
*/ | |
public function cancel(): bool | |
{ | |
} | |
} | |
class Runtime | |
{ | |
/** | |
* Create | |
* Shall construct a bootstrapped runtime if bootstrap is provided. | |
*/ | |
public function __construct(?string $bootstrap = null) | |
{ | |
} | |
/** | |
* Execute | |
* Shall schedule task for execution in parallel. | |
*/ | |
public function run(Closure $task, ?array $argv = null): ?Future | |
{ | |
} | |
/** | |
* Join | |
* Requests that the runtime task close via a graceful join. | |
*/ | |
public function close(): void | |
{ | |
} | |
/** | |
* Attempts to force the runtime to shutdown. | |
*/ | |
public function kill(): void | |
{ | |
} | |
} | |
class Channel | |
{ | |
/* Anonymous Constructor */ | |
const Infinite = null; | |
/** Shall make an anonymous buffered channel with the given capacity if provided */ | |
public function __construct(?int $capacity = null) | |
{ | |
} | |
/** Shall make a buffered channel with the given name and capacity if provided */ | |
public function make(string $name, ?int $capacity = null): Channel | |
{ | |
} | |
/** Shall open the channel with the given name */ | |
public function open(string $name): Channel | |
{ | |
} | |
/** | |
* Shall recv a value from this channel | |
* @return mixed | |
*/ | |
public function recv() | |
{ | |
} | |
/** | |
* Shall send the given value on this channel | |
* @param mixed $value | |
*/ | |
public function send($value): void | |
{ | |
} | |
/** Shall close this channel */ | |
public function close(): void | |
{ | |
} | |
} | |
class Events implements Countable, Traversable | |
{ | |
/** Shall set input for this event loop */ | |
public function setInput(Input $input): void | |
{ | |
} | |
/** Shall watch for events on the given channel */ | |
public function addChannel(Channel $channel): void | |
{ | |
} | |
/** Shall watch for events on the given future */ | |
public function addFuture(string $name, Future $future): void | |
{ | |
} | |
/** Shall remove the given target */ | |
public function remove(string $target): void | |
{ | |
} | |
/** Shall set blocking mode */ | |
public function setBlocking(bool $blocking): void | |
{ | |
} | |
/** Shall set the timeout in microseconds */ | |
public function setTimeout(int $timeout): void | |
{ | |
} | |
/** Shall poll for the next event */ | |
public function poll(): ?Event | |
{ | |
} | |
} | |
class Sync | |
{ | |
/** | |
* Shall construct a new synchronization object containing the optional scalar value | |
* @param scalar|null $value | |
*/ | |
public function __construct($value) | |
{ | |
} | |
/** Shall atomically return the synchronization objects value */ | |
public function get(): scalar | |
{ | |
} | |
/** Shall atomically set the value of the synchronization object */ | |
public function set(scalar $value) | |
{ | |
} | |
/** Shall wait for notification on this synchronization object */ | |
public function wait() | |
{ | |
} | |
/** Shall notify one (by default) or all threads waiting on the synchronization object */ | |
public function notify(array $all) | |
{ | |
} | |
/** Shall exclusively enter into the critical code */ | |
public function __invoke(callable $critical) | |
{ | |
} | |
} | |
/** | |
* Shall use the provided file to bootstrap all runtimes created | |
* for automatic scheduling via parallel\run(). | |
*/ | |
function bootstrap(string $file): void | |
{ | |
} | |
function run(\Closure $task, ?array $argv = null): ?Future | |
{ | |
} | |
} | |
namespace parallel\Events { | |
class Input | |
{ | |
/** Shall set input for the given target */ | |
public function add(string $target, mixed $value): void | |
{ | |
} | |
/** Shall remove input for the given target */ | |
public function remove(string $target): void | |
{ | |
} | |
/** Shall remove input for all targets */ | |
public function clear(): void | |
{ | |
} | |
} | |
class Event | |
{ | |
/* Shall be one of Event\Type constants */ | |
public int $type; | |
/* Shall be the source of the event (target name) */ | |
public string $source; | |
/* Shall be either Future or Channel */ | |
public object $object; | |
/* Shall be set for Read/Error events */ | |
public $value; | |
} | |
} | |
namespace parallel\Events\Event { | |
class Type | |
{ | |
/* Event::$object was read into Event::$value */ | |
const Read = null; | |
/* Input for Event::$source written to Event::$object */ | |
const Write = null; | |
/* Event::$object (Channel) was closed */ | |
const Close = null; | |
/* Event::$object (Future) was cancelled */ | |
const Cancel = null; | |
/* Runtime executing Event::$object (Future) was killed */ | |
const Kill = null; | |
/* Event::$object (Future) raised error */ | |
const Error = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment