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.
Unlock the read lock and then lock as a write lock.
_______________________________________________On Aug 17, 2011 8:20 PM, "Seven Du" <dujinfang@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 oneswitch_thread_rwlock_upgrade_to_wrlock(lock);writeswitch_thread_rwlock_unlock(lock);Thanks
--
Seven DuAbout: http://about.me/dujinfangBlog: http://www.dujinfang.comSent with Sparrow
Join us at ClueCon 2011, Aug 9-11, Chicago
http://www.cluecon.com 877-7-4ACLUE
FreeSWITCH-dev mailing list
FreeSWITCH-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org