picofuse-objc

Class Methods | List of all members
NXThread Class Reference

Runs methods in threads, and provides information about cores. More...

#import <Foundation/Foundation.h>

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

Class Methods

(void) + sleepForDuration:
 Pauses the calling thread. More...
 
(void) + halt
 Stops the program, and doesn't return. More...
 
(uint8_t) + numberOfCores
 Returns the number of cores.
 
(uint8_t) + coreNumber
 Returns the number of the core which the calling thread is running on, starting with zero. More...
 
(BOOL) + run:target:
 Runs a method in a new thread. More...
 
(BOOL) + run:target:core:
 Runs a method in a new thread on a specific core. More...
 
(BOOL) + run:target:argument:
 Runs a method which has an argument in a new thread. More...
 
(BOOL) + run:target:argument:core:
 Runs a method which has an argument in a new thread on a specific core. More...
 
- 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

- 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
(id) - init
 Initialize the instance, after allocation. More...
 
(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...
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

Runs methods in threads, and provides information about cores.

A Pico has one thread for each core: only the thread on core 0 can run a method in another thread, which is on core 1, and only if nothing is already running there.

Definition at line 18 of file NXThread.h.

Method Documentation

◆ coreNumber()

+ (uint8_t) coreNumber

Returns the number of the core which the calling thread is running on, starting with zero.

Other than on a Pico, that can change at any time.

◆ halt()

+ (void) halt

Stops the program, and doesn't return.

On a Pico, it's only the calling core which stops, and the other carries on. On other systems the program is aborted.

◆ run:target:()

+ (BOOL) run: (SEL)  selector
target: (id)  target 

Runs a method in a new thread.

Parameters
selectorThe selector for the method, which has no arguments. What it returns isn't used, and can't be a struct, a union, a complex number or a long double.
targetThe object or class which has the method. If it's an NXObject, it's retained until the method returns.
Returns
YES if the thread was started, or NO if the target doesn't have the method, the method has arguments or can't be called because of what it returns, or no thread is available.

The method has its own autorelease pool.

◆ run:target:argument:()

+ (BOOL) run: (SEL)  selector
target: (id)  target
argument: (id)  argument 

Runs a method which has an argument in a new thread.

Parameters
selectorThe selector for the method, which has one argument, an object.
targetThe object or class which has the method.
argumentThe argument, which may be nil. If it's an NXObject, it's retained until the method returns.
Returns
YES if the thread was started, or NO if the target doesn't have the method, the method doesn't have one argument which is an object, or no thread is available.

Otherwise this is the same as run:target:.

◆ run:target:argument:core:()

+ (BOOL) run: (SEL)  selector
target: (id)  target
argument: (id)  argument
core: (uint8_t)  core 

Runs a method which has an argument in a new thread on a specific core.

Parameters
selectorThe selector for the method, which has one argument, an object.
targetThe object or class which has the method.
argumentThe argument, which may be nil. If it's an NXObject, it's retained until the method returns.
coreThe number of the core.
Returns
YES if the thread was started, or NO for the same reasons as run:target:core:, or if the method doesn't have one argument which is an object.

◆ run:target:core:()

+ (BOOL) run: (SEL)  selector
target: (id)  target
core: (uint8_t)  core 

Runs a method in a new thread on a specific core.

Parameters
selectorThe selector for the method, which has no arguments.
targetThe object or class which has the method.
coreThe number of the core.
Returns
YES if the thread was started. As well as the reasons for run:target:, it's NO if there's no such core, and always on a Mac, where a core can't be chosen.

Otherwise this is the same as run:target:.

◆ sleepForDuration:()

+ (void) sleepForDuration: (NXDuration)  duration

Pauses the calling thread.

Parameters
durationHow long to pause, which is rounded up to a millisecond. It doesn't if this is zero or negative.

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