Genisys  Genisys API 1.9.3
A server software for Minecraft: Pocket Edition with many features
AsyncTask Class Reference
Inheritance diagram for AsyncTask:
[legend]
Collaboration diagram for AsyncTask:
[legend]

Public Member Functions

 isGarbage ()
 
 setGarbage ()
 
 isFinished ()
 
 run ()
 
 isCrashed ()
 
 getResult ()
 
 cancelRun ()
 
 hasCancelledRun ()
 
 hasResult ()
 
 setResult ($result, $serialize=true)
 
 setTaskId ($taskId)
 
 getTaskId ()
 
 getFromThreadStore ($identifier)
 
 saveToThreadStore ($identifier, $value)
 
 onRun ()
 
 onCompletion (Server $server)
 
 cleanObject ()
 
- Public Member Functions inherited from Threaded
 chunk ($size, bool $preserve=false)
 
 count ()
 
 isRunning ()
 
 isTerminated ()
 
 merge ($from, $overwrite=true)
 
 notify ()
 
 notifyOne ()
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 pop ()
 
 run ()
 
 shift ()
 
 synchronized (\Closure $function, $args=null)
 
 wait ($timeout)
 
 getRefCount ()
 
 addRef ()
 
 delRef ()
 
 isGarbage ()
 

Data Fields

 $worker = null
 

Additional Inherited Members

- Static Public Member Functions inherited from Threaded
static extend ($obj)
 

Detailed Description

Class used to run async tasks in other threads.

An AsyncTask does not have its own thread. It is queued into an AsyncPool and executed if there is an async worker with no AsyncTask running. Therefore, an AsyncTask SHOULD NOT execute for more than a few seconds. For tasks that run for a long time or infinitely, start another pocketmine\Threadinstead.WARNING:DonotcallPocketMine-MPAPImethods,orsaveobjects(andarrayscontainingobjects)from/onotherThreads!!

Member Function Documentation

getFromThreadStore (   $identifier)

Gets something into the local thread store. You have to initialize this in some way from the task on run

Parameters
string$identifier
Returns
mixed
getResult ( )
Returns
mixed
hasResult ( )
Returns
bool
isGarbage ( )
Returns
bool

Implements Collectable.

onCompletion ( Server  $server)

Actions to execute when completed (on main thread) Implement this if you want to handle the data in your AsyncTask after it has been processed

Parameters
Server$server
Returns
void
onRun ( )
abstract

Actions to execute when run

Returns
void
saveToThreadStore (   $identifier,
  $value 
)

Saves something into the local thread store. This might get deleted at any moment.

Parameters
string$identifier
mixed$value
setResult (   $result,
  $serialize = true 
)
Parameters
mixed$result
bool$serialize

The documentation for this class was generated from the following file: