Dynamic Load Balance 3.6.1+32-59d1
Data Structures | Enumerations | Functions
queues.c File Reference
#include "support/queues.h"
#include "support/debug.h"
#include "apis/dlb_errors.h"
#include <string.h>
Include dependency graph for queues.c:

Data Structures

struct  queue_t
 
struct  queue_iter_t
 

Enumerations

enum  { NOBODY = 0 }
 

Functions

void queue_lewi_reqs_init (queue_lewi_reqs_t *queue)
 
unsigned int queue_lewi_reqs_size (const queue_lewi_reqs_t *queue)
 
unsigned int queue_lewi_reqs_remove (queue_lewi_reqs_t *queue, pid_t pid)
 
int queue_lewi_reqs_push (queue_lewi_reqs_t *queue, pid_t pid, unsigned int howmany)
 
unsigned int queue_lewi_reqs_pop_ncpus (queue_lewi_reqs_t *queue, unsigned int ncpus, lewi_request_t *requests, unsigned int *nreqs, unsigned int maxreqs)
 
unsigned int queue_lewi_reqs_get (queue_lewi_reqs_t *queue, pid_t pid)
 
void queue_proc_reqs_init (queue_proc_reqs_t *queue)
 
unsigned int queue_proc_reqs_size (const queue_proc_reqs_t *queue)
 
process_request_tqueue_proc_reqs_front (queue_proc_reqs_t *queue)
 
process_request_tqueue_proc_reqs_back (queue_proc_reqs_t *queue)
 
void queue_proc_reqs_remove (queue_proc_reqs_t *queue, pid_t pid)
 
int queue_proc_reqs_push (queue_proc_reqs_t *queue, pid_t pid, unsigned int howmany, const cpu_set_t *allowed)
 
void queue_proc_reqs_pop (queue_proc_reqs_t *queue, process_request_t *request)
 
void queue_proc_reqs_get (queue_proc_reqs_t *queue, pid_t *pid, int cpuid)
 
void queue_pids_init (queue_pids_t *queue)
 
unsigned int queue_pids_size (const queue_pids_t *queue)
 
void queue_pids_remove (queue_pids_t *queue, pid_t pid)
 
int queue_pids_push (queue_pids_t *queue, pid_t pid)
 
void queue_pids_pop (queue_pids_t *queue, pid_t *pid)
 
queue_tqueue__init (size_t element_size, unsigned int capacity, void *ptr, queue_allocator_t allocator)
 
void queue__destroy (queue_t *queue)
 
unsigned int queue__get_size (const queue_t *queue)
 
unsigned int queue__get_capacity (const queue_t *queue)
 
bool queue__is_empty (const queue_t *queue)
 
bool queue__is_at_capacity (const queue_t *queue)
 
int queue__take_head (queue_t *queue, void *poped)
 
int queue__take_tail (queue_t *queue, void *poped)
 
int queue__peek_head (queue_t *queue, void **value_ptr)
 
int queue__peek_tail (queue_t *queue, void **value_ptr)
 
void * queue__push_head (queue_t *queue, const void *new)
 
void * queue__push_tail (queue_t *queue, const void *new)
 
void queue_iter__foreach (void *iter, void(*fn)(void *, void *), void *args)
 
void * queue_iter__get_nth (void *iter, unsigned int n)
 
queue_iter_head2tail_t queue__into_head2tail_iter (queue_t *queue)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NOBODY 

Function Documentation

◆ queue_lewi_reqs_init()

void queue_lewi_reqs_init ( queue_lewi_reqs_t queue)

◆ queue_lewi_reqs_size()

unsigned int queue_lewi_reqs_size ( const queue_lewi_reqs_t queue)

◆ queue_lewi_reqs_remove()

unsigned int queue_lewi_reqs_remove ( queue_lewi_reqs_t queue,
pid_t  pid 
)

◆ queue_lewi_reqs_push()

int queue_lewi_reqs_push ( queue_lewi_reqs_t queue,
pid_t  pid,
unsigned int  howmany 
)

◆ queue_lewi_reqs_pop_ncpus()

unsigned int queue_lewi_reqs_pop_ncpus ( queue_lewi_reqs_t queue,
unsigned int  ncpus,
lewi_request_t requests,
unsigned int *  nreqs,
unsigned int  maxreqs 
)

◆ queue_lewi_reqs_get()

unsigned int queue_lewi_reqs_get ( queue_lewi_reqs_t queue,
pid_t  pid 
)

◆ queue_proc_reqs_init()

void queue_proc_reqs_init ( queue_proc_reqs_t queue)

◆ queue_proc_reqs_size()

unsigned int queue_proc_reqs_size ( const queue_proc_reqs_t queue)

◆ queue_proc_reqs_front()

process_request_t * queue_proc_reqs_front ( queue_proc_reqs_t queue)

◆ queue_proc_reqs_back()

process_request_t * queue_proc_reqs_back ( queue_proc_reqs_t queue)

◆ queue_proc_reqs_remove()

void queue_proc_reqs_remove ( queue_proc_reqs_t queue,
pid_t  pid 
)

◆ queue_proc_reqs_push()

int queue_proc_reqs_push ( queue_proc_reqs_t queue,
pid_t  pid,
unsigned int  howmany,
const cpu_set_t *  allowed 
)

