[#1911] Add bag concept - #1926
Conversation
aaf7d2f to
c568d17
Compare
elfenpiff
left a comment
There was a problem hiding this comment.
Looks good - except the hardest part, the naming ;) .
| unsafe { self.remove(handle, mode) } | ||
| } | ||
|
|
||
| unsafe fn get_state(&self) -> ContainerState<T> { |
There was a problem hiding this comment.
Should we rename the ContainerState to BagState?
There was a problem hiding this comment.
I was also thinking about re-exporting all the types from iceoryx2-bb-lock-free in the iceoryx2-cal/bag namespace. Not sure about changing also the iceoryx2-bb-lock-free Container itself right now.
|
|
||
| unsafe fn remove( | ||
| &self, | ||
| handle: ContainerHandle, |
There was a problem hiding this comment.
Should we rename the ContainerHandle to BagHandle
| impl<T: Copy + Debug + ZeroCopySend> BagValue for T {} | ||
|
|
||
| /// TODO documentation | ||
| pub trait Bag: Debug + 'static { |
There was a problem hiding this comment.
Could we rename this: Bag -> BagFamily and the BagAccess is Bag.
The thinking is, that a Bag is a thing that contains T and has the following interface and behavior. But with this is a Bag a trait that defines a type alias and BagAccess is the thing that contains T.
We already have this name scheme in place in iceoryx2. We have for instance a Pointer<T> trait: https://github.com/eclipse-iceoryx/iceoryx2/blob/main/iceoryx2-bb/elementary-traits/src/pointer.rs
and a PointerFamily trait: https://github.com/eclipse-iceoryx/iceoryx2/blob/main/iceoryx2-bb/elementary-traits/src/pointer_family.rs
This reads then in code naturally:
struct SomeThing<P: Pointer> {
fuu: P<u64>
}or when you need it more generic:
struct SomeThing<P: PointerFamily> {
fuu: P::Pointer<u64>,
bar: P::Pointer<i32>
}I think I had some discussion with ?Jeff? and a LLM until come to this naming style.
| &self, | ||
| value: T, | ||
| owner_id: OwnerId, | ||
| ) -> Result<(*const T, ContainerHandle), ContainerAddFailure> { |
There was a problem hiding this comment.
Could we rename all errors to BagAddFailure etc..
|
|
||
| /// TODO documentation | ||
| pub trait Bag: Debug + 'static { | ||
| type Container<T: BagValue>: Debug |
There was a problem hiding this comment.
This we could rename to Bag and technically T would be the BagType.
There was a problem hiding this comment.
Just to prevent misunderstanding. This is your suggestion, right
pub trait BagFamily: Debug + 'static {
type Bag<T: BagType>: Debugf1357c6 to
04a8510
Compare
| Ok(ReleaseState::Unlocked) => Ok(DeregisterNodeState::HasOwners), | ||
| Err(ContainerRemoveError::ContainerHandleNotOwnedByContainer) => { | ||
| fail!(from self, with ContainerRemoveError::ContainerHandleNotOwnedByContainer, | ||
| Err(BagRemoveError::ContainerHandleNotOwnedByContainer) => { |
There was a problem hiding this comment.
@elfenpiff this is not nice. We either have to create a BagRemoveError enum and map the errors 1-1 to ContainerRemoveError or rename the error e.g. to HandleNotOwnedByContainer which is a bit less confusing. The former option would add some boilerplate. Alternatively, the Container itself could be renamed.
There was a problem hiding this comment.
What about HandleNotOwned, for me this would also be clear. Or HandleNotOwnedByInstance. What do you think?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1926 +/- ##
==========================================
+ Coverage 76.37% 76.52% +0.15%
==========================================
Files 457 453 -4
Lines 46145 46156 +11
Branches 1505 1489 -16
==========================================
+ Hits 35241 35319 +78
+ Misses 9857 9575 -282
- Partials 1047 1262 +215
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
b08d3f4 to
c79a037
Compare
c79a037 to
8a560c8
Compare
… 'HandleNotOwnedByInstance'
d55955d to
402a979
Compare
402a979 to
2d6f645
Compare
2d6f645 to
9881f14
Compare
Notes for Reviewer
This PR adds a
Bagconcept in order to make the resource owner tracking pluggable.Pre-Review Checklist for the PR Author
Convert to draft)iox2-123-introduce-posix-ipc-example)[#123] Add posix ipc example)PR Reviewer Reminders
References
Closes #1911