ZBLOG

15.6.1.2. Parameters on the DataWriter Every DataWriter holds internal collections with information about every DataReader to which it matches. By default, these collections are fully dynamic, meaning that new memory is allocated when a new DataR...

15.6.1.2. Parameters on the DataWriter

每个 DataWriter 都持有与其匹配的每个 DataReader 的内部集合信息。默认情况下,这些集合是完全动态的,意味着在匹配新 DataReader 时会分配新的内存。然而,DataWriterQos 中有一个数据成员 writer_resource_limits(),类型为 WriterResourceLimitsQos,可以配置 DataWriter 的内存分配行为。

WriterResourceLimitsQos 提供了两个数据成员:matched_subscriber_allocationreader_filters_allocation,类型为 ResourceLimitedContainerConfig。这允许配置预期匹配的 DataReader 集合的最大大小,以及写侧内容过滤器集合的大小,以便在初始化 DataWriter 时进行预分配,如下例所示。有关这些数据成员提供的其他配置选项,请参阅 ResourceLimitedContainerConfig

C++ 示例

DataWriterQos qos;

// 将匹配的数据读取器数量固定为3
// 这将在初始化期间有效地预分配内存
qos.writer_resource_limits().matched_subscriber_allocation =
        eprosima::fastdds::ResourceLimitedContainerConfig::fixed_size_configuration(3u);
// 将写侧内容过滤器的大小固定为1
// 这将在初始化期间有效地预分配内存
qos.writer_resource_limits().reader_filters_allocation =
        eprosima::fastdds::ResourceLimitedContainerConfig::fixed_size_configuration(1u);

XML 示例

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com">
    <data_writer profile_name="writer_profile_qos_resource_limit">
        <!-- 限制匹配读取器数量为3 -->
        <matchedSubscribersAllocation>
            <initial>3</initial>
            <maximum>3</maximum>
            <increment>0</increment>
        </matchedSubscribersAllocation>

        <!-- reader_filters_allocation 暂不支持通过 XML 配置 -->
    </data_writer>
</profiles>

警告

将匹配的数据读取器集合配置为固定大小实际上限制了可以匹配的数据读取器数量。一旦达到配置限制,任何新的数据读取器都将被忽略。在给定示例中,如果出现第四个(可能匹配的)数据读取器,它将不会被匹配,因为集合已经满了。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=21887

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?