jhelovuo / RustDDS

Rust implementation of Data Distribution Service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Questoin: How to interpret that `DataReader::take_next_sample()` returns `None`?

jerry73204 opened this issue · comments

The API doc shows that DataReader::take_next_sample() can return Ok(None) (link) but it does not give description for it. I write a simple 1-to-1 publisher-to-subscriber test with keys enabled. The configuration is shown in the JSON text below. In this test, the publisher publishes the numbers from 1 to 100, while the subscriber receives the numbers one by one. It turns out that the subscriber eventually receives all 100 numbers, but sometimes receives None halfway. I wonder whether take_next_sample() is non-blocking and None means the following data is not available yet. If yes, the method should be named try_take_next_sample() for better clarity, or to give a detailed description of the return value.

{
    "topic": "MYTOPIC",
    "durability": "Persistent",
    "reliability": {
        "Reliable": {
            "max_blocking_time": {
                "seconds": 1,
                "fraction": 0,
            },
        }
    },
    "history": {
        "KeepLast": {
            "depth": 1,
        }
    }
}

Yes, it is non-blocking as you are guessing.

Both the non-blocking behaviour and missing try_ from the name are such because the DDS specification says so.

The documentation included with RustDDS could be improved. Maybe you can make a pull request with better docs?