Triton Repository branch, master, updated. 6c92329e6d3440d7e78f76a5c611cff1d86e4be9
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Triton Repository". The branch, master has been updated via 6c92329e6d3440d7e78f76a5c611cff1d86e4be9 (commit) via 218340118657b2c8d477a28198405a712d7e51b9 (commit) from 074f9e76d35a042e476ece68bcb0487b6eb1bad0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6c92329e6d3440d7e78f76a5c611cff1d86e4be9 Author: Phil Carns <[email protected]> Date: Fri Feb 25 14:12:05 2011 -0500 turn off warnings for libev object build commit 218340118657b2c8d477a28198405a712d7e51b9 Author: Phil Carns <[email protected]> Date: Fri Feb 25 14:09:47 2011 -0500 new libev based timer resource ----------------------------------------------------------------------- Summary of changes: code/src/aesop/resource.c | 9 +++++ code/src/aesop/resource.h | 6 +++ code/src/common/libev/module.mk.in | 5 ++- code/src/common/resources/timer/timer.c | 58 ++++++++++++++++++++++++++++-- 4 files changed, 73 insertions(+), 5 deletions(-) Diff of changes: diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c index 2b2c2d2..85a17b2 100644 --- a/code/src/aesop/resource.c +++ b/code/src/aesop/resource.c @@ -863,6 +863,15 @@ triton_ret_t ae_error_wrap_stack(struct ae_ctl *ctl, triton_ret_t parent) return ret; } +#ifdef __AESOP_LIBEV +struct ev_loop * ae_resource_get_eloop(ae_context_t context) +{ + if(!context) + return(eloop); + else + return(context->eloop); +} +#endif /* diff --git a/code/src/aesop/resource.h b/code/src/aesop/resource.h index 39f3ebf..49a3c73 100644 --- a/code/src/aesop/resource.h +++ b/code/src/aesop/resource.h @@ -60,6 +60,12 @@ struct ae_resource triton_ret_t ae_resource_register(struct ae_resource *resource, int *newid); void ae_resource_unregister(int resource_id); void ae_resource_request_poll(ae_context_t context, int resource_id); +#ifdef __AESOP_LIBEV +/* this function is used by resources that want access to the event loop + * used by aesop for this context + */ +struct ev_loop * ae_resource_get_eloop(ae_context_t context); +#endif /* Contexts are created to allow separation of polling for different logical * groups of operations. Don't use this function. Instead, use the associated diff --git a/code/src/common/libev/module.mk.in b/code/src/common/libev/module.mk.in index bd24ccf..0fa8213 100644 --- a/code/src/common/libev/module.mk.in +++ b/code/src/common/libev/module.mk.in @@ -8,4 +8,7 @@ LIBSRC += $(DIR)/ev.c \ # Tell libev to use our config.h instead of its own. # This is in the top level makefile now so that it catches the dependency # generation step as well. -# MODCFLAGS_$(DIR) = -DEV_CONFIG_H=\"triton-config.h\" +# MODCFLAGS_$(DIR) = -DEV_CONFIG_H=\"triton-config.h\" -w + +# turn off warnings for libev compile +MODCFLAGS_$(DIR) = -w diff --git a/code/src/common/resources/timer/timer.c b/code/src/common/resources/timer/timer.c index 18fb1e2..1aa3dee 100644 --- a/code/src/common/resources/timer/timer.c +++ b/code/src/common/resources/timer/timer.c @@ -11,23 +11,30 @@ #include "src/aesop/opcache.h" #include "src/common/resources/timer/timer.h" #include "src/common/triton-init.h" +#ifdef __AESOP_LIBEV +#include "src/common/libev/ev.h" +#endif /* NOTES: * * This resource uses the POSIX timer interface to implement an aesop timer * resource. The aesop callbacks are driven directly from the timer * notfication function. - * - * TODO: optional support for libev */ #define TIMER_DEFAULT_SIZE 1024 static ae_opcache_t timer_opcache; static int triton_timer_resource_id; +#ifdef __AESOP_LIBEV +static ev_timer timer_watcher; +static struct ev_loop* timer_loop = NULL; +static void timer_cb(EV_P_ ev_timer *w, int revents); +#else static timer_t timer_id; static struct sigevent evp; static void timer_notify(union sigval sv); +#endif struct timer_op { @@ -93,12 +100,20 @@ ae_define_post(triton_ret_t, triton_timer, int millisecs) if(holder == op) { /* new head of queue; arm a new timer or modify the existing one */ +#ifdef __AESOP_LIBEV + if(timer_loop) + ev_timer_stop(timer_loop, &timer_watcher); + ev_timer_set(&timer_watcher, (((ev_tstamp)millisecs)/1000.0), 0); + timer_loop = ae_resource_get_eloop(op->ctx); + ev_timer_start(timer_loop, &timer_watcher); +#else memset(&tspec, 0, sizeof(tspec)); tspec.it_value.tv_sec = (int)(millisecs/1000); tspec.it_value.tv_nsec = (millisecs % 1000) * 1e6; ret = timer_settime(timer_id, 0, &tspec, NULL); /* TODO: error handling (cancel all remaining timers?) */ assert(ret == 0); +#endif } *__ae_op_id = top->op_id; @@ -167,15 +182,24 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i * strictly necessary and reset itself. */ - /* move to a special queue of cancelled timers */ assert(ae_ops_exists(&timer_oplist, &op->link)); ae_ops_del(op); +#if 0 + /* TODO: note: ideally we would like to just go ahead and trigger the + * callback directly here instead of queueing and requesting a poll, but + * right now that causes a race condition of some sort in aesop. + */ + triton_mutex_unlock(&timer_mutex); + ae_opcache_complete_op(timer_opcache, op, triton_ret_t, TRITON_ERR_CANCELED); +#else + /* move to a special queue of cancelled timers */ ctx = op->ctx; ae_ops_enqueue(op, &cancel_oplist); /* request a poll for aesop to harvest the cancelled timer */ ae_resource_request_poll(ctx, triton_timer_resource_id); triton_mutex_unlock(&timer_mutex); +#endif return TRITON_SUCCESS; } @@ -199,6 +223,9 @@ triton_ret_t triton_timer_init(void) triton_ret_t tret; int ret; +#ifdef __AESOP_LIBEV + ev_init(&timer_watcher, timer_cb); +#else memset(&evp, 0, sizeof(evp)); evp.sigev_notify = SIGEV_THREAD; evp.sigev_value.sival_ptr = NULL; @@ -210,6 +237,7 @@ triton_ret_t triton_timer_init(void) triton_err(triton_log_default, "Error: failed to create timer."); return(TRITON_ERR_NOMEM); } +#endif ae_ops_init(&timer_oplist); ae_ops_init(&cancel_oplist); @@ -227,12 +255,21 @@ void triton_timer_finalize(void) { ae_resource_unregister(triton_timer_resource_id); +#ifdef __AESOP_LIBEV + if(timer_loop) + ev_timer_stop(timer_loop, &timer_watcher); +#else timer_delete(timer_id); +#endif ae_opcache_destroy(timer_opcache); } +#ifdef __AESOP_LIBEV +static void timer_cb(EV_P_ ev_timer *w, int revents) +#else static void timer_notify(union sigval sv) +#endif { struct ae_op *gop; struct timer_op *top; @@ -240,8 +277,12 @@ static void timer_notify(union sigval sv) struct timeval diff; int did_something = 0; ae_context_t ctx; - struct itimerspec tspec; int ret; +#ifdef __AESOP_LIBEV + ev_tstamp tstamp; +#else + struct itimerspec tspec; +#endif triton_mutex_lock(&timer_mutex); @@ -286,12 +327,21 @@ static void timer_notify(union sigval sv) diff.tv_usec = 1; } +#ifdef __AESOP_LIBEV + tstamp = (ev_tstamp)diff.tv_sec + (ev_tstamp)diff.tv_usec / 1000000.0; + if(timer_loop) + ev_timer_stop(timer_loop, &timer_watcher); + ev_timer_set(&timer_watcher, tstamp, 0); + timer_loop = ae_resource_get_eloop(gop->ctx); + ev_timer_start(timer_loop, &timer_watcher); +#else memset(&tspec, 0, sizeof(tspec)); tspec.it_value.tv_sec = diff.tv_sec; tspec.it_value.tv_nsec = diff.tv_usec * 1e3; ret = timer_settime(timer_id, 0, &tspec, NULL); /* TODO: error handling (cancel all remaining timers?) */ assert(ret == 0); +#endif } triton_mutex_unlock(&timer_mutex); hooks/post-receive -- Triton Repository
participants (1)
-
noreply@mcs.anl.gov