Inherits from NSObject
Declared in NGLThread.h

Overview

The NinevehGL thread class.

This class is responsible for managing the NinevehGL threads. By default, NGLThread will create short-lived threads, the only exception is to the Render Thread, which is internally marked as a long-lived one.

The concept of short and long lived threads are a little bit different in NinevehGL: – Short-Lived: This thread will exit automatically after process at least one task. – Long-Lived: This thread will not exit until an explicit call make it does.

If a thread is marked as short-lived and during its first task other tasks are placed into its queue, those new tasks will be processed as well and then it will exit.

The thread routine of NGLThread includes a Run Loop and an Autorelease pool, which means that obj-c messages can be queued. The Run Loop has the same interval as the maximum NinevehGL FPS. However, changing the current FPS has no effects over the Run Loops. This class always exits the thread using the best approach, letting it finish itself.

The NinevehGL thread pipeline works as following:

 ______________________         ______________________         ______________________
|                      |       |                      |       |                      |
|     User Thread*     |       |    Render Thread     |       |    Parser Thread     |
|                      |       |                      |       |                      |
| Usually is the app's |       | All the NinevehGL    |       | NinevehGL can use up |
| main thread, but can |       | render commands are  |       | to X threads like    |
| be any other thread. |       | made in this thread. |       | this one.            |
|                      |       |                      |       |                      |
| You will create and  |       | Also the OpenGL      |       | The loading/parsing  |
| manage your objects  |       | calls are made from  |       | job is done inside   |
| from this thread.    |       | this one.            |       | this thread.         |
|______________________|       |______________________|       |______________________|

        NGLView -------------------> NGLCoreEngine
                                       NGLTimer

        NGLMesh ----------------------------------------------------> NGLParser**
                                      NGLCoreMesh <------------------------|

       NGLTween ---------------------> NGLTimer

       NGLDebug ---------------------> NGLTimer

Tasks

Properties

alive

Indicates if this thread is running. It’ll return NO if the thread is not started yet or if it is finishing.

@property (nonatomic, readonly, getter=isAlive) BOOL alive

Discussion

Indicates if this thread is running. It’ll return NO if the thread is not started yet or if it is finishing.

Declared In

NGLThread.h

autoExit

Mark or unmark this thread to auto deletion.

@property (nonatomic, getter=isAutoExit) BOOL autoExit

Discussion

Mark or unmark this thread to auto deletion.

When this thread is marked for deletion, it’ll exit after processing the next queue. If there is no queue, the thread will still alive but marked for deletion.

Declared In

NGLThread.h

name

The thread’s name.

@property (nonatomic, readonly) NSString *name

Discussion

The thread’s name.

Declared In

NGLThread.h

paused

Pauses or resumes this thread.

@property (nonatomic, getter=isPaused) BOOL paused

Discussion

Pauses or resumes this thread.

Declared In

NGLThread.h

thread

The NSThread instance.

@property (nonatomic, readonly) NSThread *thread

Discussion

The NSThread instance.

Declared In

NGLThread.h

Instance Methods

cancelAllPendingRequests

Cancels all the pending requests to this thread.

- (void)cancelAllPendingRequests

Discussion

Cancels all the pending requests to this thread.

Declared In

NGLThread.h

cancelAllPendingRequestsForTarget:

Cancels all the pending requests for a specific target.

- (void)cancelAllPendingRequestsForTarget:(id)target

Parameters

target

The target object that was informed early in the performAsync:target: method.

Discussion

Cancels all the pending requests for a specific target.

Declared In

NGLThread.h

exit

Immediately exit this thread, even if there is a pending queue. The pending queues will be canceled.

- (void)exit

Discussion

Immediately exit this thread, even if there is a pending queue. The pending queues will be canceled.

Declared In

NGLThread.h

initWithName:

Initializes a NGLThread instance with a name.

- (id)initWithName:(NSString *)name

Parameters

name

The name for this thread.

Return Value

A new initialized instance.

Discussion

Initializes a NGLThread instance with a name.

This method will be called to initialize NGLThread anyway. If the single init method is called, it will call this method with a blank name.

Declared In

NGLThread.h

performAsync:target:

Inserts a new item in the queue of this thread.

- (void)performAsync:(SEL)selector target:(id)target

Parameters

selector

A SEL object.

target

The target object that will receive the method.

Discussion

Inserts a new item in the queue of this thread.

The items in the queue follow the First-in First-out rule, that means, when a new item enters in the queue, it assumes the last position and will be processed after all the current items.

The items in the queue are retained to avoid bad accesses.

Declared In

NGLThread.h

performSync:target:

Inserts a new item in the queue of this thread and wait until it is performed.

- (void)performSync:(SEL)selector target:(id)target

Parameters

selector

A SEL object.

target

The target object that will receive the method.

Discussion

Inserts a new item in the queue of this thread and wait until it is performed.

The items in the queue are retained to avoid bad accesses.

Declared In

NGLThread.h