summaryrefslogtreecommitdiff
path: root/src/thread-utils.h
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-04-18 12:33:19 +0200
committerVicent Marti <vicent@github.com>2014-04-18 12:33:19 +0200
commit28fd7206b1359b6564bad3c66382b47a8f2e3eb1 (patch)
treee0d9204bdfea2a948d94b2b14d382a697b00b6db /src/thread-utils.h
parent2bed3553f4595a42d9a6884edc66b991e21f881e (diff)
parent8303827226db114a1157e6173e731f316c217851 (diff)
downloadlibgit2-28fd7206b1359b6564bad3c66382b47a8f2e3eb1.tar.gz
Merge pull request #2108 from libgit2/rb/threadsafe-index-iterator
Make index iterator thread safe
Diffstat (limited to 'src/thread-utils.h')
-rw-r--r--src/thread-utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/thread-utils.h b/src/thread-utils.h
index 914c1357d..50d8610a3 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -47,6 +47,12 @@ typedef git_atomic git_atomic_ssize;
#define git_thread_exit(status) pthread_exit(status)
#define git_thread_join(id, status) pthread_join(id, status)
+#if defined(GIT_WIN32)
+#define git_thread_yield() Sleep(0)
+#else
+#define git_thread_yield() sched_yield()
+#endif
+
/* Pthreads Mutex */
#define git_mutex pthread_mutex_t
#define git_mutex_init(a) pthread_mutex_init(a, NULL)
@@ -176,6 +182,7 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
#define git_thread_kill(thread) (void)0
#define git_thread_exit(status) (void)0
#define git_thread_join(id, status) (void)0
+#define git_thread_yield() (void)0
/* Pthreads Mutex */
#define git_mutex unsigned int