最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - CycloneDDS dds_waitset_wait returns 0 without waiting for new data - Stack Overflow

programmeradmin0浏览0评论

I am using CycloneDDS v0.11.0 and trying to use a waitset to detect when new data is available. Here's how I am setting up my waitset and attaching a read condition:

auto rdcond = dds_create_readcondition(reader, DDS_ALIVE_INSTANCE_STATE | DDS_NOT_READ_SAMPLE_STATE);
dds_waitset_attach(waitSet, rdcond, reader);

I then call dds_waitset_wait in an infinite loop to block until waitset is triggered:

int status = dds_waitset_wait(waitSet, wsresults, wsresultsize, DDS_INFINITY);

According to the CycloneDDS documentation, the function should block until one of the attached entities is triggered or the timeout (DDS_INFINITY in my case) elapses.

However, instead of waiting for new data, the function returns immediately with status = 0. The documentation states the following about return values:

  • bigger then 0: Number of entities triggered.
  • 0: Timeout occurred (no entities were triggered).
  • Negative values: Errors (e.g., invalid parameters or deleted objects).

Since dds_waitset_wait is returning 0, it seems to indicate a timeout, but I specified DDS_INFINITY, so I was expecting it to block indefinitely until new data arrived.

Why is dds_waitset_wait not blocking as expected? Am I missing something in my setup, or is there a known issue with this approach?

I am using CycloneDDS v0.11.0 and trying to use a waitset to detect when new data is available. Here's how I am setting up my waitset and attaching a read condition:

auto rdcond = dds_create_readcondition(reader, DDS_ALIVE_INSTANCE_STATE | DDS_NOT_READ_SAMPLE_STATE);
dds_waitset_attach(waitSet, rdcond, reader);

I then call dds_waitset_wait in an infinite loop to block until waitset is triggered:

int status = dds_waitset_wait(waitSet, wsresults, wsresultsize, DDS_INFINITY);

According to the CycloneDDS documentation, the function should block until one of the attached entities is triggered or the timeout (DDS_INFINITY in my case) elapses.

However, instead of waiting for new data, the function returns immediately with status = 0. The documentation states the following about return values:

  • bigger then 0: Number of entities triggered.
  • 0: Timeout occurred (no entities were triggered).
  • Negative values: Errors (e.g., invalid parameters or deleted objects).

Since dds_waitset_wait is returning 0, it seems to indicate a timeout, but I specified DDS_INFINITY, so I was expecting it to block indefinitely until new data arrived.

Why is dds_waitset_wait not blocking as expected? Am I missing something in my setup, or is there a known issue with this approach?

Share Improve this question asked Nov 19, 2024 at 14:55 mehmetfamehmetfa 3114 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There are no known issues with this. My guess is that you are not doing something that would make the wait set stop triggering.

For example, this read condition triggers whenever there is unread (and "alive") data in the reader. If you don't read what's present, it'll keep triggering forever.

发布评论

评论列表(0)

  1. 暂无评论