picofuse-objc

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

A 32-bit unsigned number, which threads can read and change without a lock. More...

#import <Foundation/Foundation.h>

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

Instance Methods

(id) - initWithUnsignedInt32:
 Initializes an atomic with a value.
 
(uint32_t) - unsignedInt32Value
 Returns the value.
 
(void) - setUnsignedInt32Value:
 Sets the value.
 
(BOOL) - compareAndSwap:with:
 Sets the value, if it's what's expected. More...
 
(uint32_t) - increment
 Adds one, wrapping around to zero, and returns the new value.
 
(uint32_t) - decrement
 Takes away one, wrapping around to UINT32_MAX, and returns the new value.
 
(void) - setBits:
 Sets the bits which are set in a mask.
 
(void) - clearBits:
 Clears the bits which are set in a mask.
 
(NXString *) - description
 Returns the value, in decimal.
 
- 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...
 
- 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...
 

Class Methods

(id) + atomicWithUnsignedInt32:
 Returns a new atomic.
 
- 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...
 
- 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

A 32-bit unsigned number, which threads can read and change without a lock.

It's a picofuse atomic. Each change is whole. A value set with setUnsignedInt32Value: or compareAndSwap:with: hands over what the thread wrote before it to a thread which then reads the value, so it can say that other data is ready. increment, decrement and the bits don't: they're for counts and flags. It can't be used in an interrupt, as sending a message there isn't safe.

Definition at line 21 of file NXAtomic.h.

Method Documentation

◆ compareAndSwap:with:()

- (BOOL) compareAndSwap: (uint32_t)  expected
with: (uint32_t)  desired 

Sets the value, if it's what's expected.

Parameters
expectedThe value it has to be.
desiredThe value to set.
Returns
YES if it was expected and is now desired, or NO if another thread changed it first, when it's left as it is.

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