473,503 Members | 11,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gracefull termination of execution.

1 New Member
Hi all,

I have a problem and I wanted to solve it :-).

My problem is I have an application (under GNU/Linux) wich launches a thread, executes some code and collects some statistics. My problem is I want to stop the execution of this code by some sort of key code ( something like Control-C), but I don't want to terminate, instead I want to simply stop the executing thread and perform some calculations with the statistics.
I could do this simply by using signal's but this I'm using C++ and since I'm using exceptions and the class that contains the exceuted code cannot be a singleton I'm in a dilema. I can't figure out a way to stop the execution of this code without terminating the whole program. Below is some pseudo-code trying to better exlpain my problem.


class my_class
{
thread_execution_function();
do_some_statistics();
....
}


my_class::thread_execution_function()
{
while( !terminate)
{
executing....;
}
}


code:

....

my_class.thread_execution_function();

my_class.do_some_statistics();

...

This is basicly my problem. If someone has any idea I would be gratelly appreciated.

Kind Regards.

José Rui
May 31 '07 #1
1 1537
weaknessforcats
9,208 Recognized Expert Moderator Expert
Presumable you could signal the thread which would cause it to look in a global area for what to do. Like pause. Or quit.
May 31 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1346
by: Alexander Staubo | last post by:
Python does not seem to clean up gracefully on SIGTERM: The exit sequence is not invoked on termination, so the atexit module cannot be used to install shutdown logic. Further, while the signal...
2
2070
by: Jim McGrail | last post by:
Background: I am investigating a problem involving a windows .NET application that is being developed in C# with Visual Studio 2003. It is a multi-threaded application that uses MSMQ to...
2
309
by: ice88 | last post by:
I would like to execute some code when a thread terminates, in the context of that thread - I guess similar to an ExitThread handler - is it possible in a C# .NET application? I can see a way to...
2
2972
by: Rahul Anand | last post by:
I have a problem in my multithreaded application. The problem is reproducible very rarely, only once in 6000 similar execution (through same code path). Problem: One of multiple threads gets...
669
25390
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
7
2499
by: KS | last post by:
I have taken up C++ after about 4 years with Java and I am facing a problem with the code that I have written. The problem is that the execution unexpectedly terminates without any error or dump....
9
6862
by: ehabaziz2001 | last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal program termination" E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01 Enter a number : 25 More numbers (y/n)? y...
1
1737
by: Sanjay | last post by:
Hi All Have an app. On start up it creates a thread and goes to sleep. Either on termination or completion of the worker thread, it triggers the main app to start executing. Question Why...
0
1781
by: Tim Golden | last post by:
Robert Rawlins wrote: You want to look at the atexit module: http://docs.python.org/lib/module-atexit.html but mind the caveats: """ Note: the functions registered via this module are not
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.