Commit 92b54f5b authored by Maxime Perrotin's avatar Maxime Perrotin

Allow multiple timers with the same name

parent 82c88e88
Pipeline #370 skipped
This diff is collapsed.
......@@ -538,13 +538,28 @@ void add_RI_to_c_wrappers(Interface * i)
}
}
else { /* synch==i->synchronism (RI is synchronous) :
make a direct call to the remote function
defined in remote polyorb_interface.c,
else { /* synch==i->synchronism (RI is synchronous) :
make a direct call to the remote function
defined in remote polyorb_interface.c,
and pass the thread id as parameter */
int count = 0;
FOREACH(t, FV, i->parent_fv->calling_threads, {
(void) t; count++;});
/* Build the list of calling threads for this RI */
FV_list *calltmp = NULL;
if (NULL == i->calling_pis) calltmp = i->parent_fv->calling_threads;
else {
FOREACH(calling_pi, Interface, i->calling_pis, {
FOREACH(thread_caller, FV, calling_pi->calling_threads, {
ADD_TO_SET(FV, calltmp, thread_caller);
});
});
}
/* Count the number of calling threads */
FOREACH(ct, FV, calltmp, {
(void) ct;
count ++;
});
fprintf(b, "\tsync_%s_%s(", i->distant_fv,
NULL != i->distant_name ? i->distant_name : i->name);
......@@ -554,8 +569,7 @@ void add_RI_to_c_wrappers(Interface * i)
fprintf(b, "%s_callinglist_get_top_value()",
i->parent_fv->name);
} else if (1 == count) {
fprintf(b, "%d",
i->parent_fv->calling_threads->value->thread_id);
fprintf(b, "%d", calltmp->value->thread_id);
} else if (0 == count) {
printf
("Warning: function \"%s\" is not called by anyone (dead code)!\n",
......
......@@ -186,9 +186,11 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
FOREACH (timer, String, fv->timer_list, {
/* Declare functions in timer manager code */
fprintf (header, "void %s_PI_SET_%s(const asn1SccT_UInt32 *val);\n\n",
timer_manager->name, timer);
fprintf (code, "void %s_PI_SET_%s(const asn1SccT_UInt32 *val)\n"
fprintf (header, "void %s_PI_%s_SET_%s(const asn1SccT_UInt32 *val);\n\n",
timer_manager->name,
fv->name,
timer);
fprintf (code, "void %s_PI_%s_SET_%s(const asn1SccT_UInt32 *val)\n"
"{\n"
" /* Timer value must be multiple of 100 ms */\n"
" assert (*val %% 100 == 0);\n"
......@@ -196,18 +198,22 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
" timers[%s_%s].value = *val / 100;\n"
"}\n\n",
timer_manager->name,
fv->name,
timer,
fv->name,
timer,
fv->name,
timer);
fprintf (header, "void %s_PI_RESET_%s();\n\n",
timer_manager->name, timer);
fprintf (code, "void %s_PI_RESET_%s()\n"
fprintf (header, "void %s_PI_%s_RESET_%s();\n\n",
timer_manager->name,
fv->name,
timer);
fprintf (code, "void %s_PI_%s_RESET_%s()\n"
"{\n"
" timers[%s_%s].state = inactive;\n"
"}\n\n",
timer_manager->name,
fv->name,
timer,
fv->name,
timer);
......@@ -242,9 +248,11 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
/* Add Unpro PI "RESET_timer" to timer manager (no param) */
reset_timer = Duplicate_Interface (PI, expire, timer_manager);
free (reset_timer->name);
reset_timer->name = make_string ("RESET_%s", timer);
reset_timer->name = make_string ("%s_RESET_%s",
fv->name,
timer);
free (reset_timer->distant_name);
reset_timer->distant_name = make_string (reset_timer->name);
reset_timer->distant_name = make_string ("RESET_%s", timer); // irrelevant in PI
reset_timer->rcm = unprotected;
reset_timer->synchronism = synch;
APPEND_TO_LIST (Interface, timer_manager->interfaces, reset_timer);
......@@ -252,15 +260,21 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
/* Add corresponding RI in the user FV */
reset_timer = Duplicate_Interface (RI, reset_timer, fv);
free (reset_timer->distant_fv);
reset_timer->distant_fv = make_string (timer_manager->name);
reset_timer->distant_fv = make_string (timer_manager->name);
reset_timer->name = make_string("RESET_%s", timer);
reset_timer->distant_name = make_string("%s_%s",
fv->name,
reset_timer->name);
APPEND_TO_LIST (Interface, fv->interfaces, reset_timer);
/* Add Unpro PI "SET_timer(value)" in timer manager */
set_timer = Duplicate_Interface (PI, reset_timer, timer_manager);
free (set_timer->name);
set_timer->name = make_string ("SET_%s", timer);
set_timer->name = make_string ("%s_SET_%s",
fv->name,
timer);
free (set_timer->distant_name);
set_timer->distant_name = make_string (set_timer->name);
set_timer->distant_name = make_string ("SET_%s", timer);
/* Add IN param holding the timer duration */
Create_Parameter (&param);
......@@ -278,6 +292,10 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
/* Add corresponding RI in the user FV */
set_timer = Duplicate_Interface (RI, set_timer, fv);
free (set_timer->distant_fv);
set_timer->name = make_string("SET_%s", timer);
set_timer->distant_name = make_string("%s_%s",
fv->name,
set_timer->name);
set_timer->distant_fv = make_string (timer_manager->name);
APPEND_TO_LIST (Interface, fv->interfaces, set_timer);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment