Changeset - r10688:9e216b0bd8ab
[Not reviewed]
master
0 4 0
truebrain - 15 years ago 2009-01-12 14:31:49
truebrain@openttd.org
(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)
4 files changed with 12 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/thread.h
Show inline comments
 
@@ -7,6 +7,8 @@
 

	
 
typedef void (*OTTDThreadFunc)(void *);
 

	
 
class OTTDThreadExitSignal { };
 

	
 
/**
 
 * A Thread Object which works on all our supported OSes.
 
 */
src/thread_morphos.cpp
Show inline comments
 
@@ -153,7 +153,7 @@ public:
 

	
 
		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 */
 
			throw 0;
 
			throw OTTDThreadExitSignal();
 
		}
 

	
 
		return true;
 
@@ -203,8 +203,10 @@ private:
 
		if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) {
 
			try {
 
				msg->func(msg->arg);
 
			} catch(OTTDThreadExitSignal e) {
 
				KPutStr("[Child] Returned to main()\n");
 
			} catch(...) {
 
				KPutStr("[Child] Returned to main()\n");
 
				NOT_REACHED();
 
			}
 
		}
 

	
src/thread_pthread.cpp
Show inline comments
 
@@ -92,7 +92,7 @@ public:
 
		if (!IsRunning()) return false;
 

	
 
		/* For now we terminate by throwing an error, gives much cleaner cleanup */
 
		throw 0;
 
		throw OTTDThreadExitSignal();
 
	}
 

	
 
	/* virtual */ void Join()
 
@@ -137,7 +137,9 @@ private:
 
		/* Call the proc of the creator to continue this thread */
 
		try {
 
			m_proc(m_param);
 
		} catch (OTTDThreadExitSignal e) {
 
		} catch (...) {
 
			NOT_REACHED();
 
		}
 

	
 
		/* Notify threads waiting for our completion */
src/thread_win32.cpp
Show inline comments
 
@@ -87,7 +87,7 @@ public:
 
		if (!IsRunning()) return false;
 

	
 
		/* For now we terminate by throwing an error, gives much cleaner cleanup */
 
		throw 0;
 
		throw OTTDThreadExitSignal();
 
	}
 

	
 
	/* virtual */ void Join()
 
@@ -128,7 +128,9 @@ private:
 
	{
 
		try {
 
			m_proc(m_param);
 
		} catch (OTTDThreadExitSignal) {
 
		} catch (...) {
 
			NOT_REACHED();
 
		}
 
	}
 
};
0 comments (0 inline, 0 general)