|
|
| 57 |
{ |
57 |
{ |
| 58 |
public: |
58 |
public: |
| 59 |
|
59 |
|
| 60 |
#ifdef HAVE_PTHREAD_H |
60 |
#ifndef HAVE_PTHREAD_H |
|
|
61 |
// This minimal implementation is needed for to support compilation |
| 62 |
// of the thread-safe Schedule implementation, on systems without |
| 63 |
// thread support. |
| 64 |
|
| 65 |
/** |
| 66 |
* Fallback type alias for thread objects |
| 67 |
* on systems without thread support. |
| 68 |
*/ |
| 69 |
typedef void * ThreadId; |
| 70 |
|
| 71 |
/** |
| 72 |
* @brief Returns the default thread Id on systems without thread support. |
| 73 |
* |
| 74 |
* @returns Default thread Id. |
| 75 |
*/ |
| 76 |
static ThreadId Self(void) { return 0; }; |
| 77 |
|
| 78 |
/** |
| 79 |
* @brief Compares ThreadIds on systems without thread support. |
| 80 |
* |
| 81 |
* @param [in] id The ThreadId to compare to. |
| 82 |
* @returns @c true if @c id matches the current ThreadId. |
| 83 |
*/ |
| 84 |
static bool Equals(ThreadId id) { return true; }; |
| 85 |
|
| 86 |
#else /* HAVE_PTHREAD_H */ |
| 61 |
/** Type alias for the system-dependent thread object. */ |
87 |
/** Type alias for the system-dependent thread object. */ |
| 62 |
typedef pthread_t ThreadId; |
88 |
typedef pthread_t ThreadId; |
| 63 |
#endif |
|
|
| 64 |
|
89 |
|
| 65 |
/** |
90 |
/** |
| 66 |
* @brief Create a SystemThread object. |
91 |
* @brief Create a SystemThread object. |
|
|
| 157 |
static bool Equals(ThreadId id); |
182 |
static bool Equals(ThreadId id); |
| 158 |
|
183 |
|
| 159 |
private: |
184 |
private: |
| 160 |
#ifdef HAVE_PTHREAD_H |
185 |
|
| 161 |
/** |
186 |
/** |
| 162 |
* Invoke the callback in the new thread. |
187 |
* Invoke the callback in the new thread. |
| 163 |
* |
188 |
* |
|
|
| 168 |
|
193 |
|
| 169 |
Callback<void> m_callback; /**< The main function for this thread when launched. */ |
194 |
Callback<void> m_callback; /**< The main function for this thread when launched. */ |
| 170 |
pthread_t m_thread; /**< The thread id of the child thread. */ |
195 |
pthread_t m_thread; /**< The thread id of the child thread. */ |
| 171 |
#endif |
196 |
|
| 172 |
}; |
197 |
#endif /* HAVE_PTHREAD_H */ |
|
|
198 |
}; // class SystemThread |
| 173 |
|
199 |
|
| 174 |
} // namespace ns3 |
200 |
} // namespace ns3 |
| 175 |
|
201 |
|