15 #include "pandabase.h" 17 #include "datagramGeneratorNet.h" 18 #include "mutexHolder.h" 19 #include "lightMutexHolder.h" 33 _dg_received(_dg_lock),
34 _dg_processed(_dg_lock)
43 DatagramGeneratorNet::
44 ~DatagramGeneratorNet() {
58 if (!thing_available()) {
59 if (net_cat.is_spam()) {
61 <<
"DatagramGeneratorNet polling\n";
65 while (!thing_available()) {
67 if (net_cat.is_spam()) {
69 <<
"DatagramGeneratorNet returning EOF\n";
76 bool got_dg = get_thing(data);
77 nassertr(got_dg,
false);
83 while (!thing_available()) {
85 if (net_cat.is_spam()) {
87 <<
"DatagramGeneratorNet returning EOF\n";
91 if (net_cat.is_spam()) {
93 <<
"DatagramGeneratorNet waiting\n";
97 bool got_dg = get_thing(data);
98 nassertr(got_dg,
false);
102 if (net_cat.is_spam()) {
104 <<
"DatagramGeneratorNet returning datagram of length " 122 return _sockets.empty();
134 Sockets::const_iterator si;
135 for (si = _sockets.begin(); si != _sockets.end(); ++si) {
136 SocketInfo *sinfo = (*si);
152 void DatagramGeneratorNet::
155 while (!enqueue_thing(datagram)) {
156 _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.
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 ...
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.
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 ...
size_t get_length() const
Returns the number of bytes in the datagram.