PHP Class XPSPL\Processor

The brainpower of XPSPL. v0.3.0 The loop is now run in respect to the currently available processes, this prevents the processor from running continuously forever when there is not anything that it needs to do. To achieve this the processor uses routines. v3.0.0 Signal storages have been upgraded to a database object, the routine and evaluation methods for the complex signal have also been moved into their own classes. The loop has been replaced with a goto statement, measurements indicate that it performs faster than a loop ... though should it?
Inheritance: use trait State
Datei anzeigen Open project: prggmr/xpspl Class Usage Examples

Public Properties

Property Type Description
$active_threads array Active processor threads.

Protected Properties

Property Type Description
$_history boolean | array Signal history.

Public Methods

Method Description
__construct ( ) : void Starts the processor.
after ( SIG $signal, Process $process ) : boolean Registers a function to interrupt the signal stack after a signal emits.
anaylze_runtime ( SIG_Awake $sig_awake ) : void Analyzes the processor runtime and shutdowns when no activity is detected.
are_processes_exhausted ( Processes $database ) : boolean Determine if the given database processes are exhausted.
before ( SIG $signal, Process $process ) : boolean Registers a function to interrupt the signal stack before a signal emits.
clean ( boolean $history = false ) : void Cleans any exhausted signals from the processor.
current_signal ( integer $offset = 1 ) : object Returns the current signal in execution.
delete_process ( SIG $signal, Process $process ) : boolean Removes a signal process.
delete_signal ( SIG $signal, boolean $history = false ) : void Delete a signal from the processor.
emit ( SIG $signal ) : object Emits a signal.
erase_history ( ) : void Cleans out the signal history.
erase_signal_history ( string | object $signal ) : void Erases any history of a signal.
evaluate_signals ( SIG $signal ) : array | null Perform the evaluation for all registered complex signals.
find_signal_database ( SIG $signal ) : null | object Finds an installed signals processes database.
flush ( ) : void Flush
get_database ( SIG $signal ) : array Returns the signal database for the given signal.
get_routine ( ) : null | object Returns the current routine object.
has_signal_exhausted ( SIG $signal ) : boolean Determines if the given signal has exhausted.
listen ( Listener $listener ) : void Listen
register_signal ( SIG $signal ) : boolean | object Registers a signal into the processor.
set_signal_history ( boolean $flag ) : void Sets the flag for storing the signal history.
shutdown ( ) : void Sends the processor the shutdown signal.
signal ( SIG $signal, Process $process ) : object | boolean Creates a new signal process.
signal_history ( ) : array Returns the signal history.
wait_loop ( ) : void Waits for the next signal to occur.

Protected Methods

Method Description
_signal_interrupt ( SIG $signal, Process $process, $interrupt = null ) : boolean Registers a function to interrupt the signal stack before or after a signal emits.

Private Methods

Method Description
_execute ( SIG $signal, Processes $db, $interrupt = true ) : void Executes a database of processes.
_get_int_database ( $interrupt ) : object Returns the interruption storage database.
_interrupt ( SIG $signal, $interrupt = null ) : boolean Process signal interuption functions.
_process_exec ( SIG $signal, mixed $function = null ) : boolean Executes a callable processor function.
_processes_execute ( SIG $signal, Processes $db ) : void Executes a processes database.
_routine ( ) : boolean | array Runs the signal routine for the processor loop.

Method Details

__construct() public method

Starts the processor.
public __construct ( ) : void
return void

_signal_interrupt() protected method

Registers a function to interrupt the signal stack before or after a signal emits.
protected _signal_interrupt ( SIG $signal, Process $process, $interrupt = null ) : boolean
$signal SIG
$process Process Process to execute
return boolean True|False false is failure

after() public method

Registers a function to interrupt the signal stack after a signal emits.
public after ( SIG $signal, Process $process ) : boolean
$signal SIG Signal instance or class name
$process Process Process to execute
return boolean True|False false is failure

anaylze_runtime() public method

Analyzes the processor runtime and shutdowns when no activity is detected.
public anaylze_runtime ( SIG_Awake $sig_awake ) : void
$sig_awake SIG_Awake SIG_Awake
return void

are_processes_exhausted() public method

Determine if the given database processes are exhausted.
public are_processes_exhausted ( Processes $database ) : boolean
$database XPSPL\database\Processes
return boolean

before() public method

This allows for manipulation of the signal before it is passed to any processes.
public before ( SIG $signal, Process $process ) : boolean
$signal SIG Signal instance or class name
$process Process Process to execute
return boolean True|False false is failure

clean() public method

Cleans any exhausted signals from the processor.
public clean ( boolean $history = false ) : void
$history boolean Erase any history of the signals cleaned.
return void

current_signal() public method

Returns the current signal in execution.
public current_signal ( integer $offset = 1 ) : object
$offset integer In memory hierarchy offset +/-.
return object

delete_process() public method

Removes a signal process.
public delete_process ( SIG $signal, Process $process ) : boolean
$signal SIG Signal instance or signal.
$process Process Process instance or identifier.
return boolean

delete_signal() public method

Delete a signal from the processor.
public delete_signal ( SIG $signal, boolean $history = false ) : void
$signal SIG Signal to delete.
$history boolean Erase any history of the signal.
return void

emit() public method

Emits a signal.
public emit ( SIG $signal ) : object
$signal SIG \XPSPL\SIG
return object Event

erase_history() public method

Cleans out the signal history.
public erase_history ( ) : void
return void

erase_signal_history() public method

Erases any history of a signal.
public erase_signal_history ( string | object $signal ) : void
$signal string | object Signal to be erased from history.
return void

evaluate_signals() public method

Perform the evaluation for all registered complex signals.
public evaluate_signals ( SIG $signal ) : array | null
$signal SIG Signal to evaluate
return array | null [[[signal, queue], eval_return]]

find_signal_database() public method

Finds an installed signals processes database.
public find_signal_database ( SIG $signal ) : null | object
$signal SIG SIG
return null | object \XPSPL\database\Signals

flush() public method

Resets the signal databases, the routine object and cleans the history if tracked.
public flush ( ) : void
return void

get_database() public method

Returns the signal database for the given signal.
public get_database ( SIG $signal ) : array
$signal SIG
return array

get_routine() public method

Returns the current routine object.
public get_routine ( ) : null | object
return null | object

has_signal_exhausted() public method

Determines if the given signal has exhausted.
public has_signal_exhausted ( SIG $signal ) : boolean
$signal SIG \XPSPL\SIG
return boolean

listen() public method

Registers an object listener.
public listen ( Listener $listener ) : void
$listener Listener XPSPL\Listener
return void

register_signal() public method

Registers a signal into the processor.
public register_signal ( SIG $signal ) : boolean | object
$signal SIG Signal
return boolean | object false|XPSPL\database\Processes

set_signal_history() public method

Note that this will delete the current if reset.
public set_signal_history ( boolean $flag ) : void
$flag boolean
return void

shutdown() public method

Sends the processor the shutdown signal.
public shutdown ( ) : void
return void

signal() public method

Creates a new signal process.
public signal ( SIG $signal, Process $process ) : object | boolean
$signal SIG Signal to attach the process.
$process Process
return object | boolean Process, boolean if error

signal_history() public method

Returns the signal history.
public signal_history ( ) : array
return array

wait_loop() public method

Waits for the next signal to occur.
public wait_loop ( ) : void
return void

Property Details

$_history protected_oe property

Signal history.
protected bool|array $_history
return boolean | array

$active_threads public_oe property

Active processor threads.
public array $active_threads
return array