-
Notifications
You must be signed in to change notification settings - Fork 46
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
main_exeuctor from smol-macros #134
Conversation
I feel like this is an XY problem. What is the use case here? |
It lets me do this: fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
Arc::<Executor>::with_main(|ex| smol::block_on(async_main(ex)))
} while boils down to this: impl MainExecutor for Arc<Executor<'_>> {
#[inline]
fn with_main<T, F: FnOnce(&Self) -> T>(f: F) -> T {
let ex = Arc::new(Executor::new());
with_thread_pool(&ex, || f(&ex))
}
} which is mildly less awkward / more clear (to me at least) We can close it if you think it doesn't gain anything. It felt weird to me that |
Sorry for the delay. I guess my issue is that the fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
Arc::<Executor>::with_main(|ex| smol::block_on(async_main(ex)))
} I don't see any advantages when compared to this code: smol_macros::main! {
fn main(ex: &Arc<Executor>) -> Result<(), Box<dyn Error + Send + Sync>> {
async_main(ex);
}
} In fact, it seems less clear to me what the intent is. |
It's a 2nd package you have to pull / it's awkward.
What can be done to make it ergonomic? It's a little strange to pull a package |
It doesn't fit well in async-executor either; right now the crate is very unopinionated when it comes to creating the threadpool, and this would make it opinionated.
One advantage of having it like this is that we're not locked into this particular implementation of a thread pool. If we want to change to a more efficient implementation of a thread pool in the future, we can do this without violating any of
I disagree. cc @smol-rs/admins Design/usability problem |
Slightly relevant comment for 4 years ago: smol-rs/smol#202 (comment) |
based on smol-rs/smol-macros#10 (comment)