summaryrefslogtreecommitdiff
path: root/src/cairo-mutex.c
diff options
context:
space:
mode:
authorMathias Hasselmann <mathias.hasselmann@gmx.de>2007-03-20 10:11:14 +0100
committerMathias Hasselmann <mathias.hasselmann@gmx.de>2007-03-20 10:11:14 +0100
commitbe52178443ffd19fc7848dfc78c477883ccb943b (patch)
treee4c546805945a8def08d82ed8b18c85dadfd71f8 /src/cairo-mutex.c
parentaba2b299db163d8a5b9d0a0214cd8a485fb87162 (diff)
Initialize mutexes at central location.
All mutex declarations have been moved to cairo-mutex-list.h. This should avoid breaking of less frequently tested backends, when mutexes are introduced or when existing mutexes are renamed. Instead of initializing mutexes on library startup, mutexes are lazily initialized within the few entry points of now by calling CAIRO_MUTEX_INITIALIZE(). Currently only the OS/2 backend takes care about releasing global mutexes. Therefore there is no counter part of that macro for finalizing all global mutexes yet - but as cairo-backend-os2.c shows such a function would be quite easy to implement.
Diffstat (limited to 'src/cairo-mutex.c')
-rw-r--r--src/cairo-mutex.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c
new file mode 100644
index 000000000..48ec86b86
--- /dev/null
+++ b/src/cairo-mutex.c
@@ -0,0 +1,51 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2007 Mathias Hasselmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * Contributor(s):
+ * Mathias Hasselmann <mathias.hasselmann@gmx.de>
+ */
+
+#define CAIRO_MUTEX_DECLARE(name) cairo_mutex_t name = CAIRO_MUTEX_NIL_INITIALIZER;
+#include "cairo-mutex-private.h"
+
+#if !HAVE_PTHREAD_H
+
+cairo_bool_t _cairo_mutex_initialized = FALSE;
+
+void _cairo_mutex_initialize (void)
+{
+ if (_cairo_mutex_initialized)
+ return;
+
+#define CAIRO_MUTEX_DECLARE(mutex) CAIRO_MUTEX_INIT (mutex);
+#include "cairo-mutex-list.h"
+#undef CAIRO_MUTEX_DECLARE
+}
+
+#endif