PHP Class XPSPL\idle\Time

The amount of time can be specified in seconds or milliseconds.
Inheritance: extends XPSPL\Idle
Show file Open project: prggmr/xpspl Class Usage Examples

Protected Properties

Property Type Description
$_allow_override boolean When set to true the "override" method will be called otherwise the processor will signal a Idle_Function_Overflow.
$_idle_length integer Length of time to idle
$_instruction integer Time instruction type.
$_priority integer Priority of this idle function.
$_stop_time integer Time to stop the idle.

Public Methods

Method Description
__construct ( $time, $instruction ) Constructs the time idle.
convert_length ( integer | float $length, integer $to ) : integer | float Converts length of times from and to seconds, milliseconds and microseconds.
get_instruction ( ) : integer Returns the type of time.
get_length ( ) : integer Returns the length of time to idle.
get_time_left ( ) : integer | float Returns the amount of time left until the idle should stop.
get_time_until ( ) : integer Returns the length of time to idle until.
has_time_passed ( ) : boolean Determines if the time to idle until has passed.
idle ( Processor $processor ) : void Runs the idle function, this will call either sleep or usleep depending upon the type.
override ( object $time ) : boolean Determine if the given time idle function is less than the current.
set_time ( integer $time ) Sets the time.

Method Details

__construct() public method

Constructs the time idle.
public __construct ( $time, $instruction )

convert_length() public method

Converts length of times from and to seconds, milliseconds and microseconds.
public convert_length ( integer | float $length, integer $to ) : integer | float
$length integer | float
$to integer To instruction
return integer | float

get_instruction() public method

Returns the type of time.
public get_instruction ( ) : integer
return integer

get_length() public method

Returns the length of time to idle.
public get_length ( ) : integer
return integer

get_time_left() public method

Returns the amount of time left until the idle should stop.
public get_time_left ( ) : integer | float
return integer | float

get_time_until() public method

Returns the length of time to idle until.
public get_time_until ( ) : integer
return integer

has_time_passed() public method

Determines if the time to idle until has passed.
public has_time_passed ( ) : boolean
return boolean

idle() public method

Runs the idle function, this will call either sleep or usleep depending upon the type.
public idle ( Processor $processor ) : void
$processor XPSPL\Processor
return void

override() public method

Determine if the given time idle function is less than the current.
public override ( object $time ) : boolean
$time object Time idle object
return boolean

set_time() public method

Sets the time.
public set_time ( integer $time )
$time integer Length of time.

Property Details

$_allow_override protected property

When set to true the "override" method will be called otherwise the processor will signal a Idle_Function_Overflow.
protected bool $_allow_override
return boolean

$_idle_length protected property

Length of time to idle
protected int $_idle_length
return integer

$_instruction protected property

Time instruction type.
protected int $_instruction
return integer

$_priority protected property

Priority of this idle function.
protected int $_priority
return integer

$_stop_time protected property

Time to stop the idle.
protected int $_stop_time
return integer