summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-15 14:27:53 -0700
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:52:07 +0200
commite976b56dda6ae3d7d81bd114b61750e97cc918d3 (patch)
treeaa06f2e71988f294a5465911009f223a9886eea0 /src/util.h
parent536078688549ac3d50483eecdec5a8169d921927 (diff)
downloadlibgit2-e976b56dda6ae3d7d81bd114b61750e97cc918d3.tar.gz
Add git__compare_and_swap and use it
This removes the lock from the repository object and changes the internals to use the new atomic git__compare_and_swap to update the _odb, _config, _index, and _refdb variables in a threadsafe manner.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h19
1 files changed, 0 insertions, 19 deletions
diff --git a/src/util.h b/src/util.h
index a2233a7e8..82435aee8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -313,23 +313,4 @@ int git__date_parse(git_time_t *out, const char *date);
*/
extern size_t git__unescape(char *str);
-/*
- * Swap a pointer with thread safety, returning old value.
- */
-GIT_INLINE(void *) git__swap(git_mutex *lock, void **ptr_ptr, void *new_ptr)
-{
- void *old_ptr;
-
- if (*ptr_ptr == new_ptr)
- return NULL;
- if (git_mutex_lock(lock) < 0)
- return new_ptr;
-
- old_ptr = *ptr_ptr;
- *ptr_ptr = new_ptr;
-
- git_mutex_unlock(lock);
- return old_ptr;
-}
-
#endif /* INCLUDE_util_h__ */