{"action":"created","comment":{"url":"https://api.github.com/repos/ros2/rcl/pulls/comments/47841365","id":47841365,"diff_hunk":"@@ -0,0 +1,161 @@\n+// Copyright 2015 Open Source Robotics Foundation, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+#ifndef RCL__GUARD_CONDITION_H_\n+#define RCL__GUARD_CONDITION_H_\n+\n+#if __cplusplus\n+extern \"C\"\n+{\n+#endif\n+\n+#include \"rcl/node.h\"\n+#include \"rcl/visibility_control.h\"\n+\n+/// Internal rcl guard condition implementation struct.\n+struct rcl_guard_condition_impl_t;\n+\n+/// Handle for a rcl guard condition.\n+typedef struct rcl_guard_condition_t\n+{\n+  struct rcl_guard_condition_impl_t * impl;\n+} rcl_guard_condition_t;\n+\n+/// Options available for a rcl guard condition.\n+typedef struct rcl_guard_condition_options_t\n+{\n+  /// Custom allocator for the guard condition, used for internal allocations.\n+  rcl_allocator_t allocator;\n+} rcl_guard_condition_options_t;\n+\n+/// Return a rcl_guard_condition_t struct with members set to NULL.\n+RCL_PUBLIC\n+rcl_guard_condition_t\n+rcl_get_zero_initialized_guard_condition();","path":"rcl/include/rcl/guard_condition.h","position":45,"original_position":45,"commit_id":"898f3890199c40780e40ca8e644ffe15a16b55b1","original_commit_id":"52da897e225a8141035e97215f5f39f155de0c36","user":{"login":"wjwwood","id":100427,"avatar_url":"https://avatars.githubusercontent.com/u/100427?v=3","gravatar_id":"","url":"https://api.github.com/users/wjwwood","html_url":"https://github.com/wjwwood","followers_url":"https://api.github.com/users/wjwwood/followers","following_url":"https://api.github.com/users/wjwwood/following{/other_user}","gists_url":"https://api.github.com/users/wjwwood/gists{/gist_id}","starred_url":"https://api.github.com/users/wjwwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjwwood/subscriptions","organizations_url":"https://api.github.com/users/wjwwood/orgs","repos_url":"https://api.github.com/users/wjwwood/repos","events_url":"https://api.github.com/users/wjwwood/events{/privacy}","received_events_url":"https://api.github.com/users/wjwwood/received_events","type":"User","site_admin":false},"body":"I generally agree, and I was about to remove these functions, but in testing I noticed that you can do this:\r\n\r\n```c\r\nrcl_node_t node = rcl_get_zero_initialized_node();\r\nrcl_node_init(&node, ...);\r\n// ... use the node\r\nrcl_node_fini(&node);\r\nnode = rcl_get_zero_initialized_node();\r\n```\r\n\r\nBut not this (at least not in C):\r\n\r\n```c\r\nrcl_node_t node = {0};\r\nrcl_node_init(&node, ...);\r\n// ... use the node\r\nrcl_node_fini(&node);\r\nnode = {0};  // This is a compiler error.\r\n```\r\n\r\nThe error looks like this:\r\n\r\n```\r\nerror: expected expression\r\nnode = {0};\r\n       ^\r\n1 error generated.\r\n```\r\n\r\nSo I left them in, but I can still remove them, even with this caveat.","created_at":"2015-12-16T22:09:19Z","updated_at":"2015-12-16T22:09:19Z","html_url":"https://github.com/ros2/rcl/pull/5#discussion_r47841365","pull_request_url":"https://api.github.com/repos/ros2/rcl/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/ros2/rcl/pulls/comments/47841365"},"html":{"href":"https://github.com/ros2/rcl/pull/5#discussion_r47841365"},"pull_request":{"href":"https://api.github.com/repos/ros2/rcl/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/ros2/rcl/pulls/5","id":51612924,"html_url":"https://github.com/ros2/rcl/pull/5","diff_url":"https://github.com/ros2/rcl/pull/5.diff","patch_url":"https://github.com/ros2/rcl/pull/5.patch","issue_url":"https://api.github.com/repos/ros2/rcl/issues/5","number":5,"state":"open","locked":false,"title":"refactor rcl into a functional library","user":{"login":"wjwwood","id":100427,"avatar_url":"https://avatars.githubusercontent.com/u/100427?v=3","gravatar_id":"","url":"https://api.github.com/users/wjwwood","html_url":"https://github.com/wjwwood","followers_url":"https://api.github.com/users/wjwwood/followers","following_url":"https://api.github.com/users/wjwwood/following{/other_user}","gists_url":"https://api.github.com/users/wjwwood/gists{/gist_id}","starred_url":"https://api.github.com/users/wjwwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjwwood/subscriptions","organizations_url":"https://api.github.com/users/wjwwood/orgs","repos_url":"https://api.github.com/users/wjwwood/repos","events_url":"https://api.github.com/users/wjwwood/events{/privacy}","received_events_url":"https://api.github.com/users/wjwwood/received_events","type":"User","site_admin":false},"body":"Currently `rcl` is just an idea and not being used. This pull request will refactor it into a working library which can be used by client libraries and which is a super set of the `rmw` functionality. The scope of this pull request is just for initialization, nodes, publishers, subscriptions, guard conditions, and waiting. This will allow prototyping of the Python API implementation while we work on services (client and server), execution logic, and parameters separately in a follow up pull request.\r\n\r\nThis is a work in progress still, I need to:\r\n\r\n- [x] redesign the headers; removing functions for things out scope (services, etc...)\r\n - [x] I need to go over all the functions and think about alternative return code (not just ok and error)\r\n - [x] I need to make sure the use of `[in]`, `[out]`, and `[inout]` is consistent\r\n - [x] I need to consider `const`-ness of parameters and return types.\r\n - [x] I need to address as many of the TODO's in the code as possible (maybe after feedback)\r\n - [x] I need to add macros for visibility.\r\n - [ ] I need to add warnings about not checking return codes.\r\n- [x] implement the headers in a shared library ~~which is rmw implementation agnostic~~\r\n- [ ] implement tests which use the rcl functions:\r\n - [x] allocator\r\n - [x] guard_condition\r\n - [ ] node\r\n - [ ] publisher\r\n - [x] rcl\r\n - [ ] subscription\r\n - [x] time\r\n - [ ] timer\r\n - [ ] wait\r\n\r\nAnd then obviously iterate on feedback from review.\r\n\r\n---\r\n\r\nI'm using C11 atomics for their semantic value, on unsupported OS's there are other options:\r\n\r\n- https://gist.github.com/nhatminhle/5181506 (for clang and gcc versions that don't implement)\r\n- https://github.com/mintomic/mintomic (potential general solution when C11 atomics are not available)","created_at":"2015-11-24T03:25:25Z","updated_at":"2015-12-16T22:09:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b920455d6aeb76435f6b8e708ae61d6c38f00efb","assignee":{"login":"wjwwood","id":100427,"avatar_url":"https://avatars.githubusercontent.com/u/100427?v=3","gravatar_id":"","url":"https://api.github.com/users/wjwwood","html_url":"https://github.com/wjwwood","followers_url":"https://api.github.com/users/wjwwood/followers","following_url":"https://api.github.com/users/wjwwood/following{/other_user}","gists_url":"https://api.github.com/users/wjwwood/gists{/gist_id}","starred_url":"https://api.github.com/users/wjwwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjwwood/subscriptions","organizations_url":"https://api.github.com/users/wjwwood/orgs","repos_url":"https://api.github.com/users/wjwwood/repos","events_url":"https://api.github.com/users/wjwwood/events{/privacy}","received_events_url":"https://api.github.com/users/wjwwood/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ros2/rcl/pulls/5/commits","review_comments_url":"https://api.github.com/repos/ros2/rcl/pulls/5/comments","review_comment_url":"https://api.github.com/repos/ros2/rcl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ros2/rcl/issues/5/comments","statuses_url":"https://api.github.com/repos/ros2/rcl/statuses/898f3890199c40780e40ca8e644ffe15a16b55b1","head":{"label":"ros2:rcl_refactor","ref":"rcl_refactor","sha":"898f3890199c40780e40ca8e644ffe15a16b55b1","user":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"repo":{"id":31091419,"name":"rcl","full_name":"ros2/rcl","owner":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ros2/rcl","description":"Library to support implementation of language specific ROS Client Libraries.","fork":false,"url":"https://api.github.com/repos/ros2/rcl","forks_url":"https://api.github.com/repos/ros2/rcl/forks","keys_url":"https://api.github.com/repos/ros2/rcl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ros2/rcl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ros2/rcl/teams","hooks_url":"https://api.github.com/repos/ros2/rcl/hooks","issue_events_url":"https://api.github.com/repos/ros2/rcl/issues/events{/number}","events_url":"https://api.github.com/repos/ros2/rcl/events","assignees_url":"https://api.github.com/repos/ros2/rcl/assignees{/user}","branches_url":"https://api.github.com/repos/ros2/rcl/branches{/branch}","tags_url":"https://api.github.com/repos/ros2/rcl/tags","blobs_url":"https://api.github.com/repos/ros2/rcl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ros2/rcl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ros2/rcl/git/refs{/sha}","trees_url":"https://api.github.com/repos/ros2/rcl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ros2/rcl/statuses/{sha}","languages_url":"https://api.github.com/repos/ros2/rcl/languages","stargazers_url":"https://api.github.com/repos/ros2/rcl/stargazers","contributors_url":"https://api.github.com/repos/ros2/rcl/contributors","subscribers_url":"https://api.github.com/repos/ros2/rcl/subscribers","subscription_url":"https://api.github.com/repos/ros2/rcl/subscription","commits_url":"https://api.github.com/repos/ros2/rcl/commits{/sha}","git_commits_url":"https://api.github.com/repos/ros2/rcl/git/commits{/sha}","comments_url":"https://api.github.com/repos/ros2/rcl/comments{/number}","issue_comment_url":"https://api.github.com/repos/ros2/rcl/issues/comments{/number}","contents_url":"https://api.github.com/repos/ros2/rcl/contents/{+path}","compare_url":"https://api.github.com/repos/ros2/rcl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ros2/rcl/merges","archive_url":"https://api.github.com/repos/ros2/rcl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ros2/rcl/downloads","issues_url":"https://api.github.com/repos/ros2/rcl/issues{/number}","pulls_url":"https://api.github.com/repos/ros2/rcl/pulls{/number}","milestones_url":"https://api.github.com/repos/ros2/rcl/milestones{/number}","notifications_url":"https://api.github.com/repos/ros2/rcl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ros2/rcl/labels{/name}","releases_url":"https://api.github.com/repos/ros2/rcl/releases{/id}","created_at":"2015-02-21T00:06:40Z","updated_at":"2015-10-06T14:39:16Z","pushed_at":"2015-12-16T20:55:42Z","git_url":"git://github.com/ros2/rcl.git","ssh_url":"git@github.com:ros2/rcl.git","clone_url":"https://github.com/ros2/rcl.git","svn_url":"https://github.com/ros2/rcl","homepage":null,"size":150,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"ros2:master","ref":"master","sha":"d0083b725b35c762c6f8eafc02734d6b75d1d133","user":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"repo":{"id":31091419,"name":"rcl","full_name":"ros2/rcl","owner":{"login":"ros2","id":3979232,"avatar_url":"https://avatars.githubusercontent.com/u/3979232?v=3","gravatar_id":"","url":"https://api.github.com/users/ros2","html_url":"https://github.com/ros2","followers_url":"https://api.github.com/users/ros2/followers","following_url":"https://api.github.com/users/ros2/following{/other_user}","gists_url":"https://api.github.com/users/ros2/gists{/gist_id}","starred_url":"https://api.github.com/users/ros2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros2/subscriptions","organizations_url":"https://api.github.com/users/ros2/orgs","repos_url":"https://api.github.com/users/ros2/repos","events_url":"https://api.github.com/users/ros2/events{/privacy}","received_events_url":"https://api.github.com/users/ros2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ros2/rcl","description":"Library to support implementation of language specific ROS Client Libraries.","fork":false,"url":"https://api.github.com/repos/ros2/rcl","forks_url":"https://api.github.com/repos/ros2/rcl/forks","keys_url":"https://api.github.com/repos/ros2/rcl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ros2/rcl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ros2/rcl/teams","hooks_url":"https://api.github.com/repos/ros2/rcl/hooks","issue_events_url":"https://api.github.com/repos/ros2/rcl/issues/events{/number}","events_url":"https://api.github.com/repos/ros2/rcl/events","assignees_url":"https://api.github.com/repos/ros2/rcl/assignees{/user}","branches_url":"https://api.github.com/repos/ros2/rcl/branches{/branch}","tags_url":"https://api.github.com/repos/ros2/rcl/tags","blobs_url":"https://api.github.com/repos/ros2/rcl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ros2/rcl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ros2/rcl/git/refs{/sha}","trees_url":"https://api.github.com/repos/ros2/rcl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ros2/rcl/statuses/{sha}","languages_url":"https://api.github.com/repos/ros2/rcl/languages","stargazers_url":"https://api.github.com/repos/ros2/rcl/stargazers","contributors_url":"https://api.github.com/repos/ros2/rcl/contributors","subscribers_url":"https://api.github.com/repos/ros2/rcl/subscribers","subscription_url":"https://api.github.com/repos/ros2/rcl/subscription","commits_url":"https://api.github.com/repos/ros2/rcl/commits{/sha}","git_commits_url":"https://api.github.com/repos/ros2/rcl/git/commits{/sha}","comments_url":"https://api.github.com/repos/ros2/rcl/comments{/number}","issue_comment_url":"https://api.github.com/repos/ros2/rcl/issues/comments{/number}","contents_url":"https://api.github.com/repos/ros2/rcl/contents/{+path}","compare_url":"https://api.github.com/repos/ros2/rcl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ros2/rcl/merges","archive_url":"https://api.github.com/repos/ros2/rcl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ros2/rcl/downloads","issues_url":"https://api.github.com/repos/ros2/rcl/issues{/number}","pulls_url":"https://api.github.com/repos/ros2/rcl/pulls{/number}","milestones_url":"https://api.github.com/repos/ros2/rcl/milestones{/number}","notifications_url":"https://api.github.com/repos/ros2/rcl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ros2/rcl/labels{/name}","releases_url":"https://api.github.com/repos/ros2/rcl/releases{/id}","created_at":"2015-02-21T00:06:40Z","updated_at":"2015-10-06T14:39:16Z","pushed_at":"2015-12-16T20:55:42Z","git_url":"git://github.com/ros2/rcl.git","ssh_url":"git@github.com:ros2/rcl.git","clone_url":"https://github.com/ros2/rcl.git","svn_url":"https://github.com/ros2/rcl","homepage":null,"size":150,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ros2/rcl/pulls/5"},"html":{"href":"https://github.com/ros2/rcl/pull/5"},"issue":{"href":"https://api.github.com/repos/ros2/rcl/issues/5"},"comments":{"href":"https://api.github.com/repos/ros2/rcl/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/ros2/rcl/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/ros2/rcl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ros2/rcl/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/ros2/rcl/statuses/898f3890199c40780e40ca8e644ffe15a16b55b1"}}}}