PULSAR  2.0.0
Parallel Ultra-Light Systolic Array Runtime
 All Data Structures Files Functions Typedefs Enumerations Macros Groups
icl_deque.c File Reference

Thread-safe double-ended queue. More...

#include "icl_deque.h"

Go to the source code of this file.

Functions

icl_deque_ticl_deque_new ()
 Creates a new deque. More...
 
int icl_deque_destroy (icl_deque_t *deque, void(*free_func)(void *))
 Destroys a deque. More...
 
icl_node_ticl_deque_first (icl_deque_t *deque)
 Returns the first node in a deque. More...
 
icl_node_ticl_deque_next (icl_deque_t *deque, icl_node_t *node)
 Returns next node in a deque. More...
 
icl_node_ticl_deque_append (icl_deque_t *deque, void *data)
 Inserts a node at the end of a deque. More...
 
icl_node_ticl_deque_prepend (icl_deque_t *deque, void *data)
 Inserts a node at the front of a deque. More...
 
int icl_deque_delete (icl_deque_t *deque, icl_node_t *node, void(*free_func)(void *))
 Deletes a node from a deque. More...
 
int icl_deque_size (icl_deque_t *deque)
 Returns the size of a deque. More...
 

Detailed Description

Thread-safe double-ended queue.

Author
Jakub Kurzak

Implemented by protecting access to icl_list using spinlocks. Also, unlike icl_list, icl_deque keeps track of its size.

PULSAR Runtime http://icl.utk.edu/pulsar/ Copyright (C) 2012-2015 University of Tennessee.

Definition in file icl_deque.c.

Function Documentation

icl_node_t* icl_deque_append ( icl_deque_t deque,
void *  data 
)

Inserts a node at the end of a deque.

Parameters
deque– The deque to append to.
data– The data to append.
Returns
The new node. NULL on error.

Definition at line 117 of file icl_deque.c.

int icl_deque_delete ( icl_deque_t deque,
icl_node_t node,
void(*)(void *)  free_func 
)

Deletes a node from a deque.

Parameters
deque– The deque to delete from.
node– The node to delete.
free_func– The function that frees the node's data.
Return values
0on success.
-1on failure.

Definition at line 163 of file icl_deque.c.

int icl_deque_destroy ( icl_deque_t deque,
void(*)(void *)  free_func 
)

Destroys a deque.

Parameters
deque– The deque to destroy.
free_func– The function that frees the node's data.
Return values
0on success.
-1on failure.

Definition at line 52 of file icl_deque.c.

icl_node_t* icl_deque_first ( icl_deque_t deque)

Returns the first node in a deque.

Parameters
deque– The deque to fetch from.
Returns
The node at the front of the deque. NULL if empty or error.

Definition at line 75 of file icl_deque.c.

icl_deque_t* icl_deque_new ( )

Creates a new deque.

Returns
A new deque. NULL on error.

Definition at line 22 of file icl_deque.c.

icl_node_t* icl_deque_next ( icl_deque_t deque,
icl_node_t node 
)

Returns next node in a deque.

Parameters
deque– The deque to fetch from.
node– The node current node.
Returns
The next node. NULL if empty or error.

Definition at line 96 of file icl_deque.c.

icl_node_t* icl_deque_prepend ( icl_deque_t deque,
void *  data 
)

Inserts a node at the front of a deque.

Parameters
deque– The deque to prepend to.
data– The data to prepent.
Returns
The new node. NULL on error.

Definition at line 139 of file icl_deque.c.

int icl_deque_size ( icl_deque_t deque)

Returns the size of a deque.

Parameters
deque– The deque to get size of.
Returns
– The size of the deque. -1 on error.

Definition at line 189 of file icl_deque.c.