1
0
Fork 0

(svn r13411) -Codechange: remove the return value from the thread procs because it is never used.

release/0.7
rubidium 2008-06-08 10:51:36 +00:00
parent b1dc705492
commit 96d7f87cc9
7 changed files with 20 additions and 39 deletions

View File

@ -109,7 +109,7 @@ private:
/** /**
* First function which is called within the fiber. * First function which is called within the fiber.
*/ */
static void * CDECL stFiberProc(void *fiber) static void stFiberProc(void *fiber)
{ {
Fiber_Thread *cur = (Fiber_Thread *)fiber; Fiber_Thread *cur = (Fiber_Thread *)fiber;
/* Now suspend the thread until we get SwitchToFiber() for the first time */ /* Now suspend the thread until we get SwitchToFiber() for the first time */
@ -124,8 +124,6 @@ private:
s_main->m_sem->Set(); s_main->m_sem->Set();
throw; throw;
} }
return NULL;
} }
}; };

View File

@ -85,7 +85,7 @@ bool IsGenerateWorldThreaded()
/** /**
* The internal, real, generate function. * The internal, real, generate function.
*/ */
static void * CDECL _GenerateWorld(void *arg) static void _GenerateWorld(void *arg)
{ {
try { try {
_generating_world = true; _generating_world = true;
@ -170,7 +170,6 @@ static void * CDECL _GenerateWorld(void *arg)
_generating_world = false; _generating_world = false;
throw; throw;
} }
return NULL;
} }
/** /**

View File

@ -1607,10 +1607,9 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
} }
} }
static void * CDECL SaveFileToDiskThread(void *arg) static void SaveFileToDiskThread(void *arg)
{ {
SaveFileToDisk(true); SaveFileToDisk(true);
return NULL;
} }
void WaitTillSaved() void WaitTillSaved()

View File

@ -5,7 +5,7 @@
#ifndef THREAD_H #ifndef THREAD_H
#define THREAD_H #define THREAD_H
typedef void * (CDECL *OTTDThreadFunc)(void *); typedef void (*OTTDThreadFunc)(void *);
/** /**
* A Thread Object which works on all our supported OSes. * A Thread Object which works on all our supported OSes.
@ -37,7 +37,7 @@ public:
/** /**
* Join this thread. * Join this thread.
*/ */
virtual void *Join() = 0; virtual void Join() = 0;
/** /**
* Check if this thread is the current active thread. * Check if this thread is the current active thread.

View File

@ -34,7 +34,6 @@ struct OTTDThreadStartupMessage {
struct Message msg; ///< standard exec.library message (MUST be the first thing in the message struct!) struct Message msg; ///< standard exec.library message (MUST be the first thing in the message struct!)
OTTDThreadFunc func; ///< function the thread will execute OTTDThreadFunc func; ///< function the thread will execute
void *arg; ///< functions arguments for the thread function void *arg; ///< functions arguments for the thread function
void *ret; ///< return value of the thread function
}; };
@ -79,7 +78,6 @@ public:
/* Things we'll pass down to the child by utilizing NP_StartupMsg */ /* Things we'll pass down to the child by utilizing NP_StartupMsg */
m_msg.func = proc; m_msg.func = proc;
m_msg.arg = param; m_msg.arg = param;
m_msg.ret = NULL;
m_replyport = CreateMsgPort(); m_replyport = CreateMsgPort();
@ -161,10 +159,9 @@ public:
return true; return true;
} }
/* virtual */ void *Join() /* virtual */ void Join()
{ {
struct OTTDThreadStartupMessage *reply; struct OTTDThreadStartupMessage *reply;
void *ret;
/* You cannot join yourself */ /* You cannot join yourself */
assert(!IsCurrent()); assert(!IsCurrent());
@ -173,13 +170,9 @@ public:
KPutStr("[OpenTTD] Wait for child to quit...\n"); KPutStr("[OpenTTD] Wait for child to quit...\n");
WaitPort(m_replyport); WaitPort(m_replyport);
reply = (struct OTTDThreadStartupMessage *)GetMsg(m_replyport); GetMsg(m_replyport);
ret = reply->ret;
DeleteMsgPort(m_replyport); DeleteMsgPort(m_replyport);
m_thr = 0; m_thr = 0;
return ret;
} }
/* virtual */ bool IsCurrent() /* virtual */ bool IsCurrent()
@ -209,7 +202,7 @@ private:
if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) { if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) {
try { try {
msg->ret = msg->func(msg->arg); msg->func(msg->arg);
} catch(...) { } catch(...) {
KPutStr("[Child] Returned to main()\n"); KPutStr("[Child] Returned to main()\n");
} }
@ -256,7 +249,7 @@ public:
/* virtual */ void Set() /* virtual */ void Set()
{ {
// Check if semaphore count is really important there. /* Check if semaphore count is really important there. */
ReleaseSemaphore(&m_sem); ReleaseSemaphore(&m_sem);
} }

View File

@ -95,18 +95,15 @@ public:
throw 0; throw 0;
} }
/* virtual */ void *Join() /* virtual */ void Join()
{ {
/* You cannot join yourself */ /* You cannot join yourself */
assert(!IsCurrent()); assert(!IsCurrent());
void *ret; pthread_join(m_thr, NULL);
pthread_join(m_thr, &ret);
m_thr = 0; m_thr = 0;
delete this; delete this;
return ret;
} }
/* virtual */ bool IsCurrent() /* virtual */ bool IsCurrent()
@ -126,14 +123,15 @@ private:
*/ */
static void *stThreadProc(void *thr) static void *stThreadProc(void *thr)
{ {
return ((ThreadObject_pthread *)thr)->ThreadProc(); ((ThreadObject_pthread *)thr)->ThreadProc();
pthread_exit(NULL);
} }
/** /**
* A new thread is created, and this function is called. Call the custom * A new thread is created, and this function is called. Call the custom
* function of the creator of the thread. * function of the creator of the thread.
*/ */
void *ThreadProc() void ThreadProc()
{ {
/* The new thread stops here so the calling thread can complete pthread_create() call */ /* The new thread stops here so the calling thread can complete pthread_create() call */
sem_wait(&m_sem_start); sem_wait(&m_sem_start);
@ -152,8 +150,6 @@ private:
sem_post(&m_sem_stop); sem_post(&m_sem_stop);
if (exit) delete this; if (exit) delete this;
pthread_exit(NULL);
} }
}; };

