equal
deleted
inserted
replaced
80 // We're going to spin up a thread soon, so we need to make sure we have |
80 // We're going to spin up a thread soon, so we need to make sure we have |
81 // a way to tear down that thread when the simulation stops. Do this by |
81 // a way to tear down that thread when the simulation stops. Do this by |
82 // scheduling a "destroy time" method to make sure the thread exits before |
82 // scheduling a "destroy time" method to make sure the thread exits before |
83 // proceeding. |
83 // proceeding. |
84 // |
84 // |
85 if (! m_destroyEvent.IsRunning ()) |
85 if (!m_destroyEvent.IsRunning ()) |
86 { |
86 { |
87 // hold a reference to ensure that this object is not |
87 // hold a reference to ensure that this object is not |
88 // deallocated before the destroy-time event fires |
88 // deallocated before the destroy-time event fires |
89 this->Ref (); |
89 this->Ref (); |
90 m_destroyEvent = |
90 m_destroyEvent = |
160 |
160 |
161 r = select (nfds, &readfds, NULL, NULL, NULL); |
161 r = select (nfds, &readfds, NULL, NULL, NULL); |
162 if (r == -1 && errno != EINTR) |
162 if (r == -1 && errno != EINTR) |
163 { |
163 { |
164 NS_FATAL_ERROR ("select() failed: " << strerror (errno)); |
164 NS_FATAL_ERROR ("select() failed: " << strerror (errno)); |
165 } |
165 } |
166 |
166 |
167 if (FD_ISSET (m_evpipe[0], &readfds)) |
167 if (FD_ISSET (m_evpipe[0], &readfds)) |
168 { |
168 { |
169 // drain the event pipe |
169 // drain the event pipe |
170 ssize_t len; |
170 ssize_t len; |
185 if (len < 0 && errno != EAGAIN && errno != EWOULDBLOCK) |
185 if (len < 0 && errno != EAGAIN && errno != EWOULDBLOCK) |
186 { |
186 { |
187 NS_LOG_WARN ("read() failed: " << strerror (errno)); |
187 NS_LOG_WARN ("read() failed: " << strerror (errno)); |
188 break; |
188 break; |
189 } |
189 } |
190 } |
190 } |
191 |
191 |
192 if (m_stop) |
192 if (m_stop) |
193 { |
193 { |
194 // this thread is done |
194 // this thread is done |
195 break; |
195 break; |