Browse Source

add Thread::interrupt

David Rose 22 years ago
parent
commit
13d1f95326

+ 14 - 0
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

+ 1 - 0
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();

+ 9 - 0
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

+ 1 - 0
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();

+ 12 - 0
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

+ 1 - 0
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();