|
|
| 84 |
* method provided to do this is Join (). If you call Join() you will block |
84 |
* method provided to do this is Join (). If you call Join() you will block |
| 85 |
* until the SystemThread run method returns. |
85 |
* until the SystemThread run method returns. |
| 86 |
* |
86 |
* |
|
|
87 |
* @warning The SystemThread uses SIGALRM to wake threads that are possibly |
| 88 |
* blocked on IO. |
| 89 |
* @see Shutdown |
| 90 |
* |
| 87 |
* @warning I've made the system thread class look like a normal ns3 object |
91 |
* @warning I've made the system thread class look like a normal ns3 object |
| 88 |
* with smart pointers, and living in the heap. This makes it very easy to |
92 |
* with smart pointers, and living in the heap. This makes it very easy to |
| 89 |
* manage threads from a single master thread context. You should be very |
93 |
* manage threads from a single master thread context. You should be very |
|
|
| 128 |
*/ |
132 |
*/ |
| 129 |
void Join (void); |
133 |
void Join (void); |
| 130 |
|
134 |
|
|
|
135 |
/** |
| 136 |
* @brief Indicates to a managed thread doing cooperative multithreading that |
| 137 |
* its managing thread wants it to exit. |
| 138 |
* |
| 139 |
* It is often the case that we want a thread to be off doing work until such |
| 140 |
* time as its job is done (typically when the simulation is done). We then |
| 141 |
* want the thread to exit itself. This method provides a consistent way for |
| 142 |
* the managing thread to communicate with the managed thread. After the |
| 143 |
* manager thread calls this method, the Break() method will begin returning |
| 144 |
* true, telling the managed thread to exit. |
| 145 |
* |
| 146 |
* This alone isn't really enough to merit these events, but in Unix, if a |
| 147 |
* worker thread is doing blocking IO, it will need to be woken up from that |
| 148 |
* read somehow. This method also provides that functionality, by sending a |
| 149 |
* SIGALRM signal to the possibly blocked thread. |
| 150 |
* |
| 151 |
* @see Break |
| 152 |
* @returns true if thread is expected to exit |
| 153 |
*/ |
| 154 |
void Shutdown (void); |
| 155 |
|
| 156 |
/** |
| 157 |
* @brief Indicates to a thread doing cooperative multithreading that |
| 158 |
* its managing thread wants it to exit. |
| 159 |
* |
| 160 |
* It is often the case that we want a thread to be off doing work until such |
| 161 |
* time as its job is done. We then want the thread to exit itself. This |
| 162 |
* method allows a thread to query whether or not it should be running. |
| 163 |
* Typically, the worker thread is running in a forever-loop, and will need to |
| 164 |
* "break" out of that loop to exit -- thus the name. |
| 165 |
* |
| 166 |
* @see Shutdown |
| 167 |
* @returns true if thread is expected to exit (break out of the forever-loop) |
| 168 |
*/ |
| 169 |
bool Break (void); |
| 170 |
|
| 131 |
private: |
171 |
private: |
| 132 |
SystemThreadImpl * m_impl; |
172 |
SystemThreadImpl * m_impl; |
| 133 |
mutable uint32_t m_count; |
173 |
mutable uint32_t m_count; |
|
|
174 |
bool m_break; |
| 134 |
}; |
175 |
}; |
| 135 |
|
176 |
|
| 136 |
void |
177 |
void |