Index

RBThreading.swift

Protocols

Classes


RBThreading

Threading convenience methods.

Functions

Executes a block after a delay.
@param taskBlock : The block to execute.
@param delay : The delay in seconds until the block will be executed.
@param dispatchQueue : The queue to execute the block in.
@returns A id object that can be cancelled before execution.
public class func dispatchTaskBlock(_ taskBlock: @escaping () -> (), afterDelay delay: TimeInterval, using dispatchQueue: DispatchQueue) -> RBCancellableTask

Measures the time that it takes to complete a task.
@param taskBlock : The block to execute the task.
@param completion : The completion block that is called at the end with the result.
public class func measureTask(_ taskBlock: @escaping (() -> Void) -> Void, completion: @escaping (_ timeTaken: TimeInterval) -> Void)

Calls a block on the main thread. Checks if the current thread is the the main one otherwise uses DispatchQueue.main.sync
@param block : The block to execute.
public class func dispatchMain(_ block: () -> Void)


RBCancellableBlockTask

A task that executes a block and allows cancellation before execution.

Properties

The block to be executed.
public var taskBlock (() -> Void) { get }

Whether the task has been cancelled.
public var cancelled Bool { get }

Whether the task has been started.
public var started Bool { get }

Whether the task has been completed.
public var finished Bool { get }

Functions

public func cancel()

Starts the task by executing the block.
@returns Whether the task was started successfully.
public func start() -> Bool