-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Change Executors to take &self #1344
Comments
@seanmonstar is there benefit to having them take |
The difficulty I ran into was when using it as a trait object, because then you can't make use of a cheap clone. |
Ah that makes a lot of sense, I think that is a good idea then! |
@seanmonstar the trait obj argument is solid. I am 👍 |
I think this issue is no longer relevant, as the |
The
Executor
andTypedExecutor
traits both take&mut self
in theirspawn
method. While this does make sense logically, it has this downside: you can't share an executor with anArc
(for example, anArc<dyn Executor>
). You can put the executor inside aMutex
, however most executors already can handle synchronization internally, frequently with some lock-free queue.It might be a good idea to switch the
spawn
function to only take&self
.An alternative option is to leave them as
&mut self
, and implementExecutor for &T
for those that already have internal synchronization.The text was updated successfully, but these errors were encountered: