fscom.Async: | Types | Modinfo | Source |
Create a task by extending TTask and override Execute. Submit the task to an executor. The executor will decide when there is a good time to do the task. The returned future can be used to keep track of the task.
Use fscom.AsyncEx to use some example implementations.
TExecutor | An executor that will execute tasks. |
TFuture | A Future is an result of an asynchronus task. |
TTask | This represents a task. |
Type TExecutor | |
Description | An executor that will execute tasks. |
Information | Executors will execute taska that are submitted. The tasks may be executed in different threads or in the thread Submit or any other method was called. |
Methods Summary | |
---|---|
ExecuteAll | Executes all Tasks and waits for all of them to be done. |
ExecuteAny | Executes some Tasks and waits for one to be done and returns its result. |
Shutdown | Makes the executor refuse to take any more tasks. |
ShutdownNow | Cancels all submitted tasks and makes the executor refuse to take new tasks. |
Submit | Submit a task for the executor to execute. |
SubmitAll | Submit many tasks for the executor to execute. |
WaitShutdown | Waits for shutdown of this executor to be completed. |
Method ExecuteAll:TFuture[](tasks:TTask[] , timeout:Int = TIMEOUT_FOREVER) Abstract | |
Description | Executes all Tasks and waits for all of them to be done. |
Method ExecuteAny:Object(tasks:TTask[] , timeout:Int = TIMEOUT_FOREVER) Abstract | |
Description | Executes some Tasks and waits for one to be done and returns its result. |
Method Shutdown() Abstract | |
Description | Makes the executor refuse to take any more tasks. |
Method ShutdownNow() Abstract | |
Description | Cancels all submitted tasks and makes the executor refuse to take new tasks. |
Method Submit:TFuture(task:TTask) Abstract | |
Description | Submit a task for the executor to execute. |
Method SubmitAll:TFuture[](tasks:TTask[]) | |
Description | Submit many tasks for the executor to execute. |
Method WaitShutdown(timeout:Int = TIMEOUT_FOREVER) Abstract | |
Description | Waits for shutdown of this executor to be completed. |
Type TFuture | |
Description | A Future is an result of an asynchronus task. |
Information | Futures can be obtained upon submitting a task. They can be used to synchronize threads and keep track of the started tasks. |
Methods Summary | |
---|---|
Cancel | Attempt do cancel a task before it was executed. |
GetTask | Returns the task this future was created for. |
IsCanceled | Returns true if the task was cancelled and didn't run. |
IsDone | Returns true if the task returned a value, threw an exception or was canceled. |
Wait | Wait for the task to finish and return the result. |
Method Cancel:Byte() Abstract | |
Returns | True if it was successful. |
Description | Attempt do cancel a task before it was executed. |
Method GetTask:TTask() Abstract | |
Description | Returns the task this future was created for. |
Method IsCanceled:Byte() Abstract | |
Description | Returns true if the task was cancelled and didn't run. |
Method IsDone:Byte() Abstract | |
Description | Returns true if the task returned a value, threw an exception or was canceled. |
Method Wait:Object(timeout:Int = TIMEOUT_FOREVER) Abstract | |
Description | Wait for the task to finish and return the result. |
Information | This method will block and wait for the task to finish. It will throw any exception thrown by the task. It will throw a timeout exception if timeout was reached before the task returned. If the task was finished before this method is called, it will imediately return/throw the result. |
Type TTask | |
Description | This represents a task. |
Information | Tasks can be executed and will return a result or throw an exception. |
Methods Summary | |
---|---|
Execute | Execute the task. |
Method Execute:Object() Abstract | |
Description | Execute the task. |
Information | This Method MUST NOT interfere with the TTask-Object. So it is safe to call Execute in multiple Threads at once. |
Version | 1.0 |
---|---|
Author | Francesco Silvani |
License | zlib/libpng |