source: source/ariba/utility/transport/tcpip/protlib/fastqueue.h@ 5540

Last change on this file since 5540 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 3.2 KB
RevLine 
[5284]1/// ----------------------------------------*- mode: C++; -*--
2/// @file fastqueue.h
3/// Fast and thread-safe queue to send/receive messages between
4/// POSIX threads
5/// ----------------------------------------------------------
6/// $Id: fastqueue.h 2872 2008-02-18 10:58:03Z bless $
7/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/fastqueue/fastqueue.h $
8// ===========================================================
9//
10// Copyright (C) 2005-2007, all rights reserved by
11// - Institute of Telematics, Universitaet Karlsruhe (TH)
12//
13// More information and contact:
14// https://projekte.tm.uka.de/trac/NSIS
15//
16// This program is free software; you can redistribute it and/or modify
17// it under the terms of the GNU General Public License as published by
18// the Free Software Foundation; version 2 of the License
19//
20// This program is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23// GNU General Public License for more details.
24//
25// You should have received a copy of the GNU General Public License along
26// with this program; if not, write to the Free Software Foundation, Inc.,
27// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28//
29// ===========================================================
30/**
31 * @ingroup fastqueue Fast Queue
32 * @{
33 */
34
35/** @file
36 * Fast and thread-safe queue to send/receive messages between POSIX threads
37 * This can be used as a port for a thread to receive messages (from any thread).
38 * The implementations allows for arbitrary long queues, but queues grow by
39 * element blocks containing ELEMENT_BLOCKSIZE elements. This avoids frequent
40 * malloc/free operations.
41 */
42
43#ifndef QUEUE_TYPE
44#define QUEUE_TYPE
45
46#include <pthread.h>
47
48#define ELEMENT_BLOCKSIZE 64
49#define MAX_QUEUENAME_LENGTH 32
50
51
52/* queue element block type */
53typedef struct queue_elblock_struct
54 {
55 void *element[ELEMENT_BLOCKSIZE];
56 int read, write;
57 struct queue_elblock_struct *next_block;
58 }
59queue_elblock_t;
60
61
62typedef struct queue_struct
63 {
64 pthread_mutex_t mutex;
65 pthread_mutexattr_t mutex_attr;
66 pthread_cond_t cond;
67
68 unsigned long nr_of_elements;
69 unsigned long exp_nr_of_elements;
70 int exp_enabled;
71 queue_elblock_t *first_block;
72 queue_elblock_t *last_block;
73 queue_elblock_t *exp_first_block;
74 queue_elblock_t *exp_last_block;
75//#ifdef QUEUELEN
76 unsigned long queue_maxlength;
77//#endif
78 char name[MAX_QUEUENAME_LENGTH +1];
79 }
80queue_t;
81
82extern queue_t *create_queue (const char *name);
83extern int enqueue_element_signal (queue_t * queuehead, void *element);
84extern int enqueue_element_expedited_signal (queue_t * queuehead, void *element, int exp);
85extern void *dequeue_element_wait (queue_t * queuehead);
86extern void *dequeue_element_timedwait(queue_t *queuehead, const struct timespec *tspec);
87extern int destroy_queue (queue_t * queuehead);
88extern void *dequeue_element_nonblocking(queue_t * queuehead);
89extern unsigned long queue_nr_of_elements(queue_t *queue);
90extern int queue_is_expedited_enabled(queue_t *queue);
91extern int queue_enable_expedited(queue_t *queue, int exp);
92
93#endif
94
95//@}
Note: See TracBrowser for help on using the repository browser.