mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Merge remote-tracking branch 'origin/patches-2.0'
This commit is contained in:
commit
f5b937e65f
4
event.c
4
event.c
@ -671,7 +671,8 @@ event_base_new_with_config(const struct event_config *cfg)
|
|||||||
/* prepare for threading */
|
/* prepare for threading */
|
||||||
|
|
||||||
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
|
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
|
||||||
if (!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK)) {
|
if (EVTHREAD_LOCKING_ENABLED() &&
|
||||||
|
(!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK))) {
|
||||||
int r;
|
int r;
|
||||||
EVTHREAD_ALLOC_LOCK(base->th_base_lock,
|
EVTHREAD_ALLOC_LOCK(base->th_base_lock,
|
||||||
EVTHREAD_LOCKTYPE_RECURSIVE);
|
EVTHREAD_LOCKTYPE_RECURSIVE);
|
||||||
@ -679,6 +680,7 @@ event_base_new_with_config(const struct event_config *cfg)
|
|||||||
EVTHREAD_ALLOC_COND(base->current_event_cond);
|
EVTHREAD_ALLOC_COND(base->current_event_cond);
|
||||||
r = evthread_make_base_notifiable(base);
|
r = evthread_make_base_notifiable(base);
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
|
event_warnx("%s: Unable to make base notifiable.", __func__);
|
||||||
event_base_free(base);
|
event_base_free(base);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,10 @@ EVLOCK_TRY_LOCK(void *lock)
|
|||||||
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \
|
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \
|
||||||
( (cond) ? _evthread_cond_fns.wait_condition((cond), (lock), (tv)) : 0 )
|
( (cond) ? _evthread_cond_fns.wait_condition((cond), (lock), (tv)) : 0 )
|
||||||
|
|
||||||
|
/** True iff locking functions have been configured. */
|
||||||
|
#define EVTHREAD_LOCKING_ENABLED() \
|
||||||
|
(_evthread_lock_fns.lock != NULL)
|
||||||
|
|
||||||
#elif ! defined(_EVENT_DISABLE_THREAD_SUPPORT)
|
#elif ! defined(_EVENT_DISABLE_THREAD_SUPPORT)
|
||||||
|
|
||||||
unsigned long _evthreadimpl_get_id(void);
|
unsigned long _evthreadimpl_get_id(void);
|
||||||
@ -187,6 +191,7 @@ void *_evthreadimpl_cond_alloc(unsigned condtype);
|
|||||||
void _evthreadimpl_cond_free(void *cond);
|
void _evthreadimpl_cond_free(void *cond);
|
||||||
int _evthreadimpl_cond_signal(void *cond, int broadcast);
|
int _evthreadimpl_cond_signal(void *cond, int broadcast);
|
||||||
int _evthreadimpl_cond_wait(void *cond, void *lock, const struct timeval *tv);
|
int _evthreadimpl_cond_wait(void *cond, void *lock, const struct timeval *tv);
|
||||||
|
int _evthreadimpl_locking_enabled(void);
|
||||||
|
|
||||||
#define EVTHREAD_GET_ID() _evthreadimpl_get_id()
|
#define EVTHREAD_GET_ID() _evthreadimpl_get_id()
|
||||||
#define EVBASE_IN_THREAD(base) \
|
#define EVBASE_IN_THREAD(base) \
|
||||||
@ -283,6 +288,9 @@ EVLOCK_TRY_LOCK(void *lock)
|
|||||||
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \
|
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, tv) \
|
||||||
( (cond) ? _evthreadimpl_cond_wait((cond), (lock), (tv)) : 0 )
|
( (cond) ? _evthreadimpl_cond_wait((cond), (lock), (tv)) : 0 )
|
||||||
|
|
||||||
|
#define EVTHREAD_LOCKING_ENABLED() \
|
||||||
|
(_evthreadimpl_locking_enabled())
|
||||||
|
|
||||||
#else /* _EVENT_DISABLE_THREAD_SUPPORT */
|
#else /* _EVENT_DISABLE_THREAD_SUPPORT */
|
||||||
|
|
||||||
#define EVTHREAD_GET_ID() 1
|
#define EVTHREAD_GET_ID() 1
|
||||||
@ -309,6 +317,8 @@ EVLOCK_TRY_LOCK(void *lock)
|
|||||||
#define EVTHREAD_COND_WAIT(cond, lock) _EVUTIL_NIL_STMT
|
#define EVTHREAD_COND_WAIT(cond, lock) _EVUTIL_NIL_STMT
|
||||||
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, howlong) _EVUTIL_NIL_STMT
|
#define EVTHREAD_COND_WAIT_TIMED(cond, lock, howlong) _EVUTIL_NIL_STMT
|
||||||
|
|
||||||
|
#define EVTHREAD_LOCKING_ENABLED() 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This code is shared between both lock impls */
|
/* This code is shared between both lock impls */
|
||||||
|
@ -437,6 +437,12 @@ _evthreadimpl_is_lock_debugging_enabled(void)
|
|||||||
{
|
{
|
||||||
return _evthread_lock_debugging_enabled;
|
return _evthread_lock_debugging_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_evthreadimpl_locking_enabled(void)
|
||||||
|
{
|
||||||
|
return _evthread_lock_fns.lock != NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user