23 _cvlock(
"DatagramQueue::_cvlock"),
27 _max_queue_size = get_net_max_write_queue();
69 bool enqueue_ok = ((int)_queue.size() < _max_queue_size);
71 while (!enqueue_ok && !_shutdown) {
73 enqueue_ok = ((int)_queue.size() < _max_queue_size);
78 _queue.push_back(data);
106 while (_queue.empty() && !_shutdown) {
114 nassertr(!_queue.empty(),
false);
115 result = _queue.front();
135 _max_queue_size = max_size;
144 return _max_queue_size;
153 int size = _queue.size();
void set_max_queue_size(int max_size)
Sets the maximum size the queue is allowed to grow to.
A specific kind of Datagram, especially for sending across or receiving from a network.
bool insert(const NetDatagram &data, bool block=false)
Inserts the indicated datagram onto the end of the queue, and returns.
void notify()
Informs one of the other threads who are currently blocked on wait() that the relevant condition has ...
void wait()
Waits on the condition.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
void notify_all()
Informs all of the other threads who are currently blocked on wait() that the relevant condition has ...
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool extract(NetDatagram &result)
Extracts a datagram from the head of the queue, if one is available.
int get_max_queue_size() const
Returns the maximum size the queue is allowed to grow to.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void shutdown()
Marks the queue as shutting down, which will eventually cause all threads blocking on extract() to re...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_current_queue_size() const
Returns the current number of things in the queue.