Inherits from NSObject
Declared in CC3Backgrounder.h

Overview

CC3Backgrounder performs activity on a background thread by submitting tasks to a Grand Central Dispatch (GCD) queue. In order to ensure that the GL engine is presented activity in an defined order, CC3Backgrounder is a singleton.

This core behaviour can be nulified by setting the shouldRunOnRequestingThread property to YES, which forces tasks submitted to this backgrounder to be run on the same thread from which the tasks are queued. This behaviour can be useful when loading OpenGL objects that need to be subsequently deleted. It is important that OpenGL objects are deleted from the same thread on which they are loaded.

Properties

queuePriority

Specifies the priority of the GCD global dispatch queue to which background tasks are dispatched.

@property (nonatomic, assign) long queuePriority

Discussion

Setting this property will affect any subsequent tasks submitted to the runBlock: method.

The value of this property must be one of the following GCD constants:

- DISPATCH_QUEUE_PRIORITY_HIGH
- DISPATCH_QUEUE_PRIORITY_DEFAULT
- DISPATCH_QUEUE_PRIORITY_LOW
- DISPATCH_QUEUE_PRIORITY_BACKGROUND (available starting with iOS 5)

The initial value of this property is DISPATCH_QUEUE_PRIORITY_BACKGROUND when running under iOS 5 or above, or DISPATCH_QUEUE_PRIORITY_LOW otherwise.

Declared In

CC3Backgrounder.h

shouldRunTasksOnRequestingThread

Indicates that tasks should be run on the same thread as the invocator of the task requests.

@property (nonatomic, assign) BOOL shouldRunTasksOnRequestingThread

Discussion

The initial value of this property is NO, indicating that tasks will be dispatched to a background thread for running. Set this property to YES to force tasks to run on the same thread as the request is made.

Declared In

CC3Backgrounder.h

Class Methods

sharedBackgrounder

Returns the singleton backgrounder instance.

+ (CC3Backgrounder *)sharedBackgrounder

Declared In

CC3Backgrounder.h

Instance Methods

runBlock:

If the value of the shouldRunOnRequestingThread property is NO (the default), the specified block of code is dispatched to the global GCD queue identified by the value of the queuePriority property, and the current thread continues without waiting for the dispatched code to complete.

- (void)runBlock:(void ( ^ ) ( void ))block

Discussion

If the value of the shouldRunOnRequestingThread property is YES, the specified block of code is run immediately on the current thread, and further thread activity waits until the specified block has completed.

Declared In

CC3Backgrounder.h

runBlock:after:

  • Waits the specified number of seconds, then executes the specified block of code
  • either on a background thread, or the current thread, depending on the value of
  • the shouldRunOnRequestingThread property.
- (void)runBlock:(void ( ^ ) ( void ))block after:(NSTimeInterval)seconds

Discussion

  • If the value of the shouldRunOnRequestingThread property is NO (the default), the specified
  • block of code is dispatched to the global GCD queue identified by the value of the queuePriority
  • property. If the value of the shouldRunOnRequestingThread property is YES, the specified block
  • of code is run on the current thread.

Declared In

CC3Backgrounder.h