summaryrefslogtreecommitdiff
path: root/bufferevent-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-04-13 03:17:19 +0000
committerNick Mathewson <nickm@torproject.org>2009-04-13 03:17:19 +0000
commit915193e7df010fb3f280208b1e7af8c74b462686 (patch)
tree9268936d9b63db940095418524961996df233067 /bufferevent-internal.h
parent1becc4c4e656213d0f71938029a08a2da04dc97f (diff)
downloadlibevent-915193e7df010fb3f280208b1e7af8c74b462686.tar.gz
Locking support for bufferevents.
svn:r1170
Diffstat (limited to 'bufferevent-internal.h')
-rw-r--r--bufferevent-internal.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/bufferevent-internal.h b/bufferevent-internal.h
index f369659f..b1026f68 100644
--- a/bufferevent-internal.h
+++ b/bufferevent-internal.h
@@ -33,6 +33,8 @@ extern "C" {
#include "event-config.h"
#include "evutil.h"
#include "defer-internal.h"
+#include "evthread-internal.h"
+#include "event2/thread.h"
struct bufferevent_private {
struct bufferevent bev;
@@ -42,6 +44,7 @@ struct bufferevent_private {
/** If set, read is suspended until evbuffer some. */
unsigned read_suspended : 1;
+ unsigned own_lock : 1;
enum bufferevent_options options;
@@ -106,6 +109,22 @@ void bufferevent_wm_suspend_read(struct bufferevent *bufev);
* read buffer is too full. */
void bufferevent_wm_unsuspend_read(struct bufferevent *bufev);
+int bufferevent_enable_locking(struct bufferevent *bufev, void *lock);
+
+#define BEV_UPCAST(b) EVUTIL_UPCAST((b), struct bufferevent_private, bev)
+
+#define BEV_LOCK(b) do { \
+ struct bufferevent_private *locking = BEV_UPCAST(b); \
+ if (locking->lock) \
+ EVLOCK_LOCK(locking->lock, EVTHREAD_WRITE); \
+ } while(0)
+
+#define BEV_UNLOCK(b) do { \
+ struct bufferevent_private *locking = BEV_UPCAST(b); \
+ if (locking->lock) \
+ EVLOCK_UNLOCK(locking->lock, EVTHREAD_WRITE); \
+ } while(0)
+
#ifdef __cplusplus
}
#endif