pas
Static Public Member Functions | Static Public Attributes | List of all members
pas\pas Class Reference

Static Public Member Functions

static isWindows ()
 
static on (string $event, callable $function)
 
static fire (string $event, array $parameters=[])
 
static addInessential (callable $function, float $interval_seconds=0.001, bool $call_immediately=false)
 
static remove (Loop $loop)
 
static whileLoop (callable $condition_function)
 
static condition (callable $condition_function)
 
static exitLoop ()
 
static loop (?callable $condition_function=null)
 
static timeout (callable $callback, float $seconds)
 
static add (callable $function, float $interval_seconds=0.001, bool $call_immediately=false, bool $essential=true)
 
static worker (string $worker_file, callable $message_handler)
 
static curl_exec (&$ch, callable $callback)
 
static init ()
 

Static Public Attributes

static $recalculate_loops = true
 
static $conditions
 

Member Function Documentation

◆ add()

static pas\pas::add ( callable  $function,
float  $interval_seconds = 0.001,
bool  $call_immediately = false,
bool  $essential = true 
)
static

Registers a function to be called every X seconds.

Parameters
callable$function
float$interval_seconds
bool$call_immediatelyTrue if the function should be called immediately, false if the interval should expire first.
bool$essentialFalse if the function should only be called if at least one other essential function exists.
Returns
Loop
Since
2.0 Added $essential

◆ addInessential()

static pas\pas::addInessential ( callable  $function,
float  $interval_seconds = 0.001,
bool  $call_immediately = false 
)
static

Registers a function to be called every X seconds if at least one other essential loop exists.

Parameters
callable$function
float$interval_seconds
bool$call_immediatelyTrue if the function should be called immediately, false if the interval should expire first.
Returns
Loop
Since
1.2

◆ condition()

static pas\pas::condition ( callable  $condition_function)
static

Registers a Condition to contain loops until $condition_function returns false.

Parameters
callable$condition_function
Returns
Condition
Since
1.5
Deprecated:
Starting in 1.7, new Condition($func) has the same effect as pas::condition($func) while being more intuitive.

◆ curl_exec()

static pas\pas::curl_exec ( $ch,
callable  $callback 
)
static

Drop-in replacement for curl_exec. Instead of blocking until the request has finished, this immediately returns and the result will be passed to the callback function when the request is finished.

Parameters
resource$ch
callable$callback
Returns
void

◆ exitLoop()

static pas\pas::exitLoop ( )
static

Causes the pas::loop() function to return, if it is currently running.

Returns
void

◆ fire()

static pas\pas::fire ( string  $event,
array  $parameters = [] 
)
static

Calls all event handlers for the given event.

Parameters
string$event
array$parameters
Returns
void

◆ init()

static pas\pas::init ( )
static

Used internally to initialize pas's default Conditions.

◆ isWindows()

static pas\pas::isWindows ( )
static

Returns true if the code is running on a Windows machine.

Returns
boolean

◆ loop()

static pas\pas::loop ( ?callable  $condition_function = null)
static

Runs pas's loop. This should be the last call in your script.

Parameters
callable | null$condition_functionAn optional function to determine when this function should return.
Returns
void

◆ on()

static pas\pas::on ( string  $event,
callable  $function 
)
static

Registers an event handler.

Parameters
string$event
callable$function
Returns
void

◆ remove()

static pas\pas::remove ( Loop  $loop)
static

Removes the given loop from the default Condition.

Parameters
Loop$loop
Returns
void
Deprecated:
Use Loop::remove(), instead.

◆ timeout()

static pas\pas::timeout ( callable  $callback,
float  $seconds 
)
static

Calls the given function in x seconds.

Parameters
callable$callback
float$seconds
Returns
void

◆ whileLoop()

static pas\pas::whileLoop ( callable  $condition_function)
static
Parameters
callable$condition_function
Returns
Condition
Deprecated:
Use new Condition($func), instead.

◆ worker()

static pas\pas::worker ( string  $worker_file,
callable  $message_handler 
)
static

Creates a new PHP thread running the given file.

Parameters
string$worker_fileThe absolute path to the worker's php file.
callable$message_handlerThe function to be called when the worker sends a message.
Returns
Worker
Since
1.6

Member Data Documentation

◆ $conditions

pas\pas::$conditions
static

◆ $recalculate_loops

pas\pas::$recalculate_loops = true
static