Asyncore
Static Public Member Functions | Static Public Attributes | List of all members
Asyncore\Asyncore 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 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 Asyncore\Asyncore::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

◆ addInessential()

static Asyncore\Asyncore::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

◆ condition()

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

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

Parameters
callable$condition_function
Returns
Condition

◆ curl_exec()

static Asyncore\Asyncore::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 Asyncore\Asyncore::exitLoop ( )
static

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

Returns
void

◆ fire()

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

Calls all event handlers for the given event.

Parameters
string$event
array$parameters
Returns
void

◆ init()

static Asyncore\Asyncore::init ( )
static

Used internally to initialize Asyncore's default Conditions.

◆ isWindows()

static Asyncore\Asyncore::isWindows ( )
static

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

Returns
boolean

◆ loop()

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

Runs Asyncore'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 Asyncore\Asyncore::on ( string  $event,
callable  $function 
)
static

Registers an event handler.

Parameters
string$event
callable$function
Returns
void

◆ timeout()

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

Calls the given function in x seconds.

Parameters
callable$callback
float$seconds
Returns
void

◆ worker()

static Asyncore\Asyncore::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

Member Data Documentation

◆ $conditions

Asyncore\Asyncore::$conditions
static

◆ $recalculate_loops

Asyncore\Asyncore::$recalculate_loops = true
static