/* * slapi_eq_once: cause an event to happen exactly once. * * Arguments: * fn: the function to call * arg: an argument to pass to the called function * when: the time that the function should be called * Returns: * slapi_eq_context - a handle to an opaque object which * the caller can use to refer to this particular scheduled * event. */ Slapi_Eq_Context slapi_eq_once(slapi_eq_fn_t fn, void *arg, time_t when) { slapi_eq_context *tmp; PR_ASSERT(eq_initialized); if (!eq_stopped) { Slapi_Eq_Context id; tmp = eq_new(fn, arg, when, 0UL); id = tmp->ec_id; eq_enqueue(tmp); /* After this point, <tmp> may have */ /* been freed, depending on the thread */ /* scheduling. Too bad */ slapi_log_error(SLAPI_LOG_HOUSE, NULL, "added one-time event id %p at time %ld\n", id, when); return(id); } return NULL; /* JCM - Not sure if this should be 0 or something else. */ }
void eq_worker_eaten_myself(eq_worker_t eqw) { Lisp_Object emev = Qnil; struct gcpro gcpro1; GCPRO1(emev); emev = make_empty_event(); XEVENT(emev)->event_type = eaten_myself_event; XEVENT(emev)->event.eaten_myself.worker = eqw; eq_enqueue(asyneq, emev); UNGCPRO; return; }
void eq_worker_work_finished(Lisp_Object job) { Lisp_Object wfev = Qnil; struct gcpro gcpro1; GCPRO1(wfev); wfev = make_empty_event(); XEVENT(wfev)->event_type = work_finished_event; XEVENT(wfev)->event.work_finished.job = job; eq_enqueue(asyneq, wfev); UNGCPRO; return; }
/* * slapi_eq_repeat: cause an event to happen repeatedly. * * Arguments: * fn: the function to call * arg: an argument to pass to the called function * when: the time that the function should first be called * interval: the amount of time (in milliseconds) between * successive calls to the function * Returns: * slapi_eq_context - a handle to an opaque object which * the caller can use to refer to this particular scheduled */ Slapi_Eq_Context slapi_eq_repeat(slapi_eq_fn_t fn, void *arg, time_t when, unsigned long interval) { slapi_eq_context *tmp ; PR_ASSERT(eq_initialized); if (!eq_stopped) { tmp = eq_new(fn, arg, when, interval); eq_enqueue(tmp); slapi_log_error(SLAPI_LOG_HOUSE, NULL, "added repeating event id %p at time %ld, interval %lu\n", tmp->ec_id, when, interval); return(tmp->ec_id); } return NULL; /* JCM - Not sure if this should be 0 or something else. */ }
/* * Call all events which are due to run. * Note that if we've missed a schedule * opportunity, we don't try to catch up * by calling the function repeatedly. */ static void eq_call_all() { slapi_eq_context *p; while ((p = eq_dequeue(current_time())) != NULL) { /* Call the scheduled function */ p->ec_fn(p->ec_when, p->ec_arg); slapi_log_error(SLAPI_LOG_HOUSE, NULL, "Event id %p called at %ld (scheduled for %ld)\n", p->ec_id, current_time(), p->ec_when); if (0UL != p->ec_interval) { /* This is a repeating event. Requeue it. */ do { p->ec_when += p->ec_interval; } while (p->ec_when < current_time()); eq_enqueue(p); } else { slapi_ch_free((void **)&p); } } }
void gcd_start ( rtinfo_t* rti, time_t length ) { rti->player.gcd = TIME_OFFSET( length ); eq_enqueue( rti, rti->player.gcd, routnum_gcd_expire, 0 ); }