static int smx_ctx_ruby_factory_finalize(smx_context_factory_t *factory);
static void smx_ctx_ruby_free(smx_context_t context);
-static void smx_ctx_ruby_start(smx_context_t context);
static void smx_ctx_ruby_stop(smx_context_t context);
static void smx_ctx_ruby_suspend(smx_context_t context);
-static void
-smx_ctx_ruby_resume(smx_context_t old_context,smx_context_t new_context);
+static void smx_ctx_ruby_resume(smx_context_t new_context);
static void smx_ctx_ruby_wrapper(void);
(*factory)->create_context = smx_ctx_ruby_create_context;
(*factory)->finalize = smx_ctx_ruby_factory_finalize;
(*factory)->free = smx_ctx_ruby_free;
- (*factory)->start = smx_ctx_ruby_start;
(*factory)->stop = smx_ctx_ruby_stop;
(*factory)->suspend = smx_ctx_ruby_suspend;
(*factory)->resume = smx_ctx_ruby_resume;
/* if the user provided a function for the process , then use it
Otherwise it's the context for maestro */
if (code) {
- context->cleanup_func = cleanup_func;
- context->cleanup_arg = cleanup_arg;
+ context->super.cleanup_func = cleanup_func;
+ context->super.cleanup_arg = cleanup_arg;
context->process = (VALUE)code;
- context->argc=argc;
- context->argv=argv;
+ context->super.argc=argc;
+ context->super.argv=argv;
DEBUG1("smx_ctx_ruby_create_context(%s)...Done",argv[0]);
}
// FIXME
static void smx_ctx_ruby_free(smx_context_t context) {
- // DEBUG1("smx_ctx_ruby_free(%s)",context->argv[0]);
-
- //VALUE process;
- /*if (context)
- {
- smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) context;
- rb_process_isProcess(ctx_ruby->process);
- if (ctx_ruby->process){
- // if the Ruby Process is Alive , Join it
- if ( rb_process_isAlive(ctx_ruby->process))
- {
- process = ctx_ruby->process;
- ctx_ruby->process = Qnil;
- rb_process_join(process);
- }
- }
- free(context);
- context = NULL;
- } */
-
+ int i;
if (context) {
DEBUG1("smx_ctx_ruby_free_context(%p)",context);
+ /* free argv */
+ if (context->argv) {
+ for (i = 0; i < context->argc; i++)
+ if (context->argv[i])
+ free(context->argv[i]);
+
+ free(context->argv);
+ }
free (context);
context = NULL;
}
}
-static void smx_ctx_ruby_start(smx_context_t context) {
- DEBUG1("smx_ctx_ruby_start(%s) (nothing to do)",context->argv[0]);
- /* Already Done .. Since a Ruby process is launched within initialization
- We Start it Within the Initializer ... We Use the Semaphore To Keep
- the thread alive waiting for mutex signal to execute the main*/
-}
-
static void smx_ctx_ruby_stop(smx_context_t context) {
DEBUG0("smx_ctx_ruby_stop()");
VALUE process = Qnil;
rb_process_unschedule(ctx_ruby->process);
}
-static void smx_ctx_ruby_resume(smx_context_t old_context,smx_context_t new_context) {
- DEBUG2("smx_ctx_ruby_resume(%s,%s)",
- (old_context->argc?old_context->argv[0]:"maestro"),
+static void smx_ctx_ruby_resume(smx_context_t new_context) {
+ DEBUG1("smx_ctx_ruby_resume(%s)",
(new_context->argc?new_context->argv[0]:"maestro"));
smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context;