mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r15006) -Codechange: throw a real instance of a class, instead of '0' (which can also be a throw from within a thread for what ever reason)
This commit is contained in:
parent
7947e78daa
commit
53ca48efe2
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
typedef void (*OTTDThreadFunc)(void *);
|
typedef void (*OTTDThreadFunc)(void *);
|
||||||
|
|
||||||
|
class OTTDThreadExitSignal { };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Thread Object which works on all our supported OSes.
|
* A Thread Object which works on all our supported OSes.
|
||||||
*/
|
*/
|
||||||
|
@ -153,7 +153,7 @@ public:
|
|||||||
|
|
||||||
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) {
|
||||||
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
||||||
throw 0;
|
throw OTTDThreadExitSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -203,8 +203,10 @@ 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->func(msg->arg);
|
msg->func(msg->arg);
|
||||||
} catch(...) {
|
} catch(OTTDThreadExitSignal e) {
|
||||||
KPutStr("[Child] Returned to main()\n");
|
KPutStr("[Child] Returned to main()\n");
|
||||||
|
} catch(...) {
|
||||||
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
if (!IsRunning()) return false;
|
if (!IsRunning()) return false;
|
||||||
|
|
||||||
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
||||||
throw 0;
|
throw OTTDThreadExitSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ void Join()
|
/* virtual */ void Join()
|
||||||
@ -137,7 +137,9 @@ private:
|
|||||||
/* Call the proc of the creator to continue this thread */
|
/* Call the proc of the creator to continue this thread */
|
||||||
try {
|
try {
|
||||||
m_proc(m_param);
|
m_proc(m_param);
|
||||||
|
} catch (OTTDThreadExitSignal e) {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify threads waiting for our completion */
|
/* Notify threads waiting for our completion */
|
||||||
|
@ -87,7 +87,7 @@ public:
|
|||||||
if (!IsRunning()) return false;
|
if (!IsRunning()) return false;
|
||||||
|
|
||||||
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
/* For now we terminate by throwing an error, gives much cleaner cleanup */
|
||||||
throw 0;
|
throw OTTDThreadExitSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ void Join()
|
/* virtual */ void Join()
|
||||||
@ -128,7 +128,9 @@ private:
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
m_proc(m_param);
|
m_proc(m_param);
|
||||||
|
} catch (OTTDThreadExitSignal) {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user