mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.64k stars 218 forks source link

Foreign BackgroundQueue type #1734

Open bendk opened 11 months ago

bendk commented 11 months ago

A common pattern we use in application-services is to run SQLite queries using a foreign-managed task queue (Dispatchers.IO on Kotlin, DispatchQueue on Swift, etc). Could UniFFI support this as a first-class type?

This would require:

bendk commented 10 months ago

I think BackgroundQueue is a nicer name than DispatchQueue, since the feature is really about running tasks in a background thread. I feel like there could be a better name though, open to any suggestions.

mhammond commented 10 months ago

"background thread" implies "low priority thread" to me, which I don't think is the actual intent. The actual use-cases here tend to be more about thread blocking than thread priority. I was going to suggest something like TaskQueue, but depending on the content the Task part of that might itself carry baggage. WorkQueue? But I don't think it matters that much though.

bendk commented 9 months ago

You're right, it really is about blocking more than anything. tokio separates their threads into "worker threads" and "blocking threads". What about BlockingQueue or BlockingTaskQueue?

mhammond commented 9 months ago

using the same terminology as tokio is certainly appealing!