aboutsummaryrefslogtreecommitdiff
path: root/subversion/include/private/svn_atomic.h
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2018-05-08 03:44:38 +0000
committerPeter Wemm <peter@FreeBSD.org>2018-05-08 03:44:38 +0000
commit3faf8d6bffc5d0fb2525ba37bb504c53366caf9d (patch)
tree7e47911263e75034b767fe34b2f8d3d17e91f66d /subversion/include/private/svn_atomic.h
parenta55fb3c0d5eca7d887798125d5b95942b1f01d4b (diff)
Diffstat (limited to 'subversion/include/private/svn_atomic.h')
-rw-r--r--subversion/include/private/svn_atomic.h68
1 files changed, 64 insertions, 4 deletions
diff --git a/subversion/include/private/svn_atomic.h b/subversion/include/private/svn_atomic.h
index 6a6b2dca6be1..f86a39ec68c6 100644
--- a/subversion/include/private/svn_atomic.h
+++ b/subversion/include/private/svn_atomic.h
@@ -76,21 +76,81 @@ extern "C" {
/** @} */
/**
+ * @name Single-threaded atomic initialization
+ * @{
+ */
+
+/**
+ * Callback for svn_atomic__init_once().
+ * @return an #svn_error_t if the initialization fails.
+ * @since New in 1.10
+ */
+typedef svn_error_t *(*svn_atomic__err_init_func_t)(void *baton,
+ apr_pool_t *pool);
+
+/**
+ * Callback for svn_atomic__init_no_error().
+ * @return a string containing an error message if the initialization fails.
+ * @since New in 1.10
+ */
+typedef const char *(*svn_atomic__str_init_func_t)(void *baton);
+
+/**
* Call an initialization function in a thread-safe manner.
*
* @a global_status must be a pointer to a global, zero-initialized
- * #svn_atomic_t. @a init_func is a pointer to the function that performs
- * the actual initialization. @a baton and and @a pool are passed on to the
- * init_func for its use.
+ * #svn_atomic_t. @a err_init_func is a pointer to the function that
+ * performs the actual initialization. @a baton and and @a pool are
+ * passed on to @a err_init_func for its use.
+ *
+ * @return the error returned by @a err_init_func.
*
* @since New in 1.5.
*/
svn_error_t *
svn_atomic__init_once(volatile svn_atomic_t *global_status,
- svn_error_t *(*init_func)(void*,apr_pool_t*),
+ svn_atomic__err_init_func_t err_init_func,
void *baton,
apr_pool_t* pool);
+/**
+ * Call an initialization function in a thread-safe manner.
+ *
+ * Unlike svn_atomic__init_once(), this function does not need a pool
+ * and does not create an #svn_error_t, and neither should the
+ * @a str_init_func implementation.
+ *
+ * @a global_status must be a pointer to a global, zero-initialized
+ * #svn_atomic_t. @a str_init_func is a pointer to the function that
+ * performs the actual initialization. @a baton is passed on to
+ * @a str_init_func for its use.
+ *
+ * @return the error string returned by @a str_init_func.
+ *
+ * @since New in 1.10.
+ */
+const char *
+svn_atomic__init_once_no_error(volatile svn_atomic_t *global_status,
+ svn_atomic__str_init_func_t str_init_func,
+ void *baton);
+
+
+/**
+ * Query and increment the global counter and set @a value to the new
+ * counter value.
+ *
+ * This function is thread-safe and you should call it whenever you need
+ * a number that is unique within the current process. The values are > 0.
+ *
+ * @return the error object in case of a synchronization failure.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_atomic__unique_counter(apr_uint64_t* value);
+
+/** @} */
+
#ifdef __cplusplus
}
#endif /* __cplusplus */