• PHP Video Tutorials

PHP - Threaded Functions



The Threaded class

The Threaded objects form the basis of pthreads ability to execute user code in parallel. They can expose synchronization methods and various interfaces.

Threaded objects can provide implicit safety for a programmer. All operations on the object scope are safe.

Class synopsis

Threaded implements Collectable , Traversable , Countable , ArrayAccess {
   
   /* Methods */
   public array chunk( integer $size , boolean $preserve )
   public integer count( void )
   public bool extend( string $class )
   public Threaded from( Closure $run [, Closure $construct [, array $args ]] )
   public array getTerminationInfo( void )
   public boolean isRunning( void )
   public boolean isTerminated( void )
   public boolean isWaiting( void )
   public boolean lock( void )
   public boolean merge( mixed $from [, bool $overwrite ] )
   public boolean notify( void )
   public boolean notifyOne( void )
   public boolean pop( void )
   public void run( void )
   public mixed shift( void )
   public mixed synchronized( Closure $block [, mixed $... ] )
   public boolean unlock( void )
   public boolean wait([ integer $timeout ] )
}
Sr.No Function & Description
1

Threaded::chunk()

Function can fetch a chunk of objects property table of a given size, optionally preserving keys.

2

Threaded::count()

Function can return the number of properties for this object, and doesn't have any parameters.

3

Threaded::extend()

Function can make a thread-safe standard class at runtime.

4

Threaded::from()

Function can create an anonymous Threaded object from closures.

5

Threaded::getTerminationInfo()

Function can retrieve terminal error information from a referenced object.

6

Threaded::isRunning()

Function can tell if a referenced object is executing.

7

Threaded::isTerminated

Function tell if a referenced object is terminated during execution, suffered fatal errors, or throw uncaught exceptions.

8

Threaded::isWaiting()

Function can tell if a referenced object is waiting for the notification.

9

Threaded::lock()

Function can lock a referenced objects property table.

10

Threaded::merge

Function can merge the data into a current object.

11

Threaded::notify()

Function can send a notification to referenced object.

12

Threaded::notifyOne()

Function can send a notification to referenced object.

13

Threaded::pop()

Function can pop an item from objects property table.

14

Threaded::run()

Function can always implement a run method for objects that are intended for execution.

15

Threaded::shift()

Function can shift an item from the objects property table.

16

Threaded::synchronized()

Function can return a value from the block.

17

Threaded::unlock()

Function can unlock the referenced objects storage for calling context.

18

Threaded::wait()

Function cause calling context to wait for notification from the referenced object.

php_function_reference.htm
Advertisements