◆ queue_proc_reqs_pop()

void queue_proc_reqs_pop ( queue_proc_reqs_t queue,
process_request_t request 
)

◆ queue_proc_reqs_get()

void queue_proc_reqs_get ( queue_proc_reqs_t queue,
pid_t *  pid,
int  cpuid 
)

◆ queue_pids_init()

void queue_pids_init ( queue_pids_t queue)

◆ queue_pids_size()

unsigned int queue_pids_size ( const queue_pids_t queue)

◆ queue_pids_remove()

void queue_pids_remove ( queue_pids_t queue,
pid_t  pid 
)

◆ queue_pids_push()

int queue_pids_push ( queue_pids_t queue,
pid_t  pid 
)

◆ queue_pids_pop()

void queue_pids_pop ( queue_pids_t queue,
pid_t *  pid 
)

◆ queue__init()

queue_t * queue__init ( size_t  element_size,
unsigned int  capacity,
void *  ptr,
queue_allocator_t  allocator 
)

Initializes a queue with a pre-allocated storage.

  • element_size: the size of the type to be stored.
  • capacity: the number of elements that fit in the queue.
  • ptr: the pointer to the memory allocated for storage.
  • allocator: chooses what to do when the queue is full.

Notes:

  • Set ptr to null if you want the allocation to be done automatically.
  • When ptr is NOT null the QUEUE_ALLOC_REALLOC is not a valid allocator.

Returns NULL if it fails.

◆ queue__destroy()

void queue__destroy ( queue_t queue)

Destroys a queue and frees the storage.

  • queue: the queue to destroy.

◆ queue__get_size()

unsigned int queue__get_size ( const queue_t queue)

Returns the number of elements avaliable in the queue.

  • queue: the queue where the operation is performed.

◆ queue__get_capacity()

unsigned int queue__get_capacity ( const queue_t queue)

Returns the maximum number of elements the queue can fit.

  • queue: the queue where the operation is performed.

◆ queue__is_empty()

bool queue__is_empty ( const queue_t queue)

Returns true if the queue does not contain any element.

◆ queue__is_at_capacity()

bool queue__is_at_capacity ( const queue_t queue)

Returns true if the number of elements is equal to the capacity of the queue.

When the queue is at capacity it means that if more data is puhsed to the queue without removing this action will cause an error, overwrite a value from the other end, or reallocate the storage (depending on the choosen allocation policy).

◆ queue__take_head()

int queue__take_head ( queue_t queue,
void *  value 
)

Takes the head off of the queue and places it to poped.

  • queue: the queue where the operation is performed.
  • poped: the pointer of where to place the head.

Returns DLB_NOUPDT if the queue is empty, and DLB_SUCCESS otherwise.

◆ queue__take_tail()

int queue__take_tail ( queue_t queue,
void *  value 
)

Takes the tail off of the queue and places it to poped.

  • queue: the queue where the operation is performed.
  • poped: the pointer of where to place the tail.

Returns DLB_NOUPDT if the queue is empty, and DLB_SUCCESS otherwise.

◆ queue__peek_head()

int queue__peek_head ( queue_t queue,
void **  value_ptr 
)

Peek the head and return its value without removing it from the queue.

  • queue: the queue where the operation is performed.
  • poped: the pointer of where to copy the reference to head.

Returns DLB_NOUPDT if the queue is empty, and DLB_SUCCESS otherwise.

◆ queue__peek_tail()

int queue__peek_tail ( queue_t queue,
void **  value_ptr 
)

Peek the tail and return its value without removing it from the queue.

  • queue: the queue where the operation is performed.
  • poped: the pointer of where to copy the reference to tail.

Returns DLB_NOUPDT if the queue is empty, and DLB_SUCCESS otherwise.

◆ queue__push_head()

void * queue__push_head ( queue_t queue,
const void *  new 
)

Pushes the new value to the queue on the head, and overwrites the tail if the queue was at capacity.

  • queue: the queue where the operation is performed.
  • new: the pointer to the value to push.

Returns NULL if the push fails.

◆ queue__push_tail()

void * queue__push_tail ( queue_t queue,
const void *  new 
)

Pushes the new value to the queue on the head, and overwrites the tail if the queue was at capacity.

  • queue: the queue where the operation is performed.
  • new: the pointer to the value to push.

Returns NULL if the push fails.

◆ queue_iter__foreach()

void queue_iter__foreach ( void *  iter,
void(*)(void *, void *)  fn,
void *  args 
)

Executes the fn function for all the values of iter as it is iterated by its specific implementation.

  • iter: the pointer to the iterator
  • fn: the function to run for all elements it receives as arguments args and the current element of the iterator
  • args: a pointer to a user defined variable

◆ queue_iter__get_nth()

void * queue_iter__get_nth ( void *  iter,
unsigned int  n 
)

Returns a pointer to the nth element in the iterator.

  • iter: the pointer to the iterator
  • n: the number of elements to skip before returning

Returns NULL if not enough elements are avaliable.

◆ queue__into_head2tail_iter()

queue_iter_head2tail_t queue__into_head2tail_iter ( queue_t queue)

Creates a queue_iter_head2tail_t iterator from a queue_t.

  • queue: the queue from which the iterator will be created.