picofuse-objc

Instance Methods | List of all members
NXCondition Class Reference

A lock, and a condition which threads holding it can wait for. More...

#import <Foundation/Foundation.h>

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

Instance Methods

(id) - init
 Initializes a condition. More...
 
(void) - lock
 Locks it, waiting until no other thread holds it. More...
 
(void) - unlock
 Unlocks it, which only the thread which locked it can do. More...
 
(void) - wait
 Unlocks it and waits until it's signalled, then locks it again. More...
 
(BOOL) - waitForDuration:
 As wait, but for no longer than a duration. More...
 
(void) - signal
 Wakes one thread which is waiting, if there are any.
 
(void) - broadcast
 Wakes every thread which is waiting.
 
- 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...
 

Additional Inherited Members

- 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...
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

A lock, and a condition which threads holding it can wait for.

A thread locks it, and while what it's waiting for isn't true, waits, which unlocks it until another thread signals it. Waking up doesn't mean it is true, so it's always checked again in a loop:

[condition lock];
while (!ready) {
[condition wait];
}
[condition unlock];

It's a picofuse condition variable and mutex, which are limited in number and shared with the rest of the program. Its lock isn't recursive, and it can't be used in an interrupt.

Definition at line 32 of file NXCondition.h.

Method Documentation

◆ init()

- (id) init

Initializes a condition.

Returns
The condition, or nil if there's no picofuse condition variable or mutex left, or not enough memory.

Implements Object.

◆ lock()

- (void) lock

Locks it, waiting until no other thread holds it.

Panics if it can't.

Reimplemented from <NXLocking>.

◆ unlock()

- (void) unlock

Unlocks it, which only the thread which locked it can do.

Panics if it can't.

Reimplemented from <NXLocking>.

◆ wait()

- (void) wait

Unlocks it and waits until it's signalled, then locks it again.

It has to be locked by this thread. Panics if it can't wait.

◆ waitForDuration:()

- (BOOL) waitForDuration: (NXDuration)  duration

As wait, but for no longer than a duration.

Parameters
durationHow long to wait at most, rounded up to a millisecond.
Returns
YES if it was signalled, or NO if the duration passed first, or straight away if it's zero or negative. It's locked again either way.

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