00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #include "engines_int.h"
00028
00029 RCSTAG("@(#)$Id: engine_activate.c,v 1.4 2005/12/18 00:15:10 klmitch Exp $");
00030
00044 #define eng_link(ctx, engine, comp) \
00045 do { \
00046 ev_ctx_t *_ctx = (ctx); \
00047 ev_engine_t *_eng = (engine); \
00048 if (!_ctx->ec_ ## comp.el_last) { \
00049 \
00050 _ctx->ec_ ## comp.el_first = _ctx->ec_ ## comp.el_last = _eng; \
00051
00052
00053 \
00054 ((_ev_englink_t *)&_eng->eng_ ## comp)->el_next = 0; \
00055 ((_ev_englink_t *)&_eng->eng_ ## comp)->el_prev = 0; \
00056 } else { \
00057 ev_engine_t *_last = _ctx->ec_ ## comp.el_last; \
00058 ((_ev_englink_t *)&_last->eng_ ## comp)->el_next = _eng; \
00059 ((_ev_englink_t *)&_eng->eng_ ## comp)->el_prev = _last; \
00060 ((_ev_englink_t *)&_eng->eng_ ## comp)->el_next = 0; \
00061 _ctx->ec_ ## comp.el_last = _eng; \
00062 } \
00063 } while (0)
00064
00065 ev_err_t
00066 engine_activate(ev_ctx_t *ctx, ev_engine_t *engine, ev_flags_t comps)
00067 {
00068 ev_init();
00069
00070
00071 comps &= EV_ENGINE_COMPMASK;
00072
00073 if (!ec_verify(ctx) || !eng_verify(engine) ||
00074 !(engine->eng_runfl & EV_ENGINE_REGISTERED) ||
00075 (engine->eng_runfl & EV_ENGINE_RUNNING) || !comps)
00076 ev_return(EINVAL);
00077
00078 if (comps & EV_ENGINE_SOCKET)
00079 eng_link(ctx, engine, socket);
00080 if (comps & EV_ENGINE_SIGNAL)
00081 eng_link(ctx, engine, signal);
00082 if (comps & EV_ENGINE_TIMER)
00083 eng_link(ctx, engine, timer);
00084
00085
00086 eng_runfl_set(engine, comps | EV_ENGINE_RUNNING);
00087
00088 ev_return(0);
00089 }