-
Notifications
You must be signed in to change notification settings - Fork 111
Managed type thread safety #2322
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6b4847a
StaticApi threading test
andrei-marinica 805e7fb
Static Api more threading tests (revealing Send issue)
andrei-marinica 28dc62e
DebugHandle !Send
andrei-marinica 12b93db
StaticApiHandle, !Send
andrei-marinica a9ec51c
DebugHandle file rename
andrei-marinica f212429
test fix
andrei-marinica b2d59cf
imports cleanup
andrei-marinica fa581f1
DebugHandle/StaticHandle !Send + !Sync test
andrei-marinica c72f41c
doc
andrei-marinica 5ac255d
managed type !Send + !Sync tests
andrei-marinica File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| use core::marker::PhantomData; | ||
|
|
||
| use multiversx_sc::{ | ||
| api::{HandleConstraints, RawHandle}, | ||
| codec::TryStaticCast, | ||
| }; | ||
|
|
||
| #[derive(Clone)] | ||
| pub struct StaticApiHandle { | ||
| raw_handle: RawHandle, | ||
| _phantom: PhantomData<*const ()>, | ||
| } | ||
|
|
||
| impl StaticApiHandle { | ||
| /// Should almost never call directly, only used directly in a test. | ||
| pub fn new(raw_handle: RawHandle) -> Self { | ||
| Self { | ||
| raw_handle, | ||
| _phantom: PhantomData, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl core::fmt::Debug for StaticApiHandle { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| RawHandle::fmt(&self.raw_handle, f) | ||
| } | ||
| } | ||
|
|
||
| impl HandleConstraints for StaticApiHandle { | ||
| fn new(handle: multiversx_sc::api::RawHandle) -> Self { | ||
| StaticApiHandle::new(handle) | ||
| } | ||
|
|
||
| fn to_be_bytes(&self) -> [u8; 4] { | ||
| self.raw_handle.to_be_bytes() | ||
| } | ||
|
|
||
| fn get_raw_handle(&self) -> RawHandle { | ||
| self.raw_handle | ||
| } | ||
|
|
||
| fn get_raw_handle_unchecked(&self) -> RawHandle { | ||
| self.raw_handle | ||
| } | ||
| } | ||
|
|
||
| impl PartialEq<RawHandle> for StaticApiHandle { | ||
| fn eq(&self, other: &RawHandle) -> bool { | ||
| &self.raw_handle == other | ||
| } | ||
| } | ||
|
|
||
| impl PartialEq<StaticApiHandle> for StaticApiHandle { | ||
| fn eq(&self, other: &StaticApiHandle) -> bool { | ||
| self.raw_handle == other.raw_handle | ||
| } | ||
| } | ||
|
|
||
| impl From<i32> for StaticApiHandle { | ||
| fn from(handle: i32) -> Self { | ||
| StaticApiHandle::new(handle) | ||
| } | ||
| } | ||
|
|
||
| impl TryStaticCast for StaticApiHandle {} | ||
2 changes: 1 addition & 1 deletion
2
framework/scenario/tests/derive_managed_vec_item_biguint_test.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
framework/scenario/tests/derive_managed_vec_item_esdt_token_payment_test.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.