summaryrefslogtreecommitdiff
path: root/src/thread_pthread.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-06-08 15:27:57 +0000
committerrubidium <rubidium@openttd.org>2008-06-08 15:27:57 +0000
commitf80d8dbe0c212858ab2380c3d7b65643eb576cc1 (patch)
tree376004aeb09d74a071fcdddcc61f01e9ea005d8b /src/thread_pthread.cpp
parentb830e6c714453385c004ac59859b1cd5d44eaeb3 (diff)
downloadopenttd-f80d8dbe0c212858ab2380c3d7b65643eb576cc1.tar.xz
(svn r13417) -Fix (r12945, r13413): freeing the ThreadObjects in a manner that hopefully doesn't cause crashes.
Diffstat (limited to 'src/thread_pthread.cpp')
-rw-r--r--src/thread_pthread.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/thread_pthread.cpp b/src/thread_pthread.cpp
index 617760000..b3f340b6a 100644
--- a/src/thread_pthread.cpp
+++ b/src/thread_pthread.cpp
@@ -22,18 +22,16 @@ private:
bool m_attached; ///< True if the ThreadObject was attached to an existing thread.
sem_t m_sem_start; ///< Here the new thread waits before it starts.
sem_t m_sem_stop; ///< Here the other thread can wait for this thread to end.
- OTTDThreadTerminateFunc m_terminate_func; ///< Function to call on thread termination.
public:
/**
* Create a pthread and start it, calling proc(param).
*/
- ThreadObject_pthread(OTTDThreadFunc proc, void *param, OTTDThreadTerminateFunc terminate_func) :
+ ThreadObject_pthread(OTTDThreadFunc proc, void *param) :
m_thr(0),
m_proc(proc),
m_param(param),
- m_attached(false),
- m_terminate_func(terminate_func)
+ m_attached(false)
{
sem_init(&m_sem_start, 0, 0);
sem_init(&m_sem_stop, 0, 0);
@@ -49,8 +47,7 @@ public:
m_thr(0),
m_proc(NULL),
m_param(0),
- m_attached(true),
- m_terminate_func(NULL)
+ m_attached(true)
{
sem_init(&m_sem_start, 0, 0);
sem_init(&m_sem_stop, 0, 0);
@@ -145,14 +142,12 @@ private:
/* Notify threads waiting for our completion */
sem_post(&m_sem_stop);
-
- if (this->m_terminate_func != NULL) this->m_terminate_func(this);
}
};
-/* static */ ThreadObject *ThreadObject::New(OTTDThreadFunc proc, void *param, OTTDThreadTerminateFunc terminate_func)
+/* static */ ThreadObject *ThreadObject::New(OTTDThreadFunc proc, void *param)
{
- return new ThreadObject_pthread(proc, param, terminate_func);
+ return new ThreadObject_pthread(proc, param);
}
/* static */ ThreadObject *ThreadObject::AttachCurrent()