473,804 Members | 2,273 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_executio n_function();
do_some_statist ics();
....
}


my_class::threa d_execution_fun ction()
{
while( !terminate)
{
executing....;
}
}


code:

....

my_class.thread _execution_func tion();

my_class.do_som e_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 1555
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
1365
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 module allows trapping the signal, it does not offer a truly portable way of respecting the termination request. As far as I can see, this issue has been a topic of conversation for years, but I don't see that it has ever been solved: ...
2
2091
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 communicate between the threads. The problem is that the program infrequently terminates with no indication of why it terminated.
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 execute code when a thread is thrown away - by having per-thread static attributes that are themselves objects, when the thread object associated with that static value is garbage collected, the destructor for the object is driven - but that...
2
2985
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 abnormally terminated. It does not goes through the try-catch-finally sequence. The mehtod gets hanged and the object used inside the method gets collected by GC. Bacground about the application: I am using COM-Interop. The threads are created in...
669
26274
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 paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
7
2521
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. Are there any commonly known bugs that can cause this problem? I would really appreciate it if you would take a look at the source. I have uploaded the complete source file at: http://www.grex.org/~kpp/gamultiknapsack.cpp (You will need the...
9
6908
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 Enter a number : 30 More numbers (y/n)? n
1
1750
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 is the completion of the worker/child thread triggering the execution of the main app thread. Shouldn't the main app thread remain
0
1820
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
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9171
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.