-
Notifications
You must be signed in to change notification settings - Fork 102
[#1178] Add loom test setup #1194
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ impl<T> Default for LazySingleton<T> { | |
|
|
||
| impl<T> LazySingleton<T> { | ||
| /// Creates a new [`LazySingleton`] where the underlying value is not yet initialized. | ||
| #[cfg(not(all(test, loom)))] | ||
| pub const fn new() -> Self { | ||
| Self { | ||
| data: UnsafeCell::new(None), | ||
|
|
@@ -63,6 +64,16 @@ impl<T> LazySingleton<T> { | |
| } | ||
| } | ||
|
|
||
| /// Creates a new [`LazySingleton`] where the underlying value is not yet initialized. | ||
| #[cfg(all(test, loom))] | ||
| pub fn new() -> Self { | ||
| Self { | ||
| data: UnsafeCell::new(None), | ||
| is_initialized: IoxAtomicBool::new(false), | ||
| is_finalized: IoxAtomicBool::new(false), | ||
| } | ||
| } | ||
|
Comment on lines
+68
to
+75
Member
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. Can we document that loom cannot handle |
||
|
|
||
| /// Returns true if the underlying value was initialized, otherwise false. | ||
| pub fn is_initialized(&self) -> bool { | ||
| self.is_initialized.load(Ordering::Relaxed) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,12 @@ pub struct UniqueId { | |
|
|
||
| impl Default for UniqueId { | ||
| fn default() -> Self { | ||
| #[cfg(not(all(test, loom)))] | ||
| static COUNTER: IoxAtomicU64 = IoxAtomicU64::new(0); | ||
| #[cfg(all(test, loom))] | ||
| static COUNTER: std::sync::LazyLock<IoxAtomicU64> = std::sync::LazyLock::new(|| { | ||
| unimplemented!("loom does not provide const-initialization for atomic variables.") | ||
| }); | ||
|
|
||
| UniqueId { | ||
| value: COUNTER.fetch_add(1, Ordering::Relaxed), | ||
|
|
@@ -105,7 +110,12 @@ pub struct TypedUniqueId<T> { | |
|
|
||
| impl<T> Default for TypedUniqueId<T> { | ||
| fn default() -> Self { | ||
| #[cfg(not(all(test, loom)))] | ||
| static COUNTER: IoxAtomicU64 = IoxAtomicU64::new(0); | ||
| #[cfg(all(test, loom))] | ||
| static COUNTER: std::sync::LazyLock<IoxAtomicU64> = std::sync::LazyLock::new(|| { | ||
|
Member
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. @orecham I guess this is not an issue for
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. This would work fine, but would mean only the |
||
| unimplemented!("loom does not provide const-initialization for atomic variables.") | ||
| }); | ||
|
|
||
| Self { | ||
| value: COUNTER.fetch_add(1, Ordering::Relaxed), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to make iceoryx2
no_std. Has this a negative effect on this goal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mox692 @elBoberido Is there a chance to wait for #1156 before proceeding with this? It's hard to tell how those changes will interfere with this.
I am actively working to get it merged now. Pending reviews it should be in sometime this week...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1156 Is merged. If you can rebase this PR and adapt as required, should be good to go.