mdcore  0.1.5
Defines | Functions | Variables
/home/pedro/work/mdcore/src/queue.c File Reference
#include "../config.h"
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include <limits.h>
#include "cycle.h"
#include "errs.h"
#include "fptype.h"
#include "lock.h"
#include "part.h"
#include "fifo.h"
#include "cell.h"
#include "space.h"
#include "potential.h"
#include "engine.h"
#include "queue.h"

Defines

#define error(id)   ( queue_err = errs_register( id , queue_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Functions

void * queue_get (struct queue *q, int rid, int keep)
 Get a task from the queue.
void queue_reset (struct queue *q)
 Reset the queue.
int queue_insert (struct queue *q, void *thing)
 Add an index to the given queue.
int queue_pairs_init (struct queue *q, int size, struct space *s, struct cellpair *pairs)
 Initialize a task queue with pairs.
int queue_tuples_init (struct queue *q, int size, struct space *s, struct celltuple *tuples)
 Initialize a task queue with tuples.

Variables

int queue_err = queue_err_ok
unsigned int queue_rcount = 0
char * queue_err_msg [5]

Define Documentation

#define error (   id)    ( queue_err = errs_register( id , queue_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Function Documentation

void* queue_get ( struct queue q,
int  rid,
int  keep 
)

Get a task from the queue.

Parameters:
qThe queue.
ridrunner ID for ownership issues.
keepIf true, remove the returned index from the queue.
Returns:
A task (pair or tuple) with no unresolved conflicts or NULL if none could be found.
int queue_insert ( struct queue q,
void *  thing 
)

Add an index to the given queue.

Parameters:
qThe queue.
thingThe thing to be inserted.

Inserts a task into the queue at the location of the next pointer and moves all remaining tasks up by one. Thus, if the queue is executing, the inserted task is considered to already have been taken.

Returns:
1 on success, 0 if the queue is full and <0 on error (see queue_err).
int queue_pairs_init ( struct queue q,
int  size,
struct space s,
struct cellpair pairs 
)

Initialize a task queue with pairs.

Parameters:
qThe queue to initialize.
sizeThe maximum number of cellpairs in this queue.
sThe space with which this queue is associated.
pairsAn array containing the pairs to which the queue indices will refer to.
Returns:
queue_err_ok or <0 on error (see queue_err).

Initializes a queue of the maximum given size. The initial queue is empty and can be filled with pair ids.

See also:
queue_tuples_init
void queue_reset ( struct queue q)

Reset the queue.

Parameters:
qThe queue.
int queue_tuples_init ( struct queue q,
int  size,
struct space s,
struct celltuple tuples 
)

Initialize a task queue with tuples.

Parameters:
qThe queue to initialize.
sizeThe maximum number of cellpairs in this queue.
sThe space with which this queue is associated.
tuplesAn array containing the tuples to which the queue indices will refer to.
Returns:
queue_err_ok or <0 on error (see queue_err).

Initializes a queue of the maximum given size. The initial queue is empty and can be filled with tuple ids.

See also:
queue_tuples_init

Variable Documentation

The ID of the last error.

char* queue_err_msg[5]
Initial value:
 {
        "Nothing bad happened.",
    "An unexpected NULL pointer was encountered.",
    "A call to malloc failed, probably due to insufficient memory.",
    "Attempted to insert into a full queue.",
    "An error occured in a lock function."
        }
unsigned int queue_rcount = 0
 All Data Structures Files Functions Variables Typedefs Enumerator Defines