compio-rs / compio

A thread-per-core Rust runtime with IOCP/io_uring/polling.
MIT License
420 stars 37 forks source link

feat(driver,runtime): add Asyncify op and `spawn_blocking` #163

Closed Berrysoft closed 10 months ago

Berrysoft commented 11 months ago

This is a requisite to fix #161

An operation Asyncify is added to spawn a blocking method to a new thread.

In this PR, the thread poll is also added into io-uring driver. In the future, we may implement CreateSocket operation with that pool in case some old kernel doesn't support socket io-uring operation.

Berrysoft commented 10 months ago

Do we really need the argument? It's a closure

Yes we do. Otherwise we need a channel to pass the data back. I think the overhead would be unacceptable.

George-Miao commented 10 months ago

@Berrysoft I mean the argument, not the returned data. We can do FnOnce() -> R.

Berrysoft commented 10 months ago

@George-Miao I see. You're right.