Skip to content

Commit 7f12dcf

Browse files
author
Paolo Borelli
committed
gio: remove Send + Sync requirements also for other GDBus closures
While the documentation is not as explicit as for register_object, also other dbus related callbacks are scheduled to be executed on the main context. See for instance the "do_call" helper in https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gdbusnamewatching.c?ref_type=heads#L233
1 parent d123363 commit 7f12dcf

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

gio/src/dbus.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ pub struct WatcherId(NonZeroU32);
1313

1414
fn own_closure<F>(f: F) -> glib::Closure
1515
where
16-
F: Fn(DBusConnection, &str) + Send + Sync + 'static,
16+
F: Fn(DBusConnection, &str) + 'static,
1717
{
18-
glib::Closure::new(move |args| {
18+
glib::Closure::new_local(move |args| {
1919
let conn = args[0].get::<DBusConnection>().unwrap();
2020
let name = args[1].get::<&str>().unwrap();
2121
f(conn, name);
@@ -25,9 +25,9 @@ where
2525

2626
fn appeared_closure<F>(f: F) -> glib::Closure
2727
where
28-
F: Fn(DBusConnection, &str, &str) + Send + Sync + 'static,
28+
F: Fn(DBusConnection, &str, &str) + 'static,
2929
{
30-
glib::Closure::new(move |args| {
30+
glib::Closure::new_local(move |args| {
3131
let conn = args[0].get::<DBusConnection>().unwrap();
3232
let name = args[1].get::<&str>().unwrap();
3333
let name_owner = args[2].get::<&str>().unwrap();
@@ -38,9 +38,9 @@ where
3838

3939
fn vanished_closure<F>(f: F) -> glib::Closure
4040
where
41-
F: Fn(DBusConnection, &str) + Send + Sync + 'static,
41+
F: Fn(DBusConnection, &str) + 'static,
4242
{
43-
glib::Closure::new(move |args| {
43+
glib::Closure::new_local(move |args| {
4444
let conn = args[0].get::<DBusConnection>().unwrap();
4545
let name = args[1].get::<&str>().unwrap();
4646
f(conn, name);
@@ -57,8 +57,8 @@ pub fn bus_own_name_on_connection<NameAcquired, NameLost>(
5757
name_lost: NameLost,
5858
) -> OwnerId
5959
where
60-
NameAcquired: Fn(DBusConnection, &str) + Send + Sync + 'static,
61-
NameLost: Fn(DBusConnection, &str) + Send + Sync + 'static,
60+
NameAcquired: Fn(DBusConnection, &str) + 'static,
61+
NameLost: Fn(DBusConnection, &str) + 'static,
6262
{
6363
unsafe {
6464
let id = ffi::g_bus_own_name_on_connection_with_closures(
@@ -82,9 +82,9 @@ pub fn bus_own_name<BusAcquired, NameAcquired, NameLost>(
8282
name_lost: NameLost,
8383
) -> OwnerId
8484
where
85-
BusAcquired: Fn(DBusConnection, &str) + Send + Sync + 'static,
86-
NameAcquired: Fn(DBusConnection, &str) + Send + Sync + 'static,
87-
NameLost: Fn(Option<DBusConnection>, &str) + Send + Sync + 'static,
85+
BusAcquired: Fn(DBusConnection, &str) + 'static,
86+
NameAcquired: Fn(DBusConnection, &str) + 'static,
87+
NameLost: Fn(Option<DBusConnection>, &str) + 'static,
8888
{
8989
unsafe {
9090
let id = ffi::g_bus_own_name_with_closures(
@@ -93,7 +93,7 @@ where
9393
flags.into_glib(),
9494
own_closure(bus_acquired).to_glib_none().0,
9595
own_closure(name_acquired).to_glib_none().0,
96-
glib::Closure::new(move |args| {
96+
glib::Closure::new_local(move |args| {
9797
let conn = args[0].get::<Option<DBusConnection>>().unwrap();
9898
let name = args[1].get::<&str>().unwrap();
9999
name_lost(conn, name);
@@ -122,8 +122,8 @@ pub fn bus_watch_name_on_connection<NameAppeared, NameVanished>(
122122
name_vanished: NameVanished,
123123
) -> WatcherId
124124
where
125-
NameAppeared: Fn(DBusConnection, &str, &str) + Send + Sync + 'static,
126-
NameVanished: Fn(DBusConnection, &str) + Send + Sync + 'static,
125+
NameAppeared: Fn(DBusConnection, &str, &str) + 'static,
126+
NameVanished: Fn(DBusConnection, &str) + 'static,
127127
{
128128
unsafe {
129129
let id = ffi::g_bus_watch_name_on_connection_with_closures(
@@ -146,8 +146,8 @@ pub fn bus_watch_name<NameAppeared, NameVanished>(
146146
name_vanished: NameVanished,
147147
) -> WatcherId
148148
where
149-
NameAppeared: Fn(DBusConnection, &str, &str) + Send + Sync + 'static,
150-
NameVanished: Fn(DBusConnection, &str) + Send + Sync + 'static,
149+
NameAppeared: Fn(DBusConnection, &str, &str) + 'static,
150+
NameVanished: Fn(DBusConnection, &str) + 'static,
151151
{
152152
unsafe {
153153
let id = ffi::g_bus_watch_name_with_closures(

0 commit comments

Comments
 (0)