mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 04:50:37 -04:00
evthread: add evthread_get_{lock,condition}_callbacks() helpers
This commit is contained in:
parent
92a359ee3a
commit
c0b34f6fd5
@ -376,6 +376,11 @@ int evsig_global_setup_locks_(const int enable_locks);
|
||||
int evutil_global_setup_locks_(const int enable_locks);
|
||||
int evutil_secure_rng_global_setup_locks_(const int enable_locks);
|
||||
|
||||
/** Return current evthread_lock_callbacks */
|
||||
struct evthread_lock_callbacks *evthread_get_lock_callbacks();
|
||||
/** Return current evthread_condition_callbacks */
|
||||
struct evthread_condition_callbacks *evthread_get_condition_callbacks();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
19
evthread.c
19
evthread.c
@ -69,12 +69,21 @@ evthread_set_id_callback(unsigned long (*id_fn)(void))
|
||||
evthread_id_fn_ = id_fn;
|
||||
}
|
||||
|
||||
struct evthread_lock_callbacks *evthread_get_lock_callbacks()
|
||||
{
|
||||
return evthread_lock_debugging_enabled_
|
||||
? &original_lock_fns_ : &evthread_lock_fns_;
|
||||
}
|
||||
struct evthread_condition_callbacks *evthread_get_condition_callbacks()
|
||||
{
|
||||
return evthread_lock_debugging_enabled_
|
||||
? &original_cond_fns_ : &evthread_cond_fns_;
|
||||
}
|
||||
|
||||
int
|
||||
evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
|
||||
{
|
||||
struct evthread_lock_callbacks *target =
|
||||
evthread_lock_debugging_enabled_
|
||||
? &original_lock_fns_ : &evthread_lock_fns_;
|
||||
struct evthread_lock_callbacks *target = evthread_get_lock_callbacks();
|
||||
|
||||
if (!cbs) {
|
||||
if (target->alloc)
|
||||
@ -109,9 +118,7 @@ evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
|
||||
int
|
||||
evthread_set_condition_callbacks(const struct evthread_condition_callbacks *cbs)
|
||||
{
|
||||
struct evthread_condition_callbacks *target =
|
||||
evthread_lock_debugging_enabled_
|
||||
? &original_cond_fns_ : &evthread_cond_fns_;
|
||||
struct evthread_condition_callbacks *target = evthread_get_condition_callbacks();
|
||||
|
||||
if (!cbs) {
|
||||
if (target->alloc_condition)
|
||||
|
Loading…
x
Reference in New Issue
Block a user