From 13d1f953262fa3bc2866e652387384554811bb07 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 23 Jan 2004 00:14:47 +0000 Subject: [PATCH] add Thread::interrupt --- panda/src/express/thread.I | 14 ++++++++++++++ panda/src/express/thread.h | 1 + panda/src/express/threadDummyImpl.I | 9 +++++++++ panda/src/express/threadDummyImpl.h | 1 + panda/src/express/threadNsprImpl.cxx | 12 ++++++++++++ panda/src/express/threadNsprImpl.h | 1 + 6 files changed, 38 insertions(+) diff --git a/panda/src/express/thread.I b/panda/src/express/thread.I index bfb911b833..17e5563ad9 100644 --- a/panda/src/express/thread.I +++ b/panda/src/express/thread.I @@ -95,6 +95,20 @@ start(ThreadPriority priority, bool global, bool joinable) { return _started; } +//////////////////////////////////////////////////////////////////// +// Function: Thread::interrupt +// Access: Public +// Description: Sends an interrupt message to the thread. This will +// interrupt any blocking-type system calls the thread +// may be waiting on, such as I/O, so that the thread +// may continue some other processing. The specific +// behavior is implementation dependent. +//////////////////////////////////////////////////////////////////// +INLINE void Thread:: +interrupt() { + _impl.interrupt(); +} + //////////////////////////////////////////////////////////////////// // Function: Thread::join // Access: Public diff --git a/panda/src/express/thread.h b/panda/src/express/thread.h index 7df684f078..d98a9ccecb 100644 --- a/panda/src/express/thread.h +++ b/panda/src/express/thread.h @@ -53,6 +53,7 @@ public: INLINE const string &get_name() const; INLINE bool start(ThreadPriority priority, bool global, bool joinable); + INLINE void interrupt(); INLINE void join(); INLINE static void prepare_for_exit(); diff --git a/panda/src/express/threadDummyImpl.I b/panda/src/express/threadDummyImpl.I index 08eefa67ff..f6703ba2d3 100644 --- a/panda/src/express/threadDummyImpl.I +++ b/panda/src/express/threadDummyImpl.I @@ -45,6 +45,15 @@ start(ThreadPriority, bool, bool) { return false; } +//////////////////////////////////////////////////////////////////// +// Function: ThreadDummyImpl::interrupt +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void ThreadDummyImpl:: +interrupt() { +} + //////////////////////////////////////////////////////////////////// // Function: ThreadDummyImpl::join // Access: Public diff --git a/panda/src/express/threadDummyImpl.h b/panda/src/express/threadDummyImpl.h index bf1afd8334..c114225360 100644 --- a/panda/src/express/threadDummyImpl.h +++ b/panda/src/express/threadDummyImpl.h @@ -48,6 +48,7 @@ public: INLINE ~ThreadDummyImpl(); INLINE bool start(ThreadPriority priority, bool global, bool joinable); + INLINE void interrupt(); INLINE void join(); INLINE static void prepare_for_exit(); diff --git a/panda/src/express/threadNsprImpl.cxx b/panda/src/express/threadNsprImpl.cxx index 0b79ea808d..e4f48d0fca 100644 --- a/panda/src/express/threadNsprImpl.cxx +++ b/panda/src/express/threadNsprImpl.cxx @@ -155,6 +155,18 @@ start(ThreadPriority priority, bool global, bool joinable) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: ThreadNsprImpl::interrupt +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void ThreadNsprImpl:: +interrupt() { + if (_thread != (PRThread *)NULL) { + PR_Interrupt(_thread); + } +} + //////////////////////////////////////////////////////////////////// // Function: ThreadNsprImpl::join // Access: Public diff --git a/panda/src/express/threadNsprImpl.h b/panda/src/express/threadNsprImpl.h index f5f1db35eb..2b4e0b3ea4 100644 --- a/panda/src/express/threadNsprImpl.h +++ b/panda/src/express/threadNsprImpl.h @@ -43,6 +43,7 @@ public: INLINE ~ThreadNsprImpl(); bool start(ThreadPriority priority, bool global, bool joinable); + void interrupt(); void join(); INLINE static void prepare_for_exit();