v2.0.2
Instance Methods | Class Methods | Properties | List of all members
CC3Backgrounder Class Reference

#import <CC3Backgrounder.h>

Inheritance diagram for CC3Backgrounder:
Inheritance graph
[legend]

Instance Methods

(void) - runBlock:
 
(void) - runBlock:after:
 

Class Methods

(CC3Backgrounder *) + sharedBackgrounder
 

Properties

long queuePriority
 
BOOL shouldRunTasksOnRequestingThread
 

Detailed Description

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.

Method Documentation

- (void) runBlock: (void)  block

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.

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.

- (void) runBlock: (void)  block
after: (NSTimeInterval)  seconds 

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.

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.

+ (CC3Backgrounder*) sharedBackgrounder

Returns the singleton backgrounder instance.

Property Documentation

- (long) queuePriority
readwritenonatomicassign

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

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.

- (BOOL) shouldRunTasksOnRequestingThread
readwritenonatomicassign

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

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.


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