SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osip_fifo.h
Go to the documentation of this file.
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2012 Aymeric MOIZARD amoizard@antisip.com
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _FIFO_H_
21 #define _FIFO_H_
22 
23 #ifndef OSIP_MONOTHREAD
24 #include <osip2/osip_mt.h>
25 #endif
26 #include <osipparser2/osip_list.h>
27 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 
47 #ifndef DOXYGEN
48 
49  typedef enum { osip_ok, osip_empty } osip_fifo_state;
50 
51 #endif
52 
57  typedef struct osip_fifo osip_fifo_t;
58 
63  struct osip_fifo {
64 #ifndef OSIP_MONOTHREAD
66  struct osip_sem *qisempty;
67 #endif
69  int nb_elt;
71  };
72 
82  void osip_fifo_init (osip_fifo_t * ff);
87  void osip_fifo_free (osip_fifo_t * ff);
93  int osip_fifo_insert (osip_fifo_t * ff, void *element);
99  int osip_fifo_add (osip_fifo_t * ff, void *element);
104  int osip_fifo_size (osip_fifo_t * ff);
105 #ifndef OSIP_MONOTHREAD
106 
110  void *osip_fifo_get (osip_fifo_t * ff);
111 #endif
112 
116  void *osip_fifo_tryget (osip_fifo_t * ff);
117 
118 
122 #ifdef __cplusplus
123 }
124 #endif
125 #endif
Structure for referencing a list of elements.
Definition: osip_list.h:82
osip_fifo_state
Definition: osip_fifo.h:49
struct osip_sem * qisempty
semaphore for fifo
Definition: osip_fifo.h:66
Structure for referencing a fifo.
Definition: osip_fifo.h:63
int osip_fifo_size(osip_fifo_t *ff)
Get the number of element in a fifo.
void * osip_fifo_tryget(osip_fifo_t *ff)
Try to get an element from a fifo, but do not block if there is no element.
oSIP list Routines
void osip_fifo_free(osip_fifo_t *ff)
Free a fifo element.
oSIP Thread, Mutex and Semaphore definitions
int osip_fifo_insert(osip_fifo_t *ff, void *element)
Insert an element in a fifo (at the beginning).
void * osip_fifo_get(osip_fifo_t *ff)
Get an element from a fifo or block until one is added.
osip_list_t queue
list of nodes containing elements
Definition: osip_fifo.h:68
struct osip_mutex * qislocked
mutex for fifo
Definition: osip_fifo.h:65
int osip_fifo_add(osip_fifo_t *ff, void *element)
Add an element in a fifo.
int nb_elt
nb of elements
Definition: osip_fifo.h:69
osip_fifo_state state
state of the fifo
Definition: osip_fifo.h:70
Structure for referencing a semaphore element.
Structure for referencing a mutex element.
void osip_fifo_init(osip_fifo_t *ff)
Initialise a osip_fifo_t element.