[rust-dev] Importing foreign refcounted, non-threadsafe objects (GObject)

Jack Moffitt jack at metajack.im
Sun Apr 7 22:05:37 PDT 2013

> multiple tasks. Are there any best practices for wrapping such objects? One
> solution I see is to dispatch all GObject calls through a dedicated
> ever-running task initialized on program startup (GObject needs an explicit
> init call anyway, so it's no big deal to add), but this grand central
> approach may not be optimal or flexible enough.

This is what tends to happen in Erlang, although in some cases
multiple tasks would be available for dispatch (think SQL database
connections where each task owns a single connection). It would
probably work fine, and if it became a bottleneck you could have a
task per object perhaps, or wherever the thread-safe boundary lies.


More information about the Rust-dev mailing list