Skip to content

Conversation

@serges147
Copy link
Contributor

Implemented TODO to make asynchronous destruction of presentation entities (publishers, subscribers and rpc clients).
Now unreferenced shared objects (with ref_count==0) will be quickly appended to the double-linked list, which will be traversed asynchronously in a near future callback (schedule for now()).

serges147 and others added 30 commits August 26, 2024 07:45
# Conflicts:
#	docs/examples/1_presentation/example_10_posix_udp.cpp
#	include/libcyphal/presentation/presentation.hpp
Set default PMR, so that default behavior of
`std::pmr::polymorphic_allocator` stays with specific memory resource
(instead of default "new/delete" one) #verification #docs #sonar
# Conflicts:
#	.github/workflows/sonar.yml
#	.github/workflows/tests.yml
# Conflicts:
#	.github/workflows/sonar.yml
#	.github/workflows/tests.yml
#	docs/examples/1_presentation/example_1_presentation_1_ping_user_service_udp.cpp
#	docs/examples/2_application/example_2_application_0_node_hb_getinfo_udp.cpp
#	include/libcyphal/application/registry/register.hpp
#	include/libcyphal/presentation/client.hpp
#	include/libcyphal/presentation/publisher.hpp
#	include/libcyphal/presentation/server.hpp
#	test/unittest/application/node/test_get_info_provider.cpp
…ities (publishers, subscribers and rpc clients).

Now unreferenced shared objects (with ref_count==0) will be quickly appended to the double-linked list, which will be traversed asynchronously in a near future callback.
CETL_DEBUG_ASSERT(shared_node.isLinked(), "");
CETL_DEBUG_ASSERT(!shared_node.isReferenced(), "");

// TODO: make it async (deferred to "on idle" callback).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the "TODO" this PR is about.

@sonarqubecloud
Copy link

@serges147 serges147 added this pull request to the merge queue Nov 20, 2024
Merged via the queue into main with commit d256aff Nov 20, 2024
25 checks passed
@serges147 serges147 deleted the sshirokov/async_destroy branch November 20, 2024 18:48
Copy link
Contributor

@thirtytwobits thirtytwobits left a comment

Choose a reason for hiding this comment

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

No blockers

// No Lint b/c this `UnRefNode` is a simple helper struct as base of the below `SharedObject`.
// It's under `detail` namespace and not supposed to be used directly by the users of the library.
// NOLINTBEGIN(misc-non-private-member-variables-in-classes)
UnRefNode* prev_node{nullptr};
Copy link
Contributor

Choose a reason for hiding this comment

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

could we protect these by making them private then using friend class SharedObject?

Copy link
Contributor Author

@serges147 serges147 Nov 21, 2024

Choose a reason for hiding this comment

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

we probably can but I'm not sure we need - all derived classes (from SharedObject) are still "Impl" internal (and under detail namespace) entities. F.e. if you work with Publisher<Message> (which is not shared object!) then you don't see under the hood involved PublisherImpl. The same story for 2 other entities: subscriber and rpc client.

Presentation& operator=(const Presentation&) = delete;
Presentation& operator=(Presentation&&) noexcept = delete;

~Presentation()
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be virtual? I'm not sure TBH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Presentation is final, so I don't think we need virtual.

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.

5 participants