[vlc-devel] [PATCH 1/6] os2: implement vlc_once()

Kamil Rytarowski n54 at gmx.com
Tue Mar 27 17:36:32 CEST 2018


On 26.03.2018 13:16, KO Myung-Hun wrote:
> 
> 
> RĂ©mi Denis-Courmont wrote:
>> POSIX model is simpler here, but it wouldn't work with C11 either.
> 
> How about this ?
> 

There is no need for a mutex.

An algorithm like follows should work better:

static atomic_uint32_t bg_thread = {};
if (atomic_load(&bg_thread, memory_order_relaxed) == 0 &&
    atomic_exchange(&bg_thread, 1, memory_order_relaxed) == 0) {
  cb();
}

There is need to adapt it for GCC / VLC API.

> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 850 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180327/4aa10dfa/attachment.sig>


More information about the vlc-devel mailing list