| Iris Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#define IRIS_TYPE_STACK IrisStack; GType iris_stack_get_type (void); IrisStack* iris_stack_new (void); void iris_stack_push (IrisStack *stack, gpointer data); gpointer iris_stack_pop (IrisStack *stack); IrisStack* iris_stack_ref (IrisStack *stack); void iris_stack_unref (IrisStack *stack);
IrisStack is a lock-free stack implementation. It is not currently guaranteed to be fully correct. This is due to the classical ABA problem with many lock-free data structures. For more information on ABA, see the wikipedia page at ABA_problem.
We do try to greatly reduce the potential of this happening. This is done by aligning the destination of our internal pointers to sizeof(void*) which leaves us the two lower bits to repurpose as a counter stamp. This makes the pointer different on every compare-and-swap operation allowing us to fail and retry the operation. As you might have guessed, if the ABA problem happens 4 times within the pre-emption time of the first thread, the problem can still exist.
You can typically solve this with an indirection node.
IrisStack* iris_stack_new (void);
Creates a new instance of an IrisStack, which is a concurrent, lock-free stack implementation.
Returns : |
the newly created IrisStack instance. |
void iris_stack_push (IrisStack *stack, gpointer data);
Pushes a new item onto the stack atomically.
|
An IrisStack |
|
a pointer |
gpointer iris_stack_pop (IrisStack *stack);
Pops an item off of the stack atomically. If no item is on the stack,
then NULL is returned.
IrisStack* iris_stack_ref (IrisStack *stack);
Atomically increases the reference count of stack by one.