summaryrefslogtreecommitdiff
path: root/include/git2/threads.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-11-16 14:09:44 +0100
committerVicent Marti <tanoku@gmail.com>2011-11-16 14:09:44 +0100
commita15c550db8b0552902e58c9bf2194005fb7fb0e9 (patch)
treeb33084b89561613dc8c9592c18b1dedcc8b06375 /include/git2/threads.h
parentb0b2dd5ecc2d309875e8dcd744fa5ff0a55b8fe5 (diff)
downloadlibgit2-a15c550db8b0552902e58c9bf2194005fb7fb0e9.tar.gz
threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing. When libgit2 is built with GIT_THREADS support, the threading system must be explicitly initialized with `git_threads_init()`.
Diffstat (limited to 'include/git2/threads.h')
-rw-r--r--include/git2/threads.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/git2/threads.h b/include/git2/threads.h
new file mode 100644
index 000000000..85472a441
--- /dev/null
+++ b/include/git2/threads.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009-2011 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_threads_h__
+#define INCLUDE_git_threads_h__
+
+#include "common.h"
+
+/**
+ * @file git2/threads.h
+ * @brief Library level thread functions
+ * @defgroup git_thread Threading functions
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Init the threading system.
+ *
+ * If libgit2 has been built with GIT_THREADS
+ * on, this function must be called once before
+ * any other library functions.
+ *
+ * If libgit2 has been built without GIT_THREADS
+ * support, this function is a no-op.
+ */
+GIT_EXTERN(void) git_threads_init(void);
+
+/**
+ * Shutdown the threading system.
+ *
+ * If libgit2 has been built with GIT_THREADS
+ * on, this function must be called before shutting
+ * down the library.
+ *
+ * If libgit2 has been built without GIT_THREADS
+ * support, this function is a no-op.
+ */
+GIT_EXTERN(void) git_threads_shutdown(void);
+
+/** @} */
+GIT_END_DECL
+#endif
+