Author: suokko
Date: Fri Sep 5 11:59:25 2008
New Revision: 29292
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29292&view=rev
Log:
Fixed async_operation thread not to try free it self after execution
Modified:
trunk/src/thread.cpp
trunk/src/thread.hpp
Modified: trunk/src/thread.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/thread.cpp?rev=29292&r1=29291&r2=29292&view=diff
==============================================================================
--- trunk/src/thread.cpp (original)
+++ trunk/src/thread.cpp Fri Sep 5 11:59:25 2008
@@ -147,6 +147,7 @@
finishedVar_ = true;
return finished_.notify_one();
}
+active_operation_list async_operation::active_;
async_operation::RESULT async_operation::execute(async_operation_ptr this_ptr,
waiter& wait)
{
@@ -159,6 +160,7 @@
//the thread needs access to the mutex before it terminates
{
const lock l(get_mutex());
+ active_.push_back(this_ptr);
thread_.reset(new thread(run_async_operation,&this_ptr));
bool completed = false;
Modified: trunk/src/thread.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/thread.hpp?rev=29292&r1=29291&r2=29292&view=diff
==============================================================================
--- trunk/src/thread.hpp (original)
+++ trunk/src/thread.hpp Fri Sep 5 11:59:25 2008
@@ -17,6 +17,8 @@
#include "SDL.h"
#include "SDL_thread.h"
+
+#include <list>
#include <boost/scoped_ptr.hpp>
#include <boost/smart_ptr.hpp>
@@ -197,6 +199,8 @@
typedef boost::shared_ptr<async_operation> async_operation_ptr;
+typedef std::list<async_operation_ptr> active_operation_list;
+
//class which defines an asynchronous operation. Objects of this class are
accessed from
//both the worker thread and the calling thread, and so it has 'strange'
allocation semantics.
//It is allocated by the caller, and generally deleted by the caller. However,
in some cases
@@ -213,7 +217,11 @@
enum RESULT { COMPLETED, ABORTED };
async_operation() :
- thread_(), aborted_(false), finished_(), finishedVar_(false),
mutex_() {}
+ thread_(), aborted_(false), finished_(), finishedVar_(false),
mutex_()
+ {
+ while (active_.front().unique())
+ active_.pop_front();
+ }
virtual ~async_operation() {}
RESULT execute(async_operation_ptr this_ptr, waiter& wait);
@@ -237,6 +245,8 @@
condition finished_;
bool finishedVar_;
mutex mutex_;
+
+ static active_operation_list active_;
};
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits