]> rtime.felk.cvut.cz Git - frescor/forb.git/blob - src/syncobj.h
Merge branch 'master' of rtime.felk.cvut.cz:/frescor/frsh-forb
[frescor/forb.git] / src / syncobj.h
1 #ifndef SYNC_OBJ_H
2 #define SYNC_OBJ_H
3
4 //----------------------------------------------------------------------
5 //  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
6 //
7 //    Universidad de Cantabria,              SPAIN
8 //    University of York,                    UK
9 //    Scuola Superiore Sant'Anna,            ITALY
10 //    Kaiserslautern University,             GERMANY
11 //    Univ. Politecnica  Valencia,           SPAIN
12 //    Czech Technical University in Prague,  CZECH REPUBLIC
13 //    ENEA                                   SWEDEN
14 //    Thales Communication S.A.              FRANCE
15 //    Visual Tools S.A.                      SPAIN
16 //    Rapita Systems Ltd                     UK
17 //    Evidence                               ITALY
18 //
19 //    See http://www.frescor.org
20 //
21 //        The FRESCOR project (FP6/2005/IST/5-034026) is funded
22 //        in part by the European Union Sixth Framework Programme
23 //        The European Union is not liable of any use that may be
24 //        made of this code.
25 //
26 //
27 //  based on previous work (FSF) done in the FIRST project
28 //
29 //   Copyright (C) 2005  Mälardalen University, SWEDEN
30 //                       Scuola Superiore S.Anna, ITALY
31 //                       Universidad de Cantabria, SPAIN
32 //                       University of York, UK
33 //
34 // This file is part of DTM (Distributed Transaction Manager)
35 //
36 // DTM is free software; you can redistribute it and/or modify it
37 // under terms of the GNU General Public License as published by the
38 // Free Software Foundation; either version 2, or (at your option) any
39 // later version.  DTM is distributed in the hope that it will be
40 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
41 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 // General Public License for more details. You should have received a
43 // copy of the GNU General Public License along with DTM; see file
44 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
45 // Cambridge, MA 02139, USA.
46 //
47 // As a special exception, including DTM header files in a file,
48 // instantiating DTM generics or templates, or linking other files
49 // with DTM objects to produce an executable application, does not
50 // by itself cause the resulting executable application to be covered
51 // by the GNU General Public License. This exception does not
52 // however invalidate any other reasons why the executable file might be
53 // covered by the GNU Public License.
54 // -----------------------------------------------------------------------
55
56 /*!
57  * @file syncobj.h
58  *
59  * @brief Synchronization objects
60  *
61  * This module contains the definition of simple synchronization
62  * objects built on top FOSA condition variables.
63  *
64  * @author Michael Gonzalez Harbour <mgh@unican.es>
65  * @author Michal Sojka <sojkam1@fel.cvut.cz>
66  * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
67  *
68  */
69
70 #ifndef _SYNC_OBJ_H_
71 #define _SYNC_OBJ_H_
72
73 #include <fosa_mutexes_and_condvars.h>
74 #include <time.h> /* for timespec */
75 #include <fosa_opaque_types.h> /* for FOSA_ETIMEDOUT */
76
77 /**
78  * Semaphore-like synchronization object build on top of FOSA's
79  * condition variables.
80  */
81 typedef struct forb_syncobj {
82         bool is_work_done;
83         fosa_cond_t cond;
84         fosa_mutex_t mutex;
85 } forb_syncobj_t;
86
87
88 extern int forb_syncobj_init(forb_syncobj_t *syncobj, int ceiling);
89 extern int forb_syncobj_destroy(forb_syncobj_t *syncobj);
90 extern int forb_syncobj_signal(forb_syncobj_t *syncobj);
91 extern int forb_syncobj_wait(forb_syncobj_t *syncobj);
92 extern int forb_syncobj_timedwait(forb_syncobj_t *syncobj,
93                                   const struct timespec *abstime);
94 #define FORB_ETIMEDOUT FOSA_ETIMEDOUT
95
96 #endif // _SYNC_OBJ_H_
97
98
99 #endif