Lumiera  0.pre.03
»edit your freedom«
sectionlock.h
Go to the documentation of this file.
1 /*
2  sectionlock.h - mutex state handle
3 
4  Copyright (C)
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 */
12 
13 
18 #ifndef LUMIERA_SECTIONLOCK_H
19 #define LUMIERA_SECTIONLOCK_H
20 
21 #include <pthread.h>
22 #include <nobug.h>
23 
24 
25 typedef void
26 (*lumiera_sectionlock_unlock_fn)(void*, struct nobug_flag* flag,
27  struct nobug_resource_user** handle,
28  const struct nobug_context ctx);
29 
34 {
35  void* lock;
36  lumiera_sectionlock_unlock_fn unlock;
37  NOBUG_IF_ALPHA(struct nobug_flag* flag);
38  RESOURCE_USER (rh);
39 };
40 typedef struct lumiera_sectionlock_struct lumiera_sectionlock;
41 typedef struct lumiera_sectionlock_struct* LumieraSectionlock;
42 
43 /* helper function for nobug */
44 static inline void
45 lumiera_sectionlock_ensureunlocked (LumieraSectionlock self)
46 {
47  ENSURE (!self->lock, "forgot to unlock");
48 }
49 
50 
57 #define LUMIERA_SECTION_UNLOCK_(section) \
58  do if ((section)->lock) \
59  { \
60  (section)->unlock((section)->lock, (section)->flag, \
61  &(section)->rh, NOBUG_CONTEXT); \
62  (section)->lock = NULL; \
63  } while (0)
64 
65 
66 #endif
67 /*
68 // Local Variables:
69 // mode: C
70 // c-file-style: "gnu"
71 // indent-tabs-mode: nil
72 // End:
73 */
sectionlock used to manage the state of mutexes.
Definition: sectionlock.h:33