branch, devel, updated. 0e203da842dddf26397b70639c51b59e7a62c0ef
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 "". The branch, devel has been updated via 0e203da842dddf26397b70639c51b59e7a62c0ef (commit) via 118d63dc1dd336dd3e70d19cc05343945a3f5332 (commit) from bf7f844d3875372700ddff37d7d38d94ba0e56c6 (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 0e203da842dddf26397b70639c51b59e7a62c0ef Author: Phil Carns <[email protected]> Date: Thu Feb 28 15:45:57 2013 -0500 remove aesop context functionality commit 118d63dc1dd336dd3e70d19cc05343945a3f5332 Author: Phil Carns <[email protected]> Date: Thu Feb 28 15:00:00 2013 -0500 remove context registration functions from rsc api ----------------------------------------------------------------------- Summary of changes: ae-blocking-parser.h | 7 - ae-ctl.h | 5 - aesop.h | 57 ++------- doc/aug_external.txt | 16 +-- op.h | 6 +- parser/tests/blocking/btest-impl.c | 30 ++-- resource.c | 248 ++++-------------------------------- resource.h | 11 +- resources/sem/sem.c | 8 +- resources/thread/aethread.c | 6 +- resources/worker/worker.c | 6 +- src/ssm/aessm.ae | 7 +- tests/resource-register.c | 4 +- 13 files changed, 74 insertions(+), 337 deletions(-) Diff of changes: diff --git a/ae-blocking-parser.h b/ae-blocking-parser.h index b032dbe..3e262d0 100644 --- a/ae-blocking-parser.h +++ b/ae-blocking-parser.h @@ -40,7 +40,6 @@ typedef triton_list_t* triton_state_data_list_t; #define AE_MK_BLOCKING_PARAMS_FUN_PTR_DECLS() \ void *__ae_user_ptr; \ ae_hints_t *__ae_hints; \ - ae_context_t __ae_context; \ ae_op_id_t *__ae_op_id; \ int __ae_internal; @@ -186,7 +185,6 @@ static void __bfun##_##__fname##_##__pos_str##_callback(void *__ae_ptr) \ __ae_postret = __bcall(__fname##_##__bcallName##_##__pos_str##_callback, \ __ae_ctl, \ __ae_ctl->gen.hints, \ - __ae_ctl->gen.context, \ &__ae_ctl->gen.current_op_id, \ 1); @@ -318,7 +316,6 @@ __ae_pbranch_##__pbranch_pos_str##_start: __ae_ctl, \ #__fname "_ctl:pbranch_" #__pbranch_pos_str, \ NULL, \ - __ae_ctl_parent->gen.context, \ 1, \ __ae_ctl_parent); \ ae_debug_pbranch("starting pbranch: %s (ctl=%p, parent=%p)\n", \ @@ -450,7 +447,6 @@ __ae_pbranch_##__pbranch_pos_str##_start: \ __ae_ctl, \ #__fname "_ctl:[L]pbranch_" #__pbranch_pos_str, \ NULL, \ - __ae_ctl_parent->gen.context, \ 1, \ __ae_ctl_parent); \ ae_debug_pbranch("starting lone pbranch: %s (ctl=%p, parent=%p)\n", \ @@ -523,14 +519,12 @@ __ae_pbranch_##__pbranch_pos_str##_after: {} #define AE_MK_BFUN_PARAMS_DECLS() \ void *__ae_user_ptr; \ ae_hints_t *__ae_hints; \ - ae_context_t __ae_context; \ ae_op_id_t *__ae_op_id; \ int __ae_internal; #define AE_MK_BFUN_PARAMS_FUN_PTR_DECLS(__ret_type) \ void *__ae_user_ptr; \ ae_hints_t *__ae_hints; \ - ae_context_t __ae_context; \ ae_op_id_t *__ae_op_id; \ int __ae_internal; \ __ret_type *retval; @@ -550,7 +544,6 @@ __ae_pbranch_##__pbranch_pos_str##_after: {} __ae_ctl, \ #__fname, \ __ae_hints, \ - __ae_context, \ __ae_internal, \ __ae_user_ptr); \ AE_MK_START_OF_BLOCKING(__fname); \ diff --git a/ae-ctl.h b/ae-ctl.h index a73c572..abcc72e 100644 --- a/ae-ctl.h +++ b/ae-ctl.h @@ -63,8 +63,6 @@ enum ae_pwait_command "NONE" : ((__cmd == AE_PWAIT_CONTINUE) ? "CONTINUE" : \ ((__cmd == AE_PWAIT_YIELD) ? "YIELD" : "UNKNOWN")) -typedef struct ae_context *ae_context_t; - enum op_state { /** This context is cancelled, all ops should return immediately */ @@ -121,7 +119,6 @@ struct ae_ctl int allposted; int in_pwait; ae_hints_t *hints; - ae_context_t context; OPA_int_t refcount; int op_state; }; @@ -142,7 +139,6 @@ static inline void ae_ctl_init(struct ae_ctl *ctl, void *fctl, const char *name, ae_hints_t *hints, - ae_context_t context, int internal, void *user_ptr) { @@ -159,7 +155,6 @@ static inline void ae_ctl_init(struct ae_ctl *ctl, */ ctl->hints = hints; - ctl->context = context; triton_mutex_init(&ctl->mutex, NULL); triton_list_init(&ctl->children); OPA_store_int (&ctl->refcount, 1); diff --git a/aesop.h b/aesop.h index 6c0964d..bfff55b 100644 --- a/aesop.h +++ b/aesop.h @@ -28,37 +28,21 @@ int aesop_debug_from_env (void); * check with the normal compiler (GCC), we don't get a 'too many arguments to function' error. */ #ifdef AESOP_PARSER -#define ae_post_blocking(__fname, __callback, __user_ptr, __hints, __resource_ctx, __op_id, __fargs...) \ - __fname(__callback, __user_ptr, __hints, __resource_ctx, __op_id, 0, ##__fargs) +#define ae_post_blocking(__fname, __callback, __user_ptr, __hints, __op_id, __fargs...) \ + __fname(__callback, __user_ptr, __hints, __op_id, 0, ##__fargs) #else -#define ae_post_blocking(__fname, __callback, __user_ptr, __hints, __resource_ctx, __op_id, __fargs...) AE_SUCCESS +#define ae_post_blocking(__fname, __callback, __user_ptr, __hints, __op_id, __fargs...) AE_SUCCESS #endif -#define ext_post_blocking(__fname, __callback, __user_ptr, __hints, __resource_ctx, __op_id, __fargs...) \ - __fname(__callback, __user_ptr, __hints, __resource_ctx, __op_id, 0, ##__fargs) +#define ext_post_blocking(__fname, __callback, __user_ptr, __hints, __op_id, __fargs...) \ + __fname(__callback, __user_ptr, __hints, __op_id, 0, ##__fargs) /* Called by c programs to break ae_poll() calls once callbacks are complete */ -void ae_poll_break(ae_context_t context); +void ae_poll_break(void); -/* Contexts are created to allow separation of polling for different logical - * groups of operations. Don't use this function. Instead, use the associated - * ae_context_create macro. +/* Poll for completion of operations up to a timeout value. */ -int _ae_context_create(ae_context_t *context, const char *format, int resource_count, ...) __attribute__((format (printf, 2, 4))) ; - -/* macro to calculate the number of resources passed in as string - * arguments so we don't have to pass in the count explicitly. */ -#define ae_context_create(_context, ...) \ - _ae_context_create(_context, FORMAT_ARGS(__VA_ARGS__) , ##__VA_ARGS__) - -/* Context destruction. Called to cleanup state allocated in ae_context_create. - */ -int ae_context_destroy(ae_context_t context); - -/* Poll for completion of the operations within the given context up to a - * timeout value. - */ -int ae_poll(ae_context_t context, int ms); +int ae_poll(int ms); int ae_cancel_branches(struct ae_ctl *ctl); @@ -115,16 +99,13 @@ static inline void aesop_set_cancel (void) { } aesop_main_set_with_init (0, __main_blocking_function__); /* Similar to above, but this one takes an initialization function - * that gets called before aesop_init, and you can optionally specify - * a comma-separated list of resources to be polled in a separate context. + * that gets called before aesop_init. * * Example: * * __blocking int aesop_main(int argc, char **argv) { ... } * int set_zeroconf_params(void) { ... } * aesop_main_set_with_init(set_zeroconf_params, aesop_main); - * or - * aesop_main_set_with_init(set_zeroconf_params, aesop_main, "bdb", "file"); */ #define aesop_main_set_with_init(__init_before_main__, \ __main_blocking_function__, ...) \ @@ -132,14 +113,12 @@ static int __main_done=0; \ static int __main_ret; \ static void __main_cb(void *user_ptr, int t) \ { \ - ae_context_t ctx = (ae_context_t)user_ptr; \ __main_done = 1; \ __main_ret = t; \ - ae_poll_break(ctx); \ + ae_poll_break(); \ } \ int main(int argc, char **argv) \ { \ - ae_context_t __main_ctx = NULL; \ ae_hints_t __main_hints; \ ae_op_id_t __main_opid; \ int ret; \ @@ -151,19 +130,13 @@ int main(int argc, char **argv) \ } \ ret = aesop_init(); \ aesop_error_assert(ret); \ - if(COUNT_ARGS(__VA_ARGS__) > 0) \ - { \ - ret = ae_context_create(&__main_ctx, ##__VA_ARGS__); \ - aesop_error_assert(ret); \ - } \ ret = ae_hints_init(&__main_hints); \ assert(ret == 0); \ ret = ae_post_blocking( \ __main_blocking_function__, \ __main_cb, \ - __main_ctx, \ + NULL, \ &__main_hints, \ - __main_ctx, \ &__main_opid, \ &__main_ret, \ argc, \ @@ -172,7 +145,7 @@ int main(int argc, char **argv) \ { \ while(!__main_done) \ { \ - ret = ae_poll(__main_ctx, AESOP_MAIN_SET_POLL_TIMEOUT); \ + ret = ae_poll(AESOP_MAIN_SET_POLL_TIMEOUT); \ if(ret == AE_ERR_TIMEDOUT) continue; \ aesop_error_assert(ret); \ } \ @@ -184,17 +157,13 @@ int main(int argc, char **argv) \ ae_lone_pbranches_count ()); \ while(ae_lone_pbranches_count ()) \ { \ - ret = ae_poll(__main_ctx, AESOP_MAIN_SET_POLL_TIMEOUT); \ + ret = ae_poll(AESOP_MAIN_SET_POLL_TIMEOUT); \ if(ret == AE_ERR_TIMEDOUT) continue; \ aesop_error_assert(ret); \ } \ } \ aesop_error_assert(ret); \ ae_hints_destroy(&__main_hints); \ - if(COUNT_ARGS(__VA_ARGS__) > 0) \ - { \ - ae_context_destroy(__main_ctx); \ - } \ aesop_finalize(); \ return __main_ret; \ } diff --git a/doc/aug_external.txt b/doc/aug_external.txt index 98dc3bf..b565a4b 100644 --- a/doc/aug_external.txt +++ b/doc/aug_external.txt @@ -358,10 +358,8 @@ struct ae_resource { const char *resource_name; int (*test)(ae_op_id_t id, int ms_timeout); - int (*poll_context)(ae_context_t context); - int (*cancel)(ae_context_t ctx, ae_op_id_t id); - int (*register_context)(ae_context_t context); - int (*unregister_context)(ae_context_t context); + int (*poll)(void* user_data); + int (*cancel)(ae_op_id_t id); }; ---- @@ -378,14 +376,6 @@ struct ae_resource * The `poll` member will be discussed below. - -[NOTE] -==== -The _context_ concept is deprecated and will be removed in a future version. -The `register_context` and `unregister_context` functions should be set to -`NULL`. The `poll_context` function can safely ignore the `context` parameter. -==== - The new resource should be registered with {aesop} using the `ae_resource_register` function. The internal ID for the resource (used in creating an operation ID) is returned in `*newid`. @@ -420,7 +410,7 @@ just indicate specific times when they would like to be polled. A resource is responsible for indicating it has work to do, by calling the `ae_resource_request_poll` function. After calling this function, {aesop} will -schedule a call to the resource's `poll_context` function. +schedule a call to the resource's `poll` function. The `ae_resource_request_poll` function is thread-safe and can safely be called from within a signal handler. diff --git a/op.h b/op.h index a40471a..d0f65af 100644 --- a/op.h +++ b/op.h @@ -24,7 +24,6 @@ typedef struct ae_op /*int (*op_worker)(struct ae_op* op); */ void *user_ptr; ae_hints_t *hints; - ae_context_t ctx; triton_list_link_t link; } ae_op_t; @@ -42,15 +41,13 @@ typedef struct ae_op (_op)->callback = (__ae_callback); \ (_op)->user_ptr = (__ae_user_ptr); \ (_op)->hints = (__ae_hints); \ - (_op)->ctx = (__ae_ctx); \ } while(0) -#define ae_op_fill_with_params(_op, _cb, _up, _hints, _ctx) \ +#define ae_op_fill_with_params(_op, _cb, _up, _hints) \ do { \ (_op)->callback = (_cb); \ (_op)->user_ptr = (_up); \ (_op)->hints = (_hints); \ - (_op)->ctx = (_ctx); \ } while(0) #define ae_ops_link_clear(_op) triton_list_link_clear(&(_op)->link) @@ -60,7 +57,6 @@ typedef struct ae_op (_op)->callback = NULL; \ (_op)->user_ptr = NULL; \ (_op)->hints = NULL; \ - (_op)->ctx = NULL; \ ae_ops_link_clear(_op); \ } while(0) diff --git a/parser/tests/blocking/btest-impl.c b/parser/tests/blocking/btest-impl.c index ea80427..78ede74 100644 --- a/parser/tests/blocking/btest-impl.c +++ b/parser/tests/blocking/btest-impl.c @@ -173,7 +173,7 @@ ae_define_post(int, btest_fail10, int *a) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &list_fail10); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -193,7 +193,7 @@ ae_define_post(int, btest_consec) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &list_consec); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -214,7 +214,7 @@ ae_define_post(int, btest1, int *a) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &list1); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -234,7 +234,7 @@ ae_define_post(int, btest2, int *a) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &list2); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -254,7 +254,7 @@ ae_define_post(int, btest3, int *a) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &list3); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -273,7 +273,7 @@ ae_define_post(int, btest_sleep, int secs) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &slist); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -292,7 +292,7 @@ ae_define_post(int, btest_sleep_random) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &srlist); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -311,7 +311,7 @@ ae_define_post(int, btest_forever) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &flist); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -330,7 +330,7 @@ ae_define_post(int, btest_random) bop->id = ae_id_gen(btest_resource_id, (intptr_t) op); *__ae_op_id = bop->id; ae_ops_enqueue(op, &rlist); - ae_resource_request_poll(op->ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); return 0; } @@ -394,7 +394,7 @@ static struct btest_op * poll_list(ae_ops_t *list, int *more) static int consec_count = 0; -static int btest_poll(ae_context_t context, void *user_data) +static int btest_poll(void *user_data) { int more, request; struct btest_op *b; @@ -552,12 +552,12 @@ static int btest_poll(ae_context_t context, void *user_data) if(request) { - ae_resource_request_poll(context, btest_resource_id); + ae_resource_request_poll(btest_resource_id); } return AE_SUCCESS; } -static int btest_cancel(ae_context_t ctx, ae_op_id_t op_id) +static int btest_cancel(ae_op_id_t op_id) { struct ae_op *t, *tmp; struct btest_op *b; @@ -570,14 +570,14 @@ static int btest_cancel(ae_context_t ctx, ae_op_id_t op_id) ae_ops_del(t); printf("forever op cancelled\n"); ae_ops_enqueue(&b->op, &clist); - ae_resource_request_poll(ctx, btest_resource_id); + ae_resource_request_poll(btest_resource_id); } } return AE_SUCCESS; } -static int btest_cancel_immed(ae_context_t ctx, ae_op_id_t op_id) +static int btest_cancel_immed(ae_op_id_t op_id) { struct ae_op *t, *tmp; struct btest_op *b; @@ -612,7 +612,7 @@ static int btest_cancel_immed(ae_context_t ctx, ae_op_id_t op_id) struct ae_resource btest_resource = { .resource_name = RESOURCE_NAME, - .poll_context = btest_poll, + .poll = btest_poll, .cancel = btest_cancel, }; diff --git a/resource.c b/resource.c index 21f54f8..48e9687 100644 --- a/resource.c +++ b/resource.c @@ -17,8 +17,7 @@ struct ae_poll_data { ev_async async; - int (*poll_context)(ae_context_t context, void *user_data); - ae_context_t context; + int (*poll)(void *user_data); void *user_data; }; @@ -43,20 +42,6 @@ static pthread_t ev_loop_thread; #define AE_RESOURCE_IDX2ID(reindex) (reindex+16) #define AE_RESOURCE_ID2IDX(rid) (rid-16) -struct ae_context -{ - int id; - int resource_count; - int* resource_ids; - struct ae_poll_data* poll_data; - struct ev_loop *eloop; - ev_async eloop_breaker; -}; - -static int ae_context_count = 0; -static struct ae_context ae_context_entries[AE_MAX_CONTEXTS]; - - static void ev_break_cb(EV_P_ ev_async *w, int revents) { /* Break the loop. Note that ev_run() will still process all events @@ -73,8 +58,8 @@ static void ev_async_cb(EV_P_ ev_async *w, int revents) struct ae_poll_data* poll_data = (struct ae_poll_data*)(((char*)w)-offsetof(struct ae_poll_data, async)); - assert(poll_data->poll_context); - ret = poll_data->poll_context(poll_data->context, poll_data->user_data); + assert(poll_data->poll); + ret = poll_data->poll(poll_data->user_data); /* TODO: error handling? */ aesop_error_assert(ret); @@ -137,9 +122,7 @@ int ae_resource_register_with_data(struct ae_resource *resource, int *newid, assert(reindex > -1 && reindex < MAX_RESOURCES); ev_async_init(&ae_resource_entries[reindex].poll_data.async, ev_async_cb); - ae_resource_entries[reindex].poll_data.poll_context = - resource->poll_context; - ae_resource_entries[reindex].poll_data.context = NULL; + ae_resource_entries[reindex].poll_data.poll = resource->poll; ae_resource_entries[reindex].poll_data.user_data = user_data; ev_async_start(eloop, &ae_resource_entries[reindex].poll_data.async); @@ -155,10 +138,6 @@ void ae_resource_unregister(int id) { int idx = AE_RESOURCE_ID2IDX(id); - /* TODO: what about contexts that might include this resource? Do we - * just assume that contexts are always closed before resources are - * unregistered? - */ ev_async_stop(eloop, &ae_resource_entries[idx].poll_data.async); memset(&ae_resource_entries[idx], 0, sizeof(ae_resource_entries[idx])); @@ -167,53 +146,22 @@ void ae_resource_unregister(int id) ae_resource_count--; } -static void find_async_watcher(ae_context_t context, int resource_id, ev_async** async_out, struct ev_loop** loop_out) +static void find_async_watcher(int resource_id, ev_async** async_out) { ev_async* async = NULL; - int i; int ridx; - struct ev_loop *target_loop = NULL; - - if(context) - { - /* find this resource in the context */ - for(i=0; i<context->resource_count; i++) - { - if(resource_id == context->resource_ids[i]) - { - async = &context->poll_data[i].async; - target_loop = context->eloop; - break; - } - } - } - else - { - /* find this resource in the global list */ - ridx = AE_RESOURCE_ID2IDX(resource_id); - async = &ae_resource_entries[ridx].poll_data.async; - target_loop = eloop; - } + + /* find this resource in the global list */ + ridx = AE_RESOURCE_ID2IDX(resource_id); + async = &ae_resource_entries[ridx].poll_data.async; if(!async) { - aesop_err("Error: context %p is not configured to handle resource with id %d", context, resource_id); - for(i=0; i<MAX_RESOURCES; i++) - { - if(ae_resource_entries[i].id == resource_id) - { - aesop_err("Consider adding the \"%s\" resource your aesop context.", ae_resource_entries[i].resource->resource_name); - assert(0); - } - } aesop_err("Error: resource_id %d is unknown to aesop. Are you using a resource that was not initialized?\n", resource_id); assert(0); } - assert(target_loop); - *async_out = async; - *loop_out = target_loop; return; } @@ -224,47 +172,32 @@ static void find_async_watcher(ae_context_t context, int resource_id, ev_async** * functions to allow the c program to continue execution after the final * aesop callback has completed. */ -void ae_poll_break(ae_context_t context) +void ae_poll_break() { - ev_async* breaker = NULL; - struct ev_loop *target_loop = NULL; - - if(context) - { - breaker = &context->eloop_breaker; - target_loop = context->eloop; - } - else - { - breaker = &eloop_breaker; - target_loop = eloop; - } - if(pthread_equal(ev_loop_thread, pthread_self())) { /* this was called from the event loop thread, so we know that it is * already awake. Just make sure that it exits if the * ae_poll_break() as called from a libev callback. */ - ev_break(target_loop, EVBREAK_ONE); + ev_break(eloop, EVBREAK_ONE); return; } - ev_async_send(target_loop, breaker); + ev_async_send(eloop, &eloop_breaker); } /** * ae_resource_request_poll() is used by a resource to inform aesop that the * resource needs to be polled. */ -void ae_resource_request_poll(ae_context_t context, int resource_id) +void ae_resource_request_poll(int resource_id) { ev_async* async = NULL; - struct ev_loop *target_loop = NULL; - find_async_watcher(context, resource_id, &async, &target_loop); + find_async_watcher(resource_id, &async); - ev_async_send(target_loop, async); + ev_async_send(eloop, async); return; } @@ -321,37 +254,25 @@ static void timeout_cb(EV_P_ ev_timer *w, int revents) ev_break(EV_A_ EVBREAK_ONE); } -int ae_poll(ae_context_t context, int millisecs) +int ae_poll(int millisecs) { - struct ev_loop* target_loop; ev_timer timeout; int hit_timeout = 0; - if(context) - { - /* use context specific event loop */ - target_loop = context->eloop; - } - else - { - /* use global event loop */ - target_loop = eloop; - } - if(millisecs > 0) { timeout.data = &hit_timeout; ev_timer_init(&timeout, timeout_cb, (double)millisecs * 1000.0, 0); - ev_timer_start(target_loop, &timeout); - ev_run(target_loop, 0); + ev_timer_start(eloop, &timeout); + ev_run(eloop, 0); } else { - ev_run(target_loop, EVRUN_NOWAIT); + ev_run(eloop, EVRUN_NOWAIT); } if(millisecs > 0) - ev_timer_stop(target_loop, &timeout); + ev_timer_stop(eloop, &timeout); /* this means that the event loop timed out without finding any work */ if(hit_timeout == 1) @@ -364,131 +285,12 @@ int ae_poll(ae_context_t context, int millisecs) #include <stdarg.h> -int _ae_context_create(ae_context_t *context, const char *format __attribute__((unused)), int resource_count, ...) -{ - va_list ap; - char *rname; - int cindex = ae_context_count; - ae_context_t c; - int i, j, reindex; - int ret; - - if(ae_context_count == AE_MAX_CONTEXTS) - { - return AE_ERR_INVALID; - } - - c = &(ae_context_entries[cindex]); - c->id = ae_context_count; - ae_context_count++; - c->resource_count = resource_count; - c->resource_ids = malloc(sizeof(*c->resource_ids) * resource_count); - if(!c->resource_ids) - { - return AE_ERR_SYSTEM; - } - c->poll_data = malloc(sizeof(*c->poll_data) * resource_count); - if(!c->poll_data) - { - free(c->resource_ids); - return AE_ERR_SYSTEM; - } - - c->eloop = ev_loop_new(EVFLAG_AUTO); - if(!c->eloop) - { - aesop_err("Error: could not create libev event loop.\n"); - free(c->resource_ids); - free(c->poll_data); - return(AE_ERR_SYSTEM); - } - ev_async_init(&c->eloop_breaker, ev_break_cb); - ev_async_start(c->eloop, &c->eloop_breaker); - - reindex = 0; - - /* step through the resource names passed in and register the context with them */ - va_start(ap, resource_count); - for(i = 0; i < resource_count; ++i) - { - int resource_found = 0; - rname = va_arg(ap, char *); - - /* find the matching resource and register the context with that resource */ - - for(j = 0; j < MAX_RESOURCES; ++j) - { - if(!strcmp(ae_resource_entries[j].resource->resource_name, rname)) - { - ev_async_init(&c->poll_data[reindex].async, ev_async_cb); - c->poll_data[reindex].poll_context = - ae_resource_entries[j].poll_data.poll_context; - c->poll_data[reindex].context = c; - c->poll_data[reindex].user_data = - ae_resource_entries[j].poll_data.user_data; - - if(ae_resource_entries[j].resource->register_context) - { - ret = ae_resource_entries[j].resource->register_context(c); - if(ret != AE_SUCCESS) - { - /* what do we do if a context fails to register with a resource? */ - va_end(ap); - return ret; - } - } - ev_async_start(c->eloop, &c->poll_data[reindex].async); - - c->resource_ids[reindex] = ae_resource_entries[j].id; - - reindex++; - resource_found = 1; - break; - } - } - if(!resource_found) - { - va_end(ap); - return AE_ERR_NOT_FOUND; - } - } - va_end(ap); - - *context = c; - return AE_SUCCESS; -} - -int ae_context_destroy(ae_context_t context) -{ - int rid, idx, i; - - for(i = 0; i < context->resource_count; ++i) - { - rid = context->resource_ids[i]; - idx = AE_RESOURCE_ID2IDX(rid); - if(ae_resource_entries[idx].resource->unregister_context) - { - ae_resource_entries[idx].resource->unregister_context(context); - } - ev_async_stop(context->eloop, &context->poll_data[i].async); - } - free(context->resource_ids); - free(context->poll_data); - context->resource_ids = NULL; - context->poll_data = NULL; - context->id = -1; - context->resource_count = -1; - ev_loop_destroy(context->eloop); - return AE_SUCCESS; -} - - /** - * Given an op_id and a context, try to call the resource to cancel + * Given an op_id, try to call the resource to cancel * the operation if it was generated by a resource. * Otherwise, do nothing. */ -static int ae_cancel_resource_op (ae_context_t context, ae_op_id_t op) +static int ae_cancel_resource_op (ae_op_id_t op) { int resource_id; @@ -513,7 +315,7 @@ static int ae_cancel_resource_op (ae_context_t context, ae_op_id_t op) if(ae_resource_entries[ridx].resource->cancel) { - return ae_resource_entries[ridx].resource->cancel(context, op); + return ae_resource_entries[ridx].resource->cancel(op); } else { @@ -601,8 +403,7 @@ int ae_cancel_ctl (struct ae_ctl * ctl) assert (resource_id); /* We're in a context that actually called a resource function */ - ret = ae_cancel_resource_op (ctl->context, - ctl->current_op_id); + ret = ae_cancel_resource_op (ctl->current_op_id); if (ret == AE_SUCCESS) @@ -633,7 +434,6 @@ int ae_cancel_branches(struct ae_ctl *ctl) //int ret; //ae_op_id_t *children_ids; //int ind, count, error; - //ae_context_t context; ae_debug_cancel("ae_cancel_branches: %p\n", ctl); diff --git a/resource.h b/resource.h index cdf6c5b..48f952d 100644 --- a/resource.h +++ b/resource.h @@ -36,7 +36,6 @@ int __fname(void (*__ae_callback)(void *ptr, __ret_type ret), \ void *__ae_user_ptr, \ ae_hints_t *__ae_hints, \ - ae_context_t __ae_ctx, \ ae_op_id_t *__ae_op_id, \ int __ae_internal, \ __ret_type *__ae_retval, \ @@ -100,10 +99,8 @@ struct ae_resource { const char *resource_name; int (*test)(ae_op_id_t id, int ms_timeout); - int (*poll_context)(ae_context_t context, void *user_data); - int (*cancel)(ae_context_t ctx, ae_op_id_t id); - int (*register_context)(ae_context_t context); - int (*unregister_context)(ae_context_t context); + int (*poll)(void *user_data); + int (*cancel)(ae_op_id_t id); }; /** @@ -133,10 +130,10 @@ int ae_resource_register_with_data(struct ae_resource *resource, int *newid, voi void ae_resource_unregister(int resource_id); /* Called by resources to request polling from the event loop */ -void ae_resource_request_poll(ae_context_t context, int resource_id); +void ae_resource_request_poll(int resource_id); /* Cancel an operation */ -int ae_cancel_op(ae_context_t context, ae_op_id_t op_id); +int ae_cancel_op(ae_op_id_t op_id); /** diff --git a/resources/sem/sem.c b/resources/sem/sem.c index fbe164d..64f849a 100644 --- a/resources/sem/sem.c +++ b/resources/sem/sem.c @@ -181,7 +181,7 @@ ae_define_post(int, aesop_sem_down, aesop_sem_t * sem) ((_ptr != NULL) ? \ ((_type *)((char *)(_ptr) - (unsigned long)((&((_type *)0)->_member)))) : NULL) -static int sem_cancel (ae_context_t ctx, ae_op_id_t op_id) +static int sem_cancel (ae_op_id_t op_id) { int resource_id; @@ -249,13 +249,13 @@ static int sem_cancel (ae_context_t ctx, ae_op_id_t op_id) ae_ops_enqueue (&wait->op, &sem_cancel_queue); triton_mutex_unlock (&sem_cancel_lock); - ae_resource_request_poll (ctx, sem_resource_id); + ae_resource_request_poll (sem_resource_id); return AE_SUCCESS; } -static int sem_poll (ae_context_t ctx, void * arg) +static int sem_poll (void * arg) { triton_mutex_lock (&sem_cancel_lock); while (!ae_ops_empty (&sem_cancel_queue)) @@ -282,7 +282,7 @@ static struct ae_resource sem_resource = { .resource_name = "aesop_sem", .cancel = sem_cancel, - .poll_context = sem_poll, + .poll = sem_poll, }; diff --git a/resources/thread/aethread.c b/resources/thread/aethread.c index 842871f..e5d257d 100644 --- a/resources/thread/aethread.c +++ b/resources/thread/aethread.c @@ -266,7 +266,6 @@ ae_define_post(int, aethread_hint, struct aethread_group * group) } static int triton_aethread_poll( - ae_context_t context, void *data) { triton_mutex_lock(&aethread_cancel_lock); @@ -284,7 +283,6 @@ static int triton_aethread_poll( } static int triton_aethread_cancel( - ae_context_t triton_ctx, ae_op_id_t op_id) { int resource_id; @@ -329,7 +327,7 @@ static int triton_aethread_cancel( if (found) { - ae_resource_request_poll(triton_ctx, aethread_resource_id); + ae_resource_request_poll(aethread_resource_id); return (AE_SUCCESS); } @@ -339,7 +337,7 @@ static int triton_aethread_cancel( struct ae_resource triton_aethread_resource = { .resource_name = "thread", - .poll_context = triton_aethread_poll, + .poll = triton_aethread_poll, .cancel = triton_aethread_cancel, }; diff --git a/resources/worker/worker.c b/resources/worker/worker.c index 0263ad6..d6f436f 100644 --- a/resources/worker/worker.c +++ b/resources/worker/worker.c @@ -59,14 +59,14 @@ int aesop_worker_schedule (aesop_worker_t * worker) * We don't have access to the context since this is not a blocking * function. */ - ae_resource_request_poll (NULL, worker_resource_id); + ae_resource_request_poll (worker_resource_id); } return AE_SUCCESS; } -static int aesop_worker_poll (ae_context_t context, void * arg) +static int aesop_worker_poll (void * arg) { assert (worker_refcount); @@ -105,7 +105,7 @@ static int aesop_worker_poll (ae_context_t context, void * arg) static struct ae_resource worker_resource = { .resource_name = "worker", - .poll_context = aesop_worker_poll + .poll = aesop_worker_poll }; diff --git a/src/ssm/aessm.ae b/src/ssm/aessm.ae index 094a51a..0a06f32 100644 --- a/src/ssm/aessm.ae +++ b/src/ssm/aessm.ae @@ -569,13 +569,12 @@ static void * aessm_thread (void *arg) * This function is intended to be called by the aesop poller. * * Parameters: - * context - aesop internal context * user_data - data provided in ae_resource_register * * Returns: * AE_SUCCESS - poll was successful */ -static int aessm_poll (ae_context_t context, void *user_data) +static int aessm_poll (void *user_data) { struct timeval tv; int rc; @@ -591,7 +590,7 @@ static int aessm_poll (ae_context_t context, void *user_data) rc = ssm_wait(aessm_id->ssm, &tv); assert(rc >= 0); - ae_resource_request_poll(context, aessm_id->resource_id); + ae_resource_request_poll(aessm_id->resource_id); return AE_SUCCESS; } @@ -602,7 +601,7 @@ static int aessm_poll (ae_context_t context, void *user_data) static struct ae_resource aessm_resource = { .resource_name = "aessm", - .poll_context = aessm_poll + .poll = aessm_poll }; /* diff --git a/tests/resource-register.c b/tests/resource-register.c index acbc206..a77bfc7 100644 --- a/tests/resource-register.c +++ b/tests/resource-register.c @@ -11,14 +11,14 @@ struct ae_resource rsc1 = { .resource_name = "rsc1", - .poll_context = NULL, + .poll = NULL, .cancel = NULL, }; struct ae_resource rsc2 = { .resource_name = "rsc2", - .poll_context = NULL, + .poll = NULL, .cancel = NULL, }; hooks/post-receive --
participants (1)
-
noreply@mcs.anl.gov