picofuse-objc

Instance Methods | Class Methods | List of all members
NXRunLoop Class Reference

Dispatches events which are posted to it, on one or more workers, until it's shut down. More...

#import <Application/Application.h>

Inheritance diagram for NXRunLoop:
Inheritance graph
[legend]
Collaboration diagram for NXRunLoop:
Collaboration graph
[legend]

Instance Methods

(id) - init
 Initializes a run loop with room for 32 events to wait.
 
(id) - initWithCapacity:
 Initializes a run loop with room for a number of events to wait.
 
(id< NXRunLoopDelegate >) - delegate
 Returns the delegate, which isn't retained.
 
(void) - setDelegate:
 Sets the delegate, which isn't retained.
 
(int) - runWithWorkers:
 Runs, dispatching events until it's shut down. More...
 
(BOOL) - isRunning
 Returns YES if it's running.
 
(void) - shutdownWithStatus:
 Stops it taking events, and once those posted have been dispatched, makes runWithWorkers: return a status. More...
 
(BOOL) - post:
 Posts an event, which is retained until it's been dispatched. More...
 
(BOOL) - perform:target:
 Posts an event which sends a message, with no arguments, to a target. More...
 
(BOOL) - perform:target:argument:
 Posts an event which sends a message, with an object as its argument, to a target. More...
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXRunLoop *) + runningRunLoop
 Returns the run loop which is running, or nil if none is.
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

Dispatches events which are posted to it, on one or more workers, until it's shut down.

It's picofuse's sys_runloop. The thread which runs it is worker 0. On a Pico, other workers are on the other cores, and on a Mac or Linux, other threads. Every worker takes events from the same queue, in the order they were posted, so with more than one worker, events are dispatched at the same time on different cores, and what they do has to be safe for that (see Threads and mutable objects). Only one run loop runs at a time, and it can be run again once it's stopped.

Events can be posted from any thread while it runs, but not from an interrupt.

Definition at line 50 of file NXRunLoop.h.

Method Documentation

◆ perform:target:()

- (BOOL) perform: (SEL)  selector
target: (id)  target 

Posts an event which sends a message, with no arguments, to a target.

The target is retained until it's been sent, if it's an NXObject.

Returns
YES, or NO if the target doesn't have the method, the method has arguments or returns something which can't be ignored (a struct, for example), or it couldn't be posted.

◆ perform:target:argument:()

- (BOOL) perform: (SEL)  selector
target: (id)  target
argument: (id)  argument 

Posts an event which sends a message, with an object as its argument, to a target.

The target and argument are retained until it's been sent, if they're NXObjects.

Returns
YES, or NO for the same reasons as perform:target:, or if the method doesn't have one argument which is an object.

◆ post:()

- (BOOL) post: (id< NXEvent >)  event

Posts an event, which is retained until it's been dispatched.

Returns
YES, or NO if it isn't running, it's been shut down, or there's no room.

◆ runWithWorkers:()

- (int) runWithWorkers: (uint8_t)  workers

Runs, dispatching events until it's shut down.

The thread which calls this is worker 0.

Parameters
workersThe number of workers, including this one, or 0 for one on every core. More than there are cores is as many as there are.
Returns
The status it was shut down with, or -1 if it couldn't run, as another run loop is running or there isn't enough memory.

◆ shutdownWithStatus:()

- (void) shutdownWithStatus: (int)  status

Stops it taking events, and once those posted have been dispatched, makes runWithWorkers: return a status.

It does nothing if it isn't running.


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