Working with flow controllers.
Working with flow controllers.
Creating a flow controller
- Set up participant
- Create a flow controller
retcode = participant->get_default_flowcontroller_property(property);
printf("***Error: failed to get default flow controller property\n");
}
controller = participant->create_flowcontroller(
"my flow controller name", property);
if (controller == NULL) {
printf("***Error: failed to create flow controller\n");
}
<<interface>> A flow controller is the object responsible for shaping the network traffic by determin...
Definition: flowcontroller.ifcxx:49
DDS_ReturnCode_t
Type for return codes.
Definition: infrastructure.ifc:1351
@ DDS_RETCODE_OK
Successful return.
Definition: infrastructure.ifc:1354
Determines the flow control characteristics of the DDSFlowController.
Definition: flowcontroller.ifc:93
Flow controlling a data writer
- Set up participant
- Create flow controller
- Create an asynchronous data writer, FooDataWriter, of user data type
Foo:
MyWriterListener* writer_listener = new MyWriterListener();
retcode = publisher->get_default_datawriter_qos(writer_qos);
}
writer_qos,
writer_listener,
if (writer == NULL) {
};
printf("***Error: failed to wait for asynchronous publishing\n");
}
virtual DDS_ReturnCode_t wait_for_asynchronous_publishing(const DDS_Duration_t &max_wait)
<<extension>> Blocks the calling thread until asynchronous sending is complete.
Definition: publication.ifcxx:684
@ DDS_KEEP_ALL_HISTORY_QOS
Keep all the samples.
Definition: infrastructure.ifc:3040
@ DDS_ASYNCHRONOUS_PUBLISH_MODE_QOS
Indicates to send data asynchronously.
Definition: infrastructure.ifc:6586
#define DDS_STATUS_MASK_ALL
All bits are set.
Definition: infrastructure.ifc:1431
char * DDS_String_dup(const char *str)
Clone a string. Creates a new string that duplicates the value of string.
QoS policies supported by a DDSDataWriter entity.
Definition: publication.ifc:970
struct DDS_PublishModeQosPolicy publish_mode
<<extension>> Publish mode policy, PUBLISH_MODE.
Definition: publication.ifc:1063
struct DDS_HistoryQosPolicy history
History policy, HISTORY.
Definition: publication.ifc:1001
DDS_HistoryQosPolicyKind kind
Specifies the kind of history to be kept.
Definition: infrastructure.ifc:3050
char * flow_controller_name
Name of the associated flow controller.
Definition: infrastructure.ifc:6614
DDS_PublishModeQosPolicyKind kind
Publishing mode.
Definition: infrastructure.ifc:6611
<<interface>> <<generic>> User data type specific data writer.
Definition: data.ifc:465
Using the built-in flow controllers
RTI Connext provides several built-in flow controllers.
The DDS_DEFAULT_FLOW_CONTROLLER_NAME built-in flow controller provides the basic asynchronous writer behavior. When calling FooDataWriter::write, the call signals the DDSPublisher asynchronous publishing thread (DDS_PublisherQos::asynchronous_publisher) to send the actual data. As with any DDS_ASYNCHRONOUS_PUBLISH_MODE_QOS DDSDataWriter, the FooDataWriter::write call returns immediately afterwards. The data is sent immediately in the context of the DDSPublisher asynchronous publishing thread.
When using the DDS_FIXED_RATE_FLOW_CONTROLLER_NAME flow controller, data is also sent in the context of the DDSPublisher asynchronous publishing thread, but at a regular fixed interval. The thread accumulates samples from different DDSDataWriter instances and generates data on the wire only once per DDS_FlowControllerTokenBucketProperty_t::period.
In contrast, the DDS_ON_DEMAND_FLOW_CONTROLLER_NAME flow controller permits flow only when DDSFlowController::trigger_flow is called. The data is still sent in the context of the DDSPublisher asynchronous publishing thread. The thread accumulates samples from different DDSDataWriter instances (across any DDSPublisher) and sends all data since the previous trigger.
The properties of the built-in DDSFlowController instances can be adjusted.
- Set up participant
- Lookup built-in flow controller
controller = participant->lookup_flowcontroller(
if (controller == NULL) {
printf("***Error: failed to lookup flow controller\n");
}
char * DDS_DEFAULT_FLOW_CONTROLLER_NAME
[default] Special value of DDS_PublishModeQosPolicy::flow_controller_name that refers to the built-in...
- Change property of built-in flow controller, if desired
printf("***Error: failed to get flow controller property\n");
}
property.token_bucket.period.sec = 2;
property.token_bucket.period.nanosec = 0;
printf("***Error: failed to set flow controller property\n");
}
virtual DDS_ReturnCode_t get_property(struct DDS_FlowControllerProperty_t &prop)=0
Gets the DDSFlowController property.
virtual DDS_ReturnCode_t set_property(const struct DDS_FlowControllerProperty_t &prop)=0
Sets the DDSFlowController property.
- Create a data writer using the correct flow controller name
Shaping the network traffic for a particular transport
Coalescing multiple samples in a single network packet