Skip to content

Commit

Permalink
gdk: Mark Texture builders destroy callbacks as Send
Browse files Browse the repository at this point in the history
As textures are thread-safe
  • Loading branch information
bilelmoussaoui committed Apr 6, 2024
1 parent 148f488 commit 25e83fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions gdk4/src/dmabuf_texture_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ impl DmabufTextureBuilder {
#[doc(alias = "gdk_dmabuf_texture_builder_build")]
#[must_use = "The builder must be built to be used"]
#[allow(clippy::missing_safety_doc)]
pub unsafe fn build_with_release_func<F: FnOnce() + 'static>(
pub unsafe fn build_with_release_func<F: FnOnce() + Send + 'static>(
self,
release_func: F,
) -> Result<Texture, glib::Error> {
let mut error = std::ptr::null_mut();
unsafe extern "C" fn destroy_closure<F: FnOnce() + 'static>(func: glib::ffi::gpointer) {
unsafe extern "C" fn destroy_closure<F: FnOnce() + Send + 'static>(
func: glib::ffi::gpointer,
) {
let released_func = Box::<F>::from_raw(func as *mut _);
released_func();
}
Expand Down
9 changes: 7 additions & 2 deletions gdk4/src/gl_texture_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ impl GLTextureBuilder {
#[doc(alias = "gdk_gl_texture_builder_build")]
#[must_use = "The builder must be built to be used"]
#[allow(clippy::missing_safety_doc)]
pub unsafe fn build_with_release_func<F: FnOnce() + 'static>(self, release_func: F) -> Texture {
unsafe extern "C" fn destroy_closure<F: FnOnce() + 'static>(func: glib::ffi::gpointer) {
pub unsafe fn build_with_release_func<F: FnOnce() + Send + 'static>(
self,
release_func: F,
) -> Texture {
unsafe extern "C" fn destroy_closure<F: FnOnce() + Send + 'static>(
func: glib::ffi::gpointer,
) {
let released_func = Box::<F>::from_raw(func as *mut _);
released_func();
}
Expand Down

0 comments on commit 25e83fd

Please sign in to comment.