ns-3
|
A class that asynchronously reads from a file descriptor. More...
#include <unix-fd-reader.h>
Classes | |
struct | Data |
Public Member Functions | |
void | Start (int fd, Callback< void, uint8_t *, ssize_t > readCallback) |
void | Stop (void) |
![]() | |
SimpleRefCount (const SimpleRefCount &o) | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
uint32_t | GetReferenceCount (void) const |
Protected Member Functions | |
virtual FdReader::Data | DoRead (void)=0 |
Protected Attributes | |
int | m_fd |
Additional Inherited Members | |
![]() | |
static void | Cleanup (void) |
A class that asynchronously reads from a file descriptor.
This class can be used to start a system thread that reads from a given file descriptor and invokes a given callback when data is received. This class handles thread management automatically but the DoRead()
method must be implemented by a subclass.
void ns3::FdReader::Start | ( | int | fd, |
Callback< void, uint8_t *, ssize_t > | readCallback | ||
) |
Start a new read thread.
fd | A valid file descriptor open for reading. |
readCallback | A callback to invoke when new data is available. |
References ns3::EventId::IsRunning(), ns3::MakeCallback(), NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_LOGIC, ns3::SimpleRefCount< FdReader >::Ref(), ns3::Simulator::ScheduleDestroy(), and ns3::SystemThread::Start().
void ns3::FdReader::Stop | ( | void | ) |
Stop the read thread and reset internal state. This does not close the file descriptor used for reading.
References ns3::SystemThread::Join(), and NS_LOG_WARN.