[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] libevent custom thread library: Recursive mutexes and wait conditions
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] libevent custom thread library: Recursive mutexes and wait conditions
- From: Julian Bui <julianbui@xxxxxxxxx>
- Date: Mon, 25 Jun 2012 14:21:55 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 25 Jun 2012 17:22:10 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=QRbK9JQ5lNwRax54bOyR4IxTisPHyic9QZ0gaQZPSb0=; b=Vv2Kh1vx/skIwuZg+qb5GsnM2PsrIbzJVjJFm5hWzFXLBVxs6km+008S/JqMYi3Gfz C/Ey9do/zFMg6Dv74t/vn+iXj+spYoZ7a2dk17W3LoOURSESrT/arr6P8QFK+DHTEtr+ QnzMg3340Ruvz6/5KLv7cb/TIipv5qCcdWM1xYIw0xeH1z5Hc5cu/4kAPCUhL/Fgtp+p DqAGwjUDHl5FgeE3RacLP+HSoCeXcQHSuoGi7DhE+WmWk5hYYoE1DoMk3pn3OVxGDSXB UzxlQNuKl8R1mHBYUPZhnjjEhVaoSOW2w5sj/Zgi3GdchfzbqHvxpsEdVduc7E/hHki1 lbkw==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hello libevent,
I am writing to see if I could get clarification on wait conditions and their use with recursive locks.
My first issue is understanding how a custom evthread_lock is supposed to be implemented. evthread_lock_callbacks::supported_locktypes() documentations says "Note that RECURSIVE locks are currently mandatory, and READWRITE locks are not currently used." So I debugged the alloc method of my custom lock and noticed that only a locktype of 0 was being used which I assume is non-recursive. At first, this description made it sound like only recursive locks are requested by the library, but that's not the case. In what cases will the libevent library try to allocate a recursive lock?
As a side note, I would suggest that there be like a NONRECURSIVE flag, so that 0 has a clear definition.
Secondly, I'm not sure what the behavior of evthread_condition is since using recursive locks and wait conditions has always been tricky (see
http://en.wikipedia.org/wiki/Reentrant_mutex paragraph starting with "
A big form of criticism on recursive mutexes is that when used in combination with condition variables"). And the custom thread/locking library that I wish to use doesn't even support wait conditions with recursive mutexes. I use QtWaitCondition and it doesn't even really even support waiting on a recursive mutex ("
If mutex is a recursive mutex, this function returns immediately.", http://doc.qt.nokia.com/4.7-snapshot/qwaitcondition.html#wait). I'm not sure how how I should be implementing this and what it means for libevent. If libevent tries to wait on a recursive mutex, should it actually wait or should it return immediately? The expected behavior should probably be documented. This is problematic since the library I use doesn't support this. Would libevent even run into this situation?
Clearly I am confused here and would benefit from some clarification.
Any help would be greatly appreciated.
Thanks,
-Julian