30 _dg_received(_dg_lock),
31 _dg_processed(_dg_lock)
38 DatagramGeneratorNet::
39 ~DatagramGeneratorNet() {
50 if (!thing_available()) {
51 if (net_cat.is_spam()) {
53 <<
"DatagramGeneratorNet polling\n";
57 while (!thing_available()) {
59 if (net_cat.is_spam()) {
61 <<
"DatagramGeneratorNet returning EOF\n";
68 bool got_dg = get_thing(data);
69 nassertr(got_dg,
false);
74 while (!thing_available()) {
76 if (net_cat.is_spam()) {
78 <<
"DatagramGeneratorNet returning EOF\n";
82 if (net_cat.is_spam()) {
84 <<
"DatagramGeneratorNet waiting\n";
88 bool got_dg = get_thing(data);
89 nassertr(got_dg,
false);
93 if (net_cat.is_spam()) {
95 <<
"DatagramGeneratorNet returning datagram of length " 96 << data.get_length() <<
"\n";
110 return _sockets.empty();
120 Sockets::const_iterator si;
121 for (si = _sockets.begin(); si != _sockets.end(); ++si) {
122 SocketInfo *sinfo = (*si);
135 void DatagramGeneratorNet::
138 while (!enqueue_thing(datagram)) {
139 _dg_processed.
wait();
virtual bool get_datagram(Datagram &data)
Reads the next datagram from the stream.
A specific kind of Datagram, especially for sending across or receiving from a network.
bool is_polling() const
Returns true if the reader is a polling reader, i.e.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The primary interface to the low-level networking layer in this package.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void force_yield()
Suspends the current thread for the rest of the current epoch.
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
void poll()
Explicitly polls the available sockets to see if any of them have any noise.
virtual bool is_eof()
Returns true if the stream has been closed normally.
Similar to MutexHolder, but for a light mutex.
DatagramGeneratorNet(ConnectionManager *manager, int num_threads)
Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests.
virtual bool is_error()
Returns true if the stream has an error condition.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void wait()
Waits on the condition.
void notify()
Informs one of the other threads who are currently blocked on wait() that the relevant condition has ...