View File

@ -20,7 +20,6 @@ private:
OTTDThreadFunc m_proc; OTTDThreadFunc m_proc;
void *m_param; void *m_param;
bool m_attached; bool m_attached;
void *ret;
public: public:
/** /**
@ -91,14 +90,12 @@ public:
throw 0; throw 0;
} }
/* virtual */ void *Join() /* virtual */ void Join()
{ {
/* You cannot join yourself */ /* You cannot join yourself */
assert(!IsCurrent()); assert(!IsCurrent());
WaitForSingleObject(m_h_thr, INFINITE); WaitForSingleObject(m_h_thr, INFINITE);
return this->ret;
} }
/* virtual */ bool IsCurrent() /* virtual */ bool IsCurrent()
@ -119,21 +116,20 @@ private:
*/ */
static uint CALLBACK stThreadProc(void *thr) static uint CALLBACK stThreadProc(void *thr)
{ {
return ((ThreadObject_Win32 *)thr)->ThreadProc(); ((ThreadObject_Win32 *)thr)->ThreadProc();
return 0;
} }
/** /**
* A new thread is created, and this function is called. Call the custom * A new thread is created, and this function is called. Call the custom
* function of the creator of the thread. * function of the creator of the thread.
*/ */
uint ThreadProc() void ThreadProc()
{ {
try { try {
this->ret = m_proc(m_param); m_proc(m_param);
} catch (...) { } catch (...) {
} }
return 0;
} }
}; };