Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
mutex.c
Go to the documentation of this file.
1/*
2 mutex.c - mutex
3
4 Copyright (C)
5 2008, 2009, 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#include "lib/mutex.h"
14
22 const char* purpose,
23 struct nobug_flag* flag,
24 const struct nobug_context ctx)
25{
26 if (self)
27 {
28 NOBUG_RESOURCE_HANDLE_INIT (self->rh);
29 NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "mutex", purpose, self, self->rh, ctx)
30 {
31 pthread_mutex_init (&self->mutex, NULL);
32 }
33 }
34 return self;
35}
36
37
40 struct nobug_flag* flag,
41 const struct nobug_context ctx)
42{
43 if (self)
44 {
45 NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx)
46 {
47 if (pthread_mutex_destroy (&self->mutex))
48 LUMIERA_DIE (LOCK_DESTROY);
49 }
50 }
51 return self;
52}
53
54
55
56/*
57// Local Variables:
58// mode: C
59// c-file-style: "gnu"
60// indent-tabs-mode: nil
61// End:
62*/
#define LUMIERA_DIE(err)
Abort unconditionally with a 'Fatal Error!' message.
Definition error.h:54
return NULL
Definition llist.h:586
LumieraMutex lumiera_mutex_destroy(LumieraMutex self, struct nobug_flag *flag, const struct nobug_context ctx)
Destroy a mutex variable.
Definition mutex.c:39
LumieraMutex lumiera_mutex_init(LumieraMutex self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx)
Initialise a mutex variable This initialises a 'fast' default mutex which must not be locked recursiv...
Definition mutex.c:21
Mutual exclusion locking, header.
lumiera_mutex * LumieraMutex
Definition mutex.h:91