#include <ConnPolicy.hpp>
Classes | |
struct | ConnPolicyDefault |
Public Member Functions | |
ConnPolicy () | |
ConnPolicy (int type) | |
ConnPolicy (int type, int lock_policy) | |
Static Public Member Functions | |
static ConnPolicy | buffer (int size, int lock_policy=LOCK_FREE, bool init_connection=false, bool pull=false) |
static ConnPolicy | circularBuffer (int size, int lock_policy=LOCK_FREE, bool init_connection=false, bool pull=false) |
static ConnPolicy | data (int lock_policy=LOCK_FREE, bool init_connection=true, bool pull=false) |
static ConnPolicy & | Default () |
Public Attributes | |
int | buffer_policy |
int | data_size |
bool | init |
int | lock_policy |
bool | mandatory |
int | max_threads |
std::string | name_id |
bool | pull |
int | size |
int | transport |
int | type |
Static Public Attributes | |
static const int | BUFFER = 1 |
static const int | CIRCULAR_BUFFER = 2 |
static const int | DATA = 0 |
static const int | LOCK_FREE = 2 |
static const int | LOCKED = 1 |
static const bool | PULL = true |
static const bool | PUSH = false |
static const int | UNBUFFERED = -1 |
static const int | UNSYNC = 0 |
Private Member Functions | |
ConnPolicy (const ConnPolicyDefault &) | |
A connection policy object describes how a given connection should behave. Various parameters are available:
the connection type: DATA, BUFFER, CIRCULAR_BUFFER or UNBUFFERED. On a data connection, the reader will have only access to the last written value. On a buffered connection, a size number of elements can be stored until the reader reads them. BUFFER drops newer samples on full, CIRCULAR_BUFFER drops older samples on full. UNBUFFERED is only valid for output streaming connections.
the locking policy: LOCKED, LOCK_FREE or UNSYNC. This defines how locking is done in the connection. For now, only three policies are available. LOCKED uses mutexes, LOCK_FREE uses a lock free method and UNSYNC means there's no synchronisation at all (not thread safe). The latter should be used only when there is no contention (simultaneous write-read).
if, upon connection, the last value that has been written on the writer end should be written on the connection as well to initialize it. This flag has an effect only if the writer has keepsLastWrittenValue() set to true (see OutputPortInterface::keepLastWrittenValue()).
if the data is pushed or pulled on the connection. This has an effect only on multi-process communication. In the pushed case (the default), new data is actively pushed to the reader's process. In the pulled case, data must be requested by the reader.
the buffer policy, which controls how multiple connections to the same input or output port are handled in case of concurrent or subsequent read and write operations. See BufferPolicy to see all available options. Not all combinations of buffer policies and the pull flag are valid and non-standard transports can have additional restrictions.
if the connection is mandatory. Mandatory connections will let the write() call fail if the new sample cannot be successfully written. Default connections are not mandatory.
the transport type. Can be used to force a certain kind of transports. The number is a RTT transport id. When the transport type is zero, local in-process communication is used, unless one of the ports is remote. If the transport type deviates from the default remote transport of one of the ports, an out-of-band transport is setup using that type.
the data size. Some protocols require a hint on big the data will be, especially if the data is dynamically sized (like std::vector<double>). If you leave this empty (recommended), the protocol will try to guess it. The unit of data size is protocol dependent.
Definition at line 107 of file ConnPolicy.hpp.
ConnPolicy::ConnPolicy | ( | ) |
Constructs a new ConnPolicy instance based on the current default settings as returned by ConnPolicy::Default().
Definition at line 109 of file ConnPolicy.cpp.
|
explicit |
Constructs a new ConnPolicy instance based on the current default settings as returned by ConnPolicy::Default(), but overrides the type. You should not use this contructor anymore and prefer the static methods ConnPolicy::data(), ConnPolicy::buffer(), etc. instead.
type |
Definition at line 122 of file ConnPolicy.cpp.
|
explicit |
Constructs a new ConnPolicy instance based on the current default settings as returned by ConnPolicy::Default(), but overrides the type and lock_policy. You should not use this contructor anymore and prefer the static methods ConnPolicy::data(), ConnPolicy::buffer(), etc. instead.
type | |
lock_policy |
Definition at line 135 of file ConnPolicy.cpp.
|
private |
Definition at line 58 of file ConnPolicy.cpp.
|
static |
Create a policy for a (lock-free) fifo buffer connection of a given size.
size | The size of the buffer in this connection |
lock_policy | The locking policy |
init_connection | If an initial sample should be pushed into the buffer upon creation. |
pull | In inter-process cases, should the consumer pull itself ? |
Definition at line 77 of file ConnPolicy.cpp.
|
static |
Create a policy for a (lock-free) circular fifo buffer connection of a given size.
size | The size of the buffer in this connection |
lock_policy | The locking policy |
init_connection | If an initial sample should be pushed into the buffer upon creation. |
pull | In inter-process cases, should the consumer pull itself ? |
Definition at line 88 of file ConnPolicy.cpp.
|
static |
Create a policy for a (lock-free) shared data connection of a given size.
lock_policy | The locking policy |
init_connection | If the data object should be initialised with the last value of the OutputPort upon creation. |
pull | In inter-process cases, should the consumer pull data itself ? |
Definition at line 99 of file ConnPolicy.cpp.
|
static |
Returns the process-wide default ConnPolicy that serves as a template for new ConnPolicy instances.
This method returns a non-const reference and you can change the defaults. This is not thread-safe and should only be done very early in the deployment phase, before the first component is loaded and before connecting ports.
Definition at line 71 of file ConnPolicy.cpp.
|
static |
Definition at line 112 of file ConnPolicy.hpp.
int RTT::ConnPolicy::buffer_policy |
The policy on how buffer elements will be installed for this connection, which influences the behavior of reads and writes if the port has muliple connections. See BufferPolicy enum for possible options.
Definition at line 216 of file ConnPolicy.hpp.
|
static |
Definition at line 113 of file ConnPolicy.hpp.
|
static |
Definition at line 111 of file ConnPolicy.hpp.
|
mutable |
Suggest the payload size of the data sent over this channel. Connections can use this value to optimize transmission or prepare the communication channel for real-time communication. This value might be overruled by the transport protocol if it can make a better guess. The interpretation of data_size is transport specific. It may be bytes, it may be something else. Leave this value set to zero, unless the transport documents otherwise.
Definition at line 248 of file ConnPolicy.hpp.
bool RTT::ConnPolicy::init |
If true, one should initialize the connection's value with the last value written on the writer port. This is only possible if the writer port has the keepsLastWrittenValue() flag set (i.e. if it remembers what was the last written value).
Definition at line 203 of file ConnPolicy.hpp.
|
static |
Definition at line 117 of file ConnPolicy.hpp.
int RTT::ConnPolicy::lock_policy |
This is the locking policy on the connection
Definition at line 196 of file ConnPolicy.hpp.
|
static |
Definition at line 116 of file ConnPolicy.hpp.
bool RTT::ConnPolicy::mandatory |
Whether the connection described by this connection policy is mandatory, which means that write operations will fail if the connection could not be served, e.g. due to a full input buffer or because of a broken remote connection. By default, all connections are mandatory.
Definition at line 232 of file ConnPolicy.hpp.
int RTT::ConnPolicy::max_threads |
The maximum number of threads that will access the connection data or buffer object. This only needs to be specified for lock-free data structures. If 0, the number of threads will be determined by a simple heuristic depending on the read and write policies of the connection.
Definition at line 224 of file ConnPolicy.hpp.
|
mutable |
The name of this connection. May be used by transports to define a 'topic' or lookup name to connect two data streams. If you leave this empty (recommended), the protocol will choose an appropriate name itself. Only specify a name to work around name clashes or if the transport protocol documents to do so.
Definition at line 256 of file ConnPolicy.hpp.
|
static |
Definition at line 120 of file ConnPolicy.hpp.
bool RTT::ConnPolicy::pull |
If true, then the sink will have to pull data. Otherwise, it is pushed from the source. In both cases, the reader side is notified that new data is available by base::ChannelElementBase::signal()
Definition at line 209 of file ConnPolicy.hpp.
|
static |
Definition at line 119 of file ConnPolicy.hpp.
int RTT::ConnPolicy::size |
If the connection is a buffered connection, the size of the buffer
Definition at line 193 of file ConnPolicy.hpp.
int RTT::ConnPolicy::transport |
The prefered transport used. 0 is local (in process), a higher number is used for inter-process or networked communication transports.
Definition at line 238 of file ConnPolicy.hpp.
int RTT::ConnPolicy::type |
DATA, BUFFER or CIRCULAR_BUFFER
Definition at line 190 of file ConnPolicy.hpp.
|
static |
Definition at line 110 of file ConnPolicy.hpp.
|
static |
Definition at line 115 of file ConnPolicy.hpp.