[Freeswitch-dev] upgrade a rdlock to wrlock

Christopher Rienzo cmrienzo at gmail.com
Thu Aug 18 16:19:13 MSD 2011


I forgot to mention that you'd have to repeat the find operation once you
get the write lock since there is a small window between the unlock and lock
where another thread may have created the item.


On Thu, Aug 18, 2011 at 6:42 AM, Christopher Rienzo <cmrienzo at gmail.com>wrote:

> Unlock the read lock and then lock as a write lock.
>
> On Aug 17, 2011 8:20 PM, "Seven Du" <dujinfang at gmail.com> wrote:
>
>  Hi,
>
>
> Just wondering how to upgrade a read lock to a write lock, say I do a
> find_or_create_item_in_queue()
>
>  switch_thread_rwlock_rdlock(lock);
>
> find an item from queue, if not found, create one
>
> switch_thread_rwlock_upgrade_to_wrlock(lock);
>
>  write
>  switch_thread_rwlock_unlock(lock);
>
> Thanks
> --
> Seven Du
> About: http://about.me/dujinfang
> Blog: http://www.dujinfang.com
> Proj:  http://www.freeswitch.org.cn
> Sent with Sparrow <http://www.sparrowmailapp.com>
>
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicago
> http://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20110818/632fb184/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list