Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update taking API documentation. #271

Merged
merged 6 commits into from
Sep 7, 2020
Merged

Update taking API documentation. #271

merged 6 commits into from
Sep 7, 2020

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Sep 2, 2020

Precisely what the title says. Closely related to #270.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
* finalization.
* Therefore, it is safe to take from the same subscription concurrently.
* However, when taking regular ROS messages:
* - Access to ROS messages is not synchronized.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
* - Access to ROS messages is not synchronized.
* - Access to the same ROS message is not synchronized.

I find that less confusing, but maybe it's just that I'm reading it incorrectly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I meant it in that sense. To say things and to say the same thing sounds equivalent to me, but I may be wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well things implies a group, whereas the same thing implies a specific instance.

I'd say the suggested change is worth doing. Or you could say:

Suggested change
* - Access to ROS messages is not synchronized.
* - Access to the ROS message is not synchronized.

Because in this case there's only one message interacting with this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is still valid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! See 005ba40.

rmw/include/rmw/rmw.h Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Show resolved Hide resolved
* finalization.
* Therefore, it is safe to take from the same subscription concurrently.
* However, when taking regular ROS messages:
* - Access to ROS messages is not synchronized.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well things implies a group, whereas the same thing implies a specific instance.

I'd say the suggested change is worth doing. Or you could say:

Suggested change
* - Access to ROS messages is not synchronized.
* - Access to the ROS message is not synchronized.

Because in this case there's only one message interacting with this function.

rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Sep 2, 2020

Oof, this is getting big. On top of what we discussed, I added a few more clarifications as to what to expect when a logical/runtime error occurs.

@hidmic
Copy link
Contributor Author

hidmic commented Sep 2, 2020

Another thing we should also document is if take (and publish) calls are: blocking or not, synchronous or not. OR leave that door open.

@ivanpauno
Copy link
Member

blocking or not, synchronous or not. OR leave that door open.

publish depends on the rmw implementation now.

I think take is always non-blocking and synchronous.
Considering how we use it, I think that that should be an API requirement.

rmw/include/rmw/rmw.h Outdated Show resolved Hide resolved
@hidmic
Copy link
Contributor Author

hidmic commented Sep 3, 2020

I think take is always non-blocking and synchronous.

I agree with it being synchronous, but non-blocking is a tricky one. Well, it depends on how you define it. take will not wait for the queue to fill up, that for sure, and the documentation already says so. But it may have to contend with other threads for the reader queue (or the message loaning pool if any). Presumably for a limited amount of time, but the thread will get re-scheduled anyways.

I'd say we allow implementations to wait on locks, but we don't allow them to wait for external events (like a message arriving, or an empty message loaning pool getting refilled, effectively banning semaphores). Some implementation may choose to go full non-blocking, but that's a bit too much for all, I think.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@ivanpauno
Copy link
Member

ivanpauno commented Sep 3, 2020

I agree with it being synchronous, but non-blocking is a tricky one. Well, it depends on how you define it. take will not wait for the queue to fill up, that for sure, and the documentation already says so. But it may have to contend with other threads for the reader queue (or the message loaning pool if any). Presumably for a limited amount of time, but the thread will get re-scheduled anyways.

I think that non-blocking isn't the same as lock-free, but maybe I'm wrong.
But yeah, I agree with your requirements above.

(edit) Mutex locking is considered a blocking operation, so I think you're right. It would be great to have a clear requirement in the doc block.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Sep 3, 2020

See be1db39. Couldn't come up with a better subtitle than " Runtime behavior". I'm open to better naming.

Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, great work @hidmic!!!

Maybe in the future, we can only have a single Thread-safety, Memory-Allocation, Runtime-Behavior paragraph for the whole "take data" API, and link to that single paragraph from the documentation of each function.
I'm not quite sure on how to do that in doxygen.

* finalization.
* Therefore, it is safe to take from the same subscription concurrently.
* However, when taking regular ROS messages:
* - Access to ROS messages is not synchronized.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is still valid

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Sep 7, 2020

Alright, going in!

@hidmic hidmic merged commit efe3f2b into master Sep 7, 2020
@delete-merged-branch delete-merged-branch bot deleted the hidmic/update-take-docs branch September 7, 2020 15:21
ahcorde pushed a commit that referenced this pull request Oct 13, 2020
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
ahcorde pushed a commit that referenced this pull request Oct 13, 2020
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants