--- a/src/core/model/system-thread.h Sun Dec 07 22:08:04 2014 -0800
+++ b/src/core/model/system-thread.h Tue Dec 09 13:17:49 2014 -0800
@@ -27,9 +27,16 @@
#include <pthread.h>
#endif /* HAVE_PTHREAD_H */
+/**
+ * @file
+ * @ingroup thread
+ * System-independent thread class ns3::SystemThread declaration.
+ */
+
namespace ns3 {
/**
+ * @ingroup thread
* @brief A class which provides a relatively platform-independent thread
* primitive.
*
@@ -43,12 +50,15 @@
* execution.
*
* Synchronization between threads is provided via the SystemMutex class.
+ *
+ * See @ref main-test-sync.cc for example usage.
*/
class SystemThread : public SimpleRefCount<SystemThread>
{
public:
#ifdef HAVE_PTHREAD_H
+ /** Type alias for the system-dependent thread object. */
typedef pthread_t ThreadId;
#endif
@@ -67,36 +77,39 @@
*
* The most common use is expected to be creating a thread of execution in
* a method. In this case you would use code similar to,
- *
+ * @code
* MyClass myObject;
* Ptr<SystemThread> st = Create<SystemThread> (
* MakeCallback (&MyClass::MyMethod, &myObject));
* st->Start ();
+ * @endcode
*
* The SystemThread is passed a callback that calls out to the function
- * MyClass::MyMethod. When this function is called, it is called as an
- * object method on the myObject object. Essentially what you are doing
- * is asking the SystemThread to call object->MyMethod () in a new thread
+ * @c MyClass::MyMethod. When this function is called, it is called as an
+ * object method on the @c myObject object. Essentially what you are doing
+ * is asking the SystemThread to call @c object->MyMethod() in a new thread
* of execution.
*
* If starting a thread in your currently executing object, you can use the
* "this" pointer:
- *
+ * @code
* Ptr<SystemThread> st = Create<SystemThread> (
* MakeCallback (&MyClass::MyMethod, this));
* st->Start ();
+ * @endcode
*
* Object lifetime is always an issue with threads, so it is common to use
* smart pointers. If you are spinning up a thread in an object that is
* managed by a smart pointer, you can use that pointer directly:
- *
+ * @code
* Ptr<MyClass> myPtr = Create<MyClass> ();
* Ptr<SystemThread> st = Create<SystemThread> (
* MakeCallback (&MyClass::MyMethod, myPtr));
* st->Start ();
+ * @endcode
*
* Just like any thread, you can synchronize with its termination. The
- * method provided to do this is Join (). If you call Join() you will block
+ * method provided to do this is Join(). If you call Join() you will block
* until the SystemThread run method returns.
*
* @param callback entry point of the thread
@@ -136,18 +149,25 @@
static ThreadId Self(void);
/**
- * @brief Compares an TharedId with the current ThreadId .
+ * @brief Compares an ThreadId with the current ThreadId .
*
- * @returns true if Id matches the current ThreadId.
+ * @param [in] id The ThreadId to compare to.
+ * @returns true if @c id matches the current ThreadId.
*/
static bool Equals(ThreadId id);
private:
#ifdef HAVE_PTHREAD_H
+ /**
+ * Invoke the callback in the new thread.
+ *
+ * @param [in] arg This SystemThread instance to communicate to the newly
+ * launched thread.
+ */
static void *DoRun (void *arg);
- Callback<void> m_callback;
- pthread_t m_thread;
+ Callback<void> m_callback; /**< The main function for this thread when launched. */
+ pthread_t m_thread; /**< The thread id of the child thread. */
#endif
};