PlatformThreading
public protocol PlatformThreading : AnyObject
Protocol for task activities on the main thread.
-
Runs a task on the main thread. If this function is called from the main thread, then the task will run immediately. Otherwise, it is put to the end of the queue of the main thread. Note: Depending on actual platform, destruction-time of passed in runnable might be unknown due to unpredictability of garbage collection. Therefore, runnable should not hold strong references to objects whose lifetimes are critical or references should be released at the end of execution.
Declaration
Swift
func runOnMainThread(runnable: Runnable) -> TaskHandleParameters
runnableTask that should be executed on the main thread. Destruction-time of runnable is unknown.
Return Value
Handle that will be used to manipulate execution of the task.
-
Posts a task to be executed on the main thread after some delay. If the delay is 0, the function puts the task at the end of the queue. The function does not wait for the task to be executed and returns immediately after the task has been put in the queue. Note: Depending on actual platform, destruction-time of passed in runnable might be unknown due to unpredictability of garbage collection. Therefore, runnable should not hold strong references to objects whose lifetimes are critical or references should be released at the end of execution.
Declaration
Swift
func postToMainThread(runnable: Runnable, delayMs: UInt64) -> TaskHandleParameters
runnableTask that should be executed on the main thread. Destruction-time of runnable is unknown.
delayMsDelay in milliseconds.
Return Value
Handle that will be used to manipulate execution of the task.
-
Posts task to the end of the queue of the main thread. Function does not wait for task to be executed and returns immediately after the task is put to the queue. Note: Depending on actual platform, destruction-time of passed in runnable might be unknown due to unpredictability of garbage collection. Therefore, runnable should not hold strong references to objects whose lifetimes are critical or references should be released at the end of execution.
Declaration
Swift
func postToMainThread(runnable: Runnable) -> TaskHandleParameters
runnableTask that should be executed on the main thread. Destruction-time of runnable is unknown.
Return Value
Handle that will be used to manipulate execution of the task.