-
Notifications
You must be signed in to change notification settings - Fork 36
Multithread improvements #205
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
Changes from all commits
70eb6d5
d84ef15
8ef1f82
682a381
c763cae
5171154
660bd5a
a061000
5c29194
f18c609
dd9e0ea
81615ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,9 +33,8 @@ rmw_ret_t rmw_uros_ping_agent( | |
| { | ||
| bool success = false; | ||
|
|
||
| UXR_LOCK(&session_memory.mutex); | ||
|
|
||
| if (NULL == session_memory.allocateditems) { | ||
| if (!session_memory.is_initialized || NULL == session_memory.allocateditems) { | ||
| // There is no session available to ping. Init transport is required. | ||
| #ifdef RMW_UXRCE_TRANSPORT_SERIAL | ||
| uxrSerialTransport transport; | ||
| #elif defined(RMW_UXRCE_TRANSPORT_UDP) | ||
|
|
@@ -54,24 +53,23 @@ rmw_ret_t rmw_uros_ping_agent( | |
| rmw_ret_t ret = rmw_uxrce_transport_init(NULL, NULL, (void *)&transport); | ||
|
|
||
| if (RMW_RET_OK != ret) { | ||
| UXR_UNLOCK(&session_memory.mutex); | ||
| return ret; | ||
| } | ||
|
|
||
| success = uxr_ping_agent_attempts(&transport.comm, timeout_ms, attempts); | ||
| CLOSE_TRANSPORT(&transport); | ||
| } else { | ||
| // There is a session available to ping. Using session. | ||
| rmw_uxrce_mempool_item_t * item = session_memory.allocateditems; | ||
| do { | ||
| rmw_context_impl_t * context = (rmw_context_impl_t *)item->data; | ||
|
|
||
| success = uxr_ping_agent_attempts(&context->transport.comm, timeout_ms, attempts); | ||
| success = uxr_ping_agent_session(&context->session, timeout_ms, attempts); | ||
|
|
||
| item = item->next; | ||
| } while (NULL != item && !success); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still dont like the ping multiple sessions approach. Maybe we could change this to accept a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't understand, can you make a proposal? |
||
| } | ||
|
|
||
| UXR_UNLOCK(&session_memory.mutex); | ||
|
|
||
| return success ? RMW_RET_OK : RMW_RET_ERROR; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,14 @@ rmw_wait( | |
| (void)events; | ||
| (void)wait_set; | ||
|
|
||
| // With `rmw_uxrce_wait_mutex` member `need_to_be_ran` is protected. | ||
| // `session_memory` itself is not protected because it is not modified between | ||
| // rmw_init and rmw_shutdown, and rmw_wait cannot be called concurrently with | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add a multi-thread section to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea |
||
| // those functions. | ||
| UXR_LOCK(&rmw_uxrce_wait_mutex); | ||
|
|
||
| if (!services && !clients && !subscriptions && !guard_conditions) { | ||
| UXR_UNLOCK(&rmw_uxrce_wait_mutex); | ||
| return RMW_RET_OK; | ||
| } | ||
|
|
||
|
|
@@ -53,8 +60,6 @@ rmw_wait( | |
|
|
||
| rmw_uxrce_clean_expired_static_input_buffer(); | ||
|
|
||
| UXR_LOCK(&session_memory.mutex); | ||
|
|
||
| // Clear run flag for all sessions | ||
| rmw_uxrce_mempool_item_t * item = session_memory.allocateditems; | ||
| while (item != NULL) { | ||
|
|
@@ -63,6 +68,7 @@ rmw_wait( | |
| item = item->next; | ||
| } | ||
|
|
||
| // TODO(pablogs9): What happens if there already data in one entity? | ||
| // Enable flag for every XRCE session available in the entities | ||
| for (size_t i = 0; services && i < services->service_count; ++i) { | ||
| rmw_uxrce_service_t * custom_service = (rmw_uxrce_service_t *)services->services[i]; | ||
|
|
@@ -91,7 +97,7 @@ rmw_wait( | |
|
|
||
| // There is no context that contais any of the wait set entities. Nothing to wait here. | ||
| if (available_contexts == 0) { | ||
| UXR_UNLOCK(&session_memory.mutex); | ||
| UXR_UNLOCK(&rmw_uxrce_wait_mutex); | ||
| return RMW_RET_OK; | ||
| } | ||
|
|
||
|
|
@@ -108,7 +114,7 @@ rmw_wait( | |
| item = item->next; | ||
| } | ||
|
|
||
| UXR_UNLOCK(&session_memory.mutex); | ||
| UXR_UNLOCK(&rmw_uxrce_wait_mutex); | ||
|
|
||
| bool buffered_status = false; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.