X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fovs-thread.c;h=e1e728912bbb2ba7101ee26c8ac2d21d3caeab57;hb=1514b275558304c63bc3838c2da5c4be0c1cbef0;hp=23224323c76d7ad4b0f3b2957a20f56e2db9a679;hpb=31a3fc6e3e9ce68d8bfebf65150d9455b9334dda;p=sliver-openvswitch.git diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index 23224323c..e1e728912 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -88,4 +88,22 @@ xpthread_create(pthread_t *threadp, pthread_attr_t *attr, ovs_abort(error, "pthread_create failed"); } } + +bool +ovsthread_once_start__(struct ovsthread_once *once) +{ + xpthread_mutex_lock(&once->mutex); + if (!ovsthread_once_is_done__(once)) { + return false; + } + xpthread_mutex_unlock(&once->mutex); + return true; +} + +void OVS_RELEASES(once) +ovsthread_once_done(struct ovsthread_once *once) +{ + atomic_store(&once->done, true); + xpthread_mutex_unlock(&once->mutex); +} #endif