Panda3D
Loading...
Searching...
No Matches
queuedConnectionReader.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file queuedConnectionReader.h
10 * @author drose
11 * @date 2000-02-08
12 */
13
14#ifndef QUEUEDCONNECTIONREADER_H
15#define QUEUEDCONNECTIONREADER_H
16
17#include "pandabase.h"
18
19#include "connectionReader.h"
20#include "netDatagram.h"
21#include "queuedReturn.h"
22#include "lightMutex.h"
23#include "pdeque.h"
24
25EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<NetDatagram>);
26
27/**
28 * This flavor of ConnectionReader will read from its sockets and queue up all
29 * of the datagrams read for later receipt by the client code. This class is
30 * useful for client code that doesn't want to deal with threading and is
31 * willing to poll for datagrams at its convenience.
32 */
33class EXPCL_PANDA_NET QueuedConnectionReader : public ConnectionReader,
34 public QueuedReturn<NetDatagram> {
35PUBLISHED:
36 explicit QueuedConnectionReader(ConnectionManager *manager, int num_threads);
38
39 BLOCKING bool data_available();
40 bool get_data(NetDatagram &result);
41 bool get_data(Datagram &result);
42
43protected:
44 virtual void receive_datagram(const NetDatagram &datagram);
45
46#ifdef SIMULATE_NETWORK_DELAY
47PUBLISHED:
48 void start_delay(double min_delay, double max_delay);
49 void stop_delay();
50
51private:
52 void get_delayed();
53 void delay_datagram(const NetDatagram &datagram);
54
55 class DelayedDatagram {
56 public:
57 double _reveal_time;
58 NetDatagram _datagram;
59 };
60
61 LightMutex _dd_mutex;
62 typedef pdeque<DelayedDatagram> Delayed;
63 Delayed _delayed;
64 bool _delay_active;
65 double _min_delay, _delay_variance;
66
67#endif // SIMULATE_NETWORK_DELAY
68};
69
70#endif
The primary interface to the low-level networking layer in this package.
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition lightMutex.h:41
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition netDatagram.h:40
This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for...
This is the implementation of a family of things that queue up their return values for later retrieva...
This is our own Panda specialization on the default STL deque.
Definition pdeque.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.