Skip to content
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

Remove unnecessary Sync bounds in actor framework #3601

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

guilload
Copy link
Member

@guilload guilload commented Jul 3, 2023

Description

  • Actors don't need to be Sync because they're behind channels and process messages sequentially
  • Messages sent to actors don't need to be Sync either.

I used SyncWrapper in this PR to make the actor loop future Sync.

How was this PR tested?

  • added unit tests
  • make test-all

Copy link
Contributor

@trinity-1686a trinity-1686a left a comment

Choose a reason for hiding this comment

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

lgtm

/// Piece of state that can be copied for assert in unit test, admin, etc.
type ObservableState: Send + Sync + Clone + serde::Serialize + fmt::Debug;
type ObservableState: fmt::Debug + serde::Serialize + Send + Sync + Clone;
Copy link
Contributor

Choose a reason for hiding this comment

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

does the observable state needs to be Sync?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it needs to be Sync because of the watch channel. Under the hood, it's using a RwLock, I found out the hard way in the parking_lot documentation:

The type parameter T represents the data that this lock protects. It is
/// required that T satisfies Send to be shared across threads and Sync to
/// allow concurrent access through readers.

@guilload guilload merged commit 25c30d8 into main Jul 4, 2023
7 checks passed
@guilload guilload deleted the guillood/remove-unnecessary-sync-bounds branch July 4, 2023 13:37
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.

2 participants