int git_threads_init(void) { int error = 0; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ if (1 == git_atomic_inc(&git__n_inits)) error = synchronized_threads_init(); /* Exit the lock */ InterlockedExchange(&_mutex, 0); return error; }
int git_libgit2_init(void) { int ret; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ if ((ret = git_atomic_inc(&git__n_inits)) == 1) { if (synchronized_threads_init() < 0) ret = -1; } /* Exit the lock */ InterlockedExchange(&_mutex, 0); return ret; }
int git_libgit2_init(void) { int ret; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ if ((ret = git_atomic_inc(&git__n_inits)) == 1) { #if defined(GIT_MSVC_CRTDBG) git_win32__crtdbg_stacktrace_init(); git_win32__stack_init(); #endif if (synchronized_threads_init() < 0) ret = -1; } /* Exit the lock */ InterlockedExchange(&_mutex, 0); return ret; }