Panda3D
|
This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection. More...
#include "datagramGeneratorNet.h"
Public Member Functions | |
DatagramGeneratorNet (ConnectionManager *manager, int num_threads) | |
Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests. | |
virtual bool | get_datagram (Datagram &data) |
Reads the next datagram from the stream. | |
virtual bool | is_eof () |
Returns true if the stream has been closed normally. | |
virtual bool | is_error () |
Returns true if the stream has an error condition. | |
Protected Member Functions | |
virtual void | receive_datagram (const NetDatagram &datagram) |
An internal function called by ConnectionReader() when a new datagram has become available. | |
Protected Attributes | |
Mutex | _dg_lock |
ConditionVar | _dg_processed |
ConditionVar | _dg_received |
This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection.
If a datagram is not available, get_datagram() will block until one is.
Definition at line 35 of file datagramGeneratorNet.h.
DatagramGeneratorNet::DatagramGeneratorNet | ( | ConnectionManager * | manager, |
int | num_threads | ||
) |
Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests.
Normally num_threads should be either 0 or 1 to guarantee that datagrams are generated in the same order in which they were received.
Definition at line 31 of file datagramGeneratorNet.cxx.
bool DatagramGeneratorNet::get_datagram | ( | Datagram & | data | ) | [virtual] |
Reads the next datagram from the stream.
Blocks until a datagram is available. Returns true on success, false on stream closed or error.
Implements DatagramGenerator.
Definition at line 55 of file datagramGeneratorNet.cxx.
References Thread::force_yield(), Datagram::get_length(), QueuedReturn< Datagram >::get_thing(), is_eof(), ConnectionReader::is_polling(), ConditionVarDirect::notify(), ConnectionReader::poll(), QueuedReturn< Datagram >::thing_available(), and ConditionVarDirect::wait().
bool DatagramGeneratorNet::is_eof | ( | ) | [virtual] |
Returns true if the stream has been closed normally.
This test may only be made after a call to get_datagram() has failed.
Implements DatagramGenerator.
Definition at line 119 of file datagramGeneratorNet.cxx.
Referenced by get_datagram().
bool DatagramGeneratorNet::is_error | ( | ) | [virtual] |
Returns true if the stream has an error condition.
Implements DatagramGenerator.
Definition at line 131 of file datagramGeneratorNet.cxx.
void DatagramGeneratorNet::receive_datagram | ( | const NetDatagram & | datagram | ) | [protected, virtual] |
An internal function called by ConnectionReader() when a new datagram has become available.
This call may be received in a sub-thread.
Implements ConnectionReader.
Definition at line 153 of file datagramGeneratorNet.cxx.
References QueuedReturn< Datagram >::enqueue_thing(), ConditionVarDirect::notify(), and ConditionVarDirect::wait().