# HG changeset patch # User Mathieu Lacage # Date 1293652796 28800 # Node ID 766d0bf91ab37645dcf259541fbd6fc78da67175 # Parent 9b8db14aeb3bd9ac392caad7fd00af3131b78d5e kill SystemThread::Shutdown and SystemThread::Break methods diff -r 9b8db14aeb3b -r 766d0bf91ab3 src/core/system-thread.h --- a/src/core/system-thread.h Wed Dec 29 11:58:59 2010 -0800 +++ b/src/core/system-thread.h Wed Dec 29 11:59:56 2010 -0800 @@ -96,7 +96,6 @@ * * @warning The SystemThread uses SIGALRM to wake threads that are possibly * blocked on IO. - * @see Shutdown * * @warning I've made the system thread class look like a normal ns3 object * with smart pointers, and living in the heap. This makes it very easy to @@ -126,46 +125,8 @@ */ void Join (void); - /** - * @brief Indicates to a managed thread doing cooperative multithreading that - * its managing thread wants it to exit. - * - * It is often the case that we want a thread to be off doing work until such - * time as its job is done (typically when the simulation is done). We then - * want the thread to exit itself. This method provides a consistent way for - * the managing thread to communicate with the managed thread. After the - * manager thread calls this method, the Break() method will begin returning - * true, telling the managed thread to exit. - * - * This alone isn't really enough to merit these events, but in Unix, if a - * worker thread is doing blocking IO, it will need to be woken up from that - * read somehow. This method also provides that functionality, by sending a - * SIGALRM signal to the possibly blocked thread. - * - * @warning Uses SIGALRM to notify threads possibly blocked on IO. Beware - * if you are using signals. - * @see Break - */ - void Shutdown (void); - - /** - * @brief Indicates to a thread doing cooperative multithreading that - * its managing thread wants it to exit. - * - * It is often the case that we want a thread to be off doing work until such - * time as its job is done. We then want the thread to exit itself. This - * method allows a thread to query whether or not it should be running. - * Typically, the worker thread is running in a forever-loop, and will need to - * "break" out of that loop to exit -- thus the name. - * - * @see Shutdown - * @returns true if thread is expected to exit (break out of the forever-loop) - */ - bool Break (void); - private: SystemThreadImpl * m_impl; - bool m_break; }; } //namespace ns3 diff -r 9b8db14aeb3b -r 766d0bf91ab3 src/core/unix-system-thread.cc --- a/src/core/unix-system-thread.cc Wed Dec 29 11:58:59 2010 -0800 +++ b/src/core/unix-system-thread.cc Wed Dec 29 11:59:56 2010 -0800 @@ -50,28 +50,18 @@ void Start (void); void Join (void); - void Shutdown (void); - bool Break (void); private: static void *DoRun (void *arg); Callback m_callback; pthread_t m_thread; - bool m_break; void * m_ret; }; SystemThreadImpl::SystemThreadImpl (Callback callback) - : m_callback (callback), m_break (false) + : m_callback (callback) { NS_LOG_FUNCTION_NOARGS (); - // Make sure we have a SIGALRM handler which does not terminate - // our process. - struct sigaction act; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - act.sa_handler = SIG_IGN; - sigaction (SIGALRM, &act, 0); } void @@ -103,26 +93,6 @@ } } - void -SystemThreadImpl::Shutdown (void) -{ - NS_LOG_FUNCTION_NOARGS (); - - m_break = true; - - // send a SIGALRM signal on the target thread to make sure that it - // will unblock. - pthread_kill (m_thread, SIGALRM); -} - - bool -SystemThreadImpl::Break (void) -{ - NS_LOG_FUNCTION_NOARGS (); - - return m_break; -} - void * SystemThreadImpl::DoRun (void *arg) { @@ -141,7 +111,7 @@ // class above. // SystemThread::SystemThread (Callback callback) - : m_impl (new SystemThreadImpl (callback)), m_break (false) + : m_impl (new SystemThreadImpl (callback)) { NS_LOG_FUNCTION_NOARGS (); } @@ -166,18 +136,4 @@ m_impl->Join (); } - void -SystemThread::Shutdown (void) -{ - NS_LOG_FUNCTION_NOARGS (); - m_impl->Shutdown (); -} - - bool -SystemThread::Break (void) -{ - NS_LOG_FUNCTION_NOARGS (); - return m_impl->Break (); -} - } // namespace ns3