Panda3D
Public Member Functions | List of all members
QueuedConnectionReader Class Reference

This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for later receipt by the client code. More...

#include "queuedConnectionReader.h"

Inheritance diagram for QueuedConnectionReader:
ConnectionReader QueuedReturn< NetDatagram >

Public Member Functions

 QueuedConnectionReader (ConnectionManager *manager, int num_threads)
 
bool data_available ()
 Returns true if a datagram is available on the queue; call get_data() to extract the datagram. More...
 
bool get_data (NetDatagram &result)
 If a previous call to data_available() returned true, this function will return the datagram that has become available. More...
 
bool get_data (Datagram &result)
 This flavor of QueuedConnectionReader::get_data(), works like the other, except that it only fills a Datagram object, not a NetDatagram object. More...
 
- Public Member Functions inherited from ConnectionReader
 ConnectionReader (ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
 Creates a new ConnectionReader with the indicated number of threads to handle requests. More...
 
bool add_connection (Connection *connection)
 Adds a new socket to the list of sockets the ConnectionReader will monitor. More...
 
ConnectionManagerget_manager () const
 Returns a pointer to the ConnectionManager object that serves this ConnectionReader. More...
 
int get_num_threads () const
 Returns the number of threads the ConnectionReader has been created with. More...
 
bool get_raw_mode () const
 Returns the current setting of the raw mode flag. More...
 
int get_tcp_header_size () const
 Returns the current setting of TCP header size. More...
 
bool is_connection_ok (Connection *connection)
 Returns true if the indicated connection has been added to the ConnectionReader and is being monitored properly, false if it is not known, or if there was some error condition detected on the connection. More...
 
bool is_polling () const
 Returns true if the reader is a polling reader, i.e. More...
 
void poll ()
 Explicitly polls the available sockets to see if any of them have any noise. More...
 
bool remove_connection (Connection *connection)
 Removes a socket from the list of sockets being monitored. More...
 
void set_raw_mode (bool mode)
 Sets the ConnectionReader into raw mode (or turns off raw mode). More...
 
void set_tcp_header_size (int tcp_header_size)
 Sets the header size of TCP packets. More...
 
void shutdown ()
 Terminates all threads cleanly. More...
 
- Public Member Functions inherited from QueuedReturn< NetDatagram >
int get_current_queue_size () const
 Returns the current number of things in the queue. More...
 
int get_max_queue_size () const
 Returns the maximum size the queue is allowed to grow to. More...
 
bool get_overflow_flag () const
 Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that some elements have been dropped from the queue), or false otherwise. More...
 
void reset_overflow_flag ()
 Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs. More...
 
void set_max_queue_size (int max_size)
 Sets the maximum size the queue is allowed to grow to. More...
 

Detailed Description

This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for later receipt by the client code.

This class is useful for client code that doesn't want to deal with threading and is willing to poll for datagrams at its convenience.

Definition at line 33 of file queuedConnectionReader.h.

Member Function Documentation

◆ data_available()

bool QueuedConnectionReader::data_available ( )

Returns true if a datagram is available on the queue; call get_data() to extract the datagram.

Definition at line 50 of file queuedConnectionReader.cxx.

References ConnectionReader::poll().

Referenced by MayaToEggServer::poll(), and DirectD::wait_for_servers().

◆ get_data() [1/2]

bool QueuedConnectionReader::get_data ( NetDatagram result)

If a previous call to data_available() returned true, this function will return the datagram that has become available.

The return value is true if a datagram was successfully returned, or false if there was, in fact, no datagram available. (This may happen if there are multiple threads accessing the QueuedConnectionReader).

Definition at line 67 of file queuedConnectionReader.cxx.

Referenced by MayaToEggServer::poll(), and DirectD::wait_for_servers().

◆ get_data() [2/2]

bool QueuedConnectionReader::get_data ( Datagram result)

This flavor of QueuedConnectionReader::get_data(), works like the other, except that it only fills a Datagram object, not a NetDatagram object.

This means that the Datagram cannot be queried for its source Connection and/or NetAddress, but it is useful in all other respects.

Definition at line 78 of file queuedConnectionReader.cxx.


The documentation for this class was generated from the following files: