--- a/src/core/model/unix-fd-reader.h Sun Dec 07 22:08:04 2014 -0800
+++ b/src/core/model/unix-fd-reader.h Tue Dec 09 13:17:49 2014 -0800
@@ -27,9 +27,16 @@
#include "system-thread.h"
#include "event-id.h"
+/**
+ * \ingroup system
+ * \file
+ * Asynchronous reads from a file descriptor, which trigger a Callback.
+ */
+
namespace ns3 {
/**
+ * \ingroup system
* \brief A class that asynchronously reads from a file descriptor.
*
* This class can be used to start a system thread that reads from a
@@ -40,7 +47,9 @@
class FdReader : public SimpleRefCount<FdReader>
{
public:
+ /** Constructor. */
FdReader();
+ /** Destructor. */
virtual ~FdReader();
/**
@@ -66,9 +75,18 @@
*/
struct Data
{
+ /** Default constructor, with null buffer and zero length. */
Data () : m_buf (0), m_len (0) {}
+ /**
+ * Construct from a buffer of a given length.
+ *
+ * \param buf The buffer.
+ * \param len The size of the buffer, in bytes.
+ */
Data (uint8_t *buf, ssize_t len) : m_buf (buf), m_len (len) {}
+ /** The read data buffer. */
uint8_t *m_buf;
+ /** The size of the read data buffer, in bytes. */
ssize_t m_len;
};
@@ -94,13 +112,26 @@
private:
+ /** The asynchronous function which performs the read. */
void Run (void);
+ /** Event handler scheduled for destroy time to halt the thread. */
void DestroyEvent (void);
+ /** The main thread callback function to invoke when we have data. */
Callback<void, uint8_t *, ssize_t> m_readCallback;
+
+ /** The thread doing the read, created and launched by Start(). */
Ptr<SystemThread> m_readThread;
- int m_evpipe[2]; // pipe used to signal events between threads
- bool m_stop; // true means the read thread should stop
+
+ /** Pipe used to signal events between threads. */
+ int m_evpipe[2];
+ /** Signal the read thread to stop. */
+ bool m_stop;
+
+ /**
+ * The event scheduled for destroy time which will invoke DestroyEvent
+ * and halt the thread.
+ */
EventId m_destroyEvent;
};