Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
condition.c
Go to the documentation of this file.
1 /*
2  condition.c - condition variable
3 
4  Copyright (C) Lumiera.org
5  2008, 2009, 2010, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 
22 #include "lib/condition.h"
23 
32  const char* purpose,
33  struct nobug_flag* flag,
34  const struct nobug_context ctx)
35 {
36  if (self)
37  {
38  NOBUG_RESOURCE_HANDLE_INIT (self->rh);
39  NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "cond_var", purpose, self, self->rh, ctx)
40  {
41  pthread_mutex_init (&self->cndmutex, NULL);
42  pthread_cond_init (&self->cond, NULL);
43  }
44  }
45  return self;
46 }
47 
48 
51  struct nobug_flag* flag,
52  const struct nobug_context ctx)
53 {
54  if (self)
55  {
56  NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx)
57  {
58  if (pthread_mutex_destroy (&self->cndmutex))
59  LUMIERA_DIE (LOCK_DESTROY);
60 
61  if (pthread_cond_destroy (&self->cond))
62  LUMIERA_DIE (LOCK_DESTROY);
63  }
64  }
65  return self;
66 }
67 
68 
69 /*
70 // Local Variables:
71 // mode: C
72 // c-file-style: "gnu"
73 // indent-tabs-mode: nil
74 // End:
75 */
lumiera_condition * LumieraCondition
Definition: condition.h:163
Condition variables, header.
LumieraCondition lumiera_condition_destroy(LumieraCondition self, struct nobug_flag *flag, const struct nobug_context ctx)
Destroy a condition variable.
Definition: condition.c:50
return NULL
Definition: llist.h:596
#define LUMIERA_DIE(err)
Abort unconditionally with a 'Fatal Error!' message.
Definition: error.h:63
LumieraCondition lumiera_condition_init(LumieraCondition self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx)
Initialise a condition variable.
Definition: condition.c:31