#include <connectionWriter.h>
Public Member Functions | |
ConnectionWriter (ConnectionManager *manager, int num_threads) | |
Creates a new ConnectionWriter with the indicated number of threads to handle output. | |
~ConnectionWriter () | |
bool | send (const Datagram &datagram, const PointerTo< Connection > &connection) |
Enqueues a datagram for transmittal on the indicated socket. | |
bool | send (const Datagram &datagram, const PointerTo< Connection > &connection, const NetAddress &address) |
Enqueues a datagram for transmittal on the indicated socket. | |
bool | is_valid_for_udp (const Datagram &datagram) const |
Returns true if the datagram is small enough to be sent over a UDP packet, false otherwise. | |
ConnectionManager * | get_manager () const |
Returns a pointer to the ConnectionManager object that serves this ConnectionWriter. | |
bool | is_immediate () const |
Returns true if the writer is an immediate writer, i.e. | |
int | get_num_threads () const |
Returns the number of threads the ConnectionWriter has been created with. | |
void | set_raw_mode (bool mode) |
Sets the ConnectionWriter into raw mode (or turns off raw mode). | |
bool | get_raw_mode () const |
Returns the current setting of the raw mode flag. | |
Protected Member Functions | |
void | clear_manager () |
This should normally only be called when the associated ConnectionManager destructs. | |
Protected Attributes | |
ConnectionManager * | _manager |
Private Types | |
typedef pvector< PRThread * > | Threads |
Private Member Functions | |
void | thread_run () |
This is the actual executing function for each thread. | |
bool | send_datagram (const NetDatagram &datagram) |
Static Private Member Functions | |
void | thread_start (void *data) |
The static wrapper around the thread's executing function. | |
Private Attributes | |
bool | _raw_mode |
DatagramQueue | _queue |
Threads | _threads |
bool | _immediate |
Friends | |
class | ConnectionManager |
A ConnectionWriter may define an arbitrary number of threads (at least one) to write its datagrams to sockets. The number of threads is specified at construction time and cannot be changed.
Definition at line 57 of file connectionWriter.h.
|
Definition at line 93 of file connectionWriter.h. |
|
Creates a new ConnectionWriter with the indicated number of threads to handle output. If num_threads is 0, all datagrams will be sent immediately instead of queueing for later transmission by a thread. Definition at line 49 of file connectionWriter.cxx. References ConnectionReader::_threads. |
|
Definition at line 79 of file connectionWriter.cxx. |
|
This should normally only be called when the associated ConnectionManager destructs. It resets the ConnectionManager pointer to NULL so we don't have a floating pointer. This makes the ConnectionWriter invalid; presumably it also will be destructed momentarily. Definition at line 336 of file connectionWriter.cxx. |
|
Returns a pointer to the ConnectionManager object that serves this ConnectionWriter.
Definition at line 237 of file connectionWriter.cxx. References _raw_mode. |
|
Returns the number of threads the ConnectionWriter has been created with.
Definition at line 267 of file connectionWriter.cxx. |
|
Returns the current setting of the raw mode flag. See set_raw_mode(). Definition at line 313 of file connectionWriter.cxx. |
|
Returns true if the writer is an immediate writer, i.e. it has no threads. Definition at line 252 of file connectionWriter.cxx. |
|
Returns true if the datagram is small enough to be sent over a UDP packet, false otherwise.
Definition at line 222 of file connectionWriter.cxx. References _raw_mode. |
|
Enqueues a datagram for transmittal on the indicated socket. This form of the function allows the specification of a destination host address, and so is appropriate for UDP packets. Use the other send() method for sending TCP packets. Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point. Definition at line 182 of file connectionWriter.cxx. References _manager. |
|
Enqueues a datagram for transmittal on the indicated socket. Since the host address is not specified with this form, this function should only be used for sending TCP packets. Use the other send() method for sending UDP packets. Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point. Definition at line 134 of file connectionWriter.cxx. References _queue, Datagram::get_length(), Connection::get_socket(), DatagramQueue::insert(), nassertr, NULL, Connection::send_datagram(), Connection::send_raw_datagram(), NetDatagram::set_address(), and NetDatagram::set_connection(). |
|
|
|
Sets the ConnectionWriter into raw mode (or turns off raw mode). In raw mode, datagrams are not sent along with their headers; the bytes in the datagram are simply sent down the pipe. Setting the ConnectionWriter to raw mode must be done with care. This can only be done when the matching ConnectionReader is also set to raw mode, or when the ConnectionWriter is communicating to a process that does not expect datagrams. Definition at line 298 of file connectionWriter.cxx. Referenced by HTTPClient::HTTPClient(). |
|
This is the actual executing function for each thread.
Definition at line 370 of file connectionWriter.cxx. |
|
The static wrapper around the thread's executing function. This must be a static member function because it is passed through the C interface to PR_CreateThread(). Definition at line 355 of file connectionWriter.cxx. |
|
Definition at line 97 of file connectionWriter.h. |
|
Definition at line 95 of file connectionWriter.h. |
|
Definition at line 87 of file connectionWriter.h. Referenced by is_immediate(), and send(). |
|
Definition at line 91 of file connectionWriter.h. Referenced by send(). |
|
Definition at line 90 of file connectionWriter.h. Referenced by get_manager(), and is_valid_for_udp(). |
|
Definition at line 94 of file connectionWriter.h. |