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

Thread local, !Send + !Sync version of Event #47

Closed
yshui opened this issue Feb 17, 2023 · 4 comments
Closed

Thread local, !Send + !Sync version of Event #47

yshui opened this issue Feb 17, 2023 · 4 comments

Comments

@yshui
Copy link

yshui commented Feb 17, 2023

Does it make sense to have a !Send + !Sync version of Event, to be used with LocalExecutor? Feels silly to pay the cost of thread synchronization when everything is happening on a single thread.

(and also a thread local version of Mutex and RwLock, which IIUC is based on event_listener?)

@notgull
Copy link
Member

notgull commented Mar 14, 2023

Previously, I was working on a thread-unsafe async framework called unsend, which had thread unsafe versions of most of smol's primitives. I stopped developing because I heard that Rust was moving towards adding !Send + !Sync versions of Waker, and if they did that it would change up my model considerably.

That being said, smol is intended to be thread-safe. Barring some kind of crazy generic solution, I don't see us moving forward on this.

@yshui
Copy link
Author

yshui commented Mar 18, 2023

I heard that Rust was moving towards adding !Send + !Sync versions of Waker

Do you mean this: rust-lang/libs-team#191 ?

@yshui
Copy link
Author

yshui commented Mar 18, 2023

smol is intended to be thread-safe.

If this is the case, maybe LocalExecutor shouldn't be included either?

@notgull
Copy link
Member

notgull commented May 14, 2023

I've released unsend version 0.1.0, with an Event structure similar to the one in this crate, but is !Sync and doesn't use any synchronization primitives.

Since we are not planning on adding an equivalent structure to EventListener, I'll close this issue now.

If this is the case, maybe LocalExecutor shouldn't be included either?

LocalExecutor is a special case I feel, because most contemporary async runtimes (even thread-safe ones) provide a LocalExecutor analogue.

@notgull notgull closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants