Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Figure out and document the thread-safety story #256
Many objects in cairo are manipulated through pointer types like
Unfortunately I couldn’t find any documentation about what is considered correct use of these objects or not, in a multi-threaded application.
I think we can conservatively assume that cairo should be thread-safe when any object created through the public API is only manipulated on the same thread it was created on. Some commit messages and entries in the
However it is not clear to me what objects can be shared across threads under what conditions, if at all. The
In cairo-rs, status quo
Cairo objects are exposed in the Rust API as wrapper structs that implement
As of cairo-rs 0.6.0 (since PR #233) most methods take a shared
These structs wrapper are
All of the above is not obvious, as shown by #192. It would be good to have high-level documentation that explains it. (By the way, I’ve found https://github.com/gtk-rs/lgpl-docs but it’s not clear how it relates to this repo. Does the release script use whatever is the latest docs commit at the time? Are new docs written for Rust bindings also under LGPL?)
More flexibility in cairo-rs?
There’s desire to do more with threads: #175, #226. If we can get answers on what is considered correct use of cairo’s C API or not (and ideally have them documented upstream), maybe we can relax these
Or, one might imagine a
Surfaces are neither