fastdds 2.9版本怎么设置调度策略和优先级
时间: 2023-08-08 08:10:03 浏览: 118
在FastDDS 2.9版本中,可以通过在QoS配置中设置Scheduler类和Priority属性来设置调度策略和优先级。
具体步骤如下:
1. 创建一个QoS对象,例如:
```cpp
eprosima::fastrtps::ParticipantQos qos;
```
2. 设置调度策略,例如:
```cpp
qos.scheduler = eprosima::fastrtps::RoundRobinScheduler::instance();
```
FastDDS 2.9版本支持RoundRobinScheduler和PriorityScheduler两种调度策略。RoundRobinScheduler是默认的调度策略,如果不设置调度器,则默认使用RoundRobinScheduler。
3. 设置优先级,例如:
```cpp
qos.properties().properties().emplace_back("dds.scheduler.priority", "1");
```
这里将优先级设置为1。
注意:优先级的范围是0到255,0是最低优先级,255是最高优先级。
4. 将QoS对象应用于FastDDS实体,例如:
```cpp
eprosima::fastrtps::ParticipantAttributes participant_attributes;
participant_attributes.rtps.setName("MyParticipant");
participant_attributes.rtps.properties = qos.properties().properties();
auto participant = eprosima::fastrtps::Domain::createParticipant(participant_attributes);
```
这里将QoS对象中的属性添加到participant_attributes.rtps.properties中,然后创建FastDDS参与者实体。
以上就是在FastDDS 2.9版本中设置调度策略和优先级的步骤。
阅读全文
相关推荐
















