summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Elstner <daniel@src.gnome.org>2004-05-20 23:24:54 +0000
committerDaniel Elstner <daniel@src.gnome.org>2004-05-20 23:24:54 +0000
commit9d17268e32a07c2d52b2c847d3d76ccf5b00f990 (patch)
tree2655a18433ad2b760358b442dafa850832fbe426
parentb325c1375584fb4aa49605e10138543060d95a87 (diff)
downloadglibmm-9d17268e32a07c2d52b2c847d3d76ccf5b00f990.tar.gz
Revert last commit because it's silly. To make the code truly
* examples/thread/dispatcher.cc: Revert last commit because it's silly. To make the code truly exception-safe it would be necessary to either join all threads or to notify them, which is way beyond the scope of this example.
-rw-r--r--ChangeLog7
-rw-r--r--examples/thread/dispatcher.cc34
2 files changed, 14 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index f4234917..a89bad52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2004-05-20 Daniel Elstner <daniel.elstner@gmx.net>
+ * examples/thread/dispatcher.cc: Revert last commit because it's
+ silly. To make the code truly exception-safe it would be necessary
+ to either join all threads or to notify them, which is way beyond
+ the scope of this example.
+
+2004-05-20 Daniel Elstner <daniel.elstner@gmx.net>
+
* examples/thread/dispatcher.cc: Set a good example and
be paranoid about possible memory leaks due to exeptions.
diff --git a/examples/thread/dispatcher.cc b/examples/thread/dispatcher.cc
index 76b1a268..ce484baf 100644
--- a/examples/thread/dispatcher.cc
+++ b/examples/thread/dispatcher.cc
@@ -54,7 +54,6 @@ private:
Glib::RefPtr<Glib::MainLoop> main_loop_;
std::list<ThreadProgress*> progress_list_;
- void clear_progress_list();
void on_progress_finished(ThreadProgress* thread_progress);
};
@@ -120,28 +119,18 @@ Application::Application()
{
std::cout << "Thread Dispatcher Example." << std::endl;
- try
+ for(int i = 1; i <= 5; ++i)
{
- for(int i = 1; i <= 5; ++i)
- {
- progress_list_.push_back(0); // be paronoid about exceptions
- ThreadProgress *const progress = (progress_list_.back() = new ThreadProgress(i));
-
- progress->signal_finished().connect(
- sigc::bind(sigc::mem_fun(*this, &Application::on_progress_finished), progress));
- }
- }
- catch(...)
- {
- clear_progress_list();
- throw;
+ std::auto_ptr<ThreadProgress> progress (new ThreadProgress(i));
+ progress_list_.push_back(progress.get());
+
+ progress->signal_finished().connect(
+ sigc::bind(sigc::mem_fun(*this, &Application::on_progress_finished), progress.release()));
}
}
Application::~Application()
-{
- clear_progress_list();
-}
+{}
void Application::launch_threads()
{
@@ -154,15 +143,6 @@ void Application::run()
main_loop_->run();
}
-void Application::clear_progress_list()
-{
- while(!progress_list_.empty())
- {
- const std::auto_ptr<ThreadProgress> temp (progress_list_.back());
- progress_list_.pop_back();
- }
-}
-
void Application::on_progress_finished(ThreadProgress* thread_progress)
{
{