Commit d0341485 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add the scaffolding for destroying waiters, now I just need to make it

also work.
parent 4776a39f
......@@ -112,12 +112,27 @@ Wait_New(waiter_handle_f *func, volatile double *tmo)
Lck_Lock(&wait_mtx);
VTAILQ_INSERT_TAIL(&waiters, w, list);
nwaiters++;
/* We assume all waiters either use pipes or don't use pipes */
if (w->pipes[1] >= 0 && nwaiters == 1)
AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL));
Lck_Unlock(&wait_mtx);
return (w);
}
void
Wait_Destroy(struct waiter **wp)
{
struct waiter *w;
AN(wp);
w = *wp;
*wp = NULL;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
AN(w->impl->fini);
w->impl->fini(w);
}
void
Wait_UsePipe(struct waiter *w)
{
......
......@@ -58,6 +58,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now);
/* cache_waiter.c */
int Wait_Enter(const struct waiter *, struct waited *);
struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout);
void Wait_Destroy(struct waiter **);
const char *Wait_GetName(void);
void Wait_Init(void);
......
......@@ -50,6 +50,7 @@ struct waiter {
};
typedef void waiter_init_f(struct waiter *);
typedef void waiter_fini_f(struct waiter *);
typedef int waiter_pass_f(void *priv, struct waited *);
typedef void waiter_inject_f(const struct waiter *, struct waited *);
typedef void waiter_evict_f(const struct waiter *, struct waited *);
......@@ -57,6 +58,7 @@ typedef void waiter_evict_f(const struct waiter *, struct waited *);
struct waiter_impl {
const char *name;
waiter_init_f *init;
waiter_fini_f *fini;
waiter_pass_f *pass;
waiter_inject_f *inject;
waiter_evict_f *evict;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment