G
gamehack
Hello all,
I've thought about having to implement 2 functions, say
enter_main_loop(func_name); and a function called quit_application();
which terminates the program. The enter_main_loop() can be defined as
something like:
int enter_main_loop(func_name)
{
while(1)
{
func_name();
}
return 0;
}
But then how am I going to implement the quit_application(); ? The only
way I thought it could be handled is changing enter_main_loop to
something like:
int terminate = 0;
int enter_main_loop(func_name)
{
if(!terminate)
func_name();
return 0;
}
and then quit_application(); can simply do
int quit_application()
{
return (terminate = 1);
}
What do you think about this approach? Any better ways of achieving the
same effect? I'm planning to use the quit_application() in a
multithreaded environment so I assume it should be thread-safe (but it
isn't now, is it)?
Thanks
I've thought about having to implement 2 functions, say
enter_main_loop(func_name); and a function called quit_application();
which terminates the program. The enter_main_loop() can be defined as
something like:
int enter_main_loop(func_name)
{
while(1)
{
func_name();
}
return 0;
}
But then how am I going to implement the quit_application(); ? The only
way I thought it could be handled is changing enter_main_loop to
something like:
int terminate = 0;
int enter_main_loop(func_name)
{
if(!terminate)
func_name();
return 0;
}
and then quit_application(); can simply do
int quit_application()
{
return (terminate = 1);
}
What do you think about this approach? Any better ways of achieving the
same effect? I'm planning to use the quit_application() in a
multithreaded environment so I assume it should be thread-safe (but it
isn't now, is it)?
Thanks