Skip to content

Commit 6c6c7bd

Browse files
authored
Merge pull request #1422 from pbor/dbusconn2
gio: remove Send + Sync requirements from DBusConnection::register_ob…
2 parents 147b477 + 7f12dcf commit 6c6c7bd

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
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(

gio/src/dbus_connection.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,17 @@ impl DBusConnection {
3434
) -> Result<RegistrationId, glib::Error>
3535
where
3636
MethodCall: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant, DBusMethodInvocation)
37-
+ Send
38-
+ Sync
39-
+ 'static,
40-
GetProperty:
41-
Fn(DBusConnection, &str, &str, &str, &str) -> glib::Variant + Send + Sync + 'static,
42-
SetProperty: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant) -> bool
43-
+ Send
44-
+ Sync
4537
+ 'static,
38+
GetProperty: Fn(DBusConnection, &str, &str, &str, &str) -> glib::Variant + 'static,
39+
SetProperty: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant) -> bool + 'static,
4640
{
4741
unsafe {
4842
let mut error = std::ptr::null_mut();
4943
let id = ffi::g_dbus_connection_register_object_with_closures(
5044
self.to_glib_none().0,
5145
object_path.to_glib_none().0,
5246
interface_info.to_glib_none().0,
53-
glib::Closure::new(move |args| {
47+
glib::Closure::new_local(move |args| {
5448
let conn = args[0].get::<DBusConnection>().unwrap();
5549
let sender = args[1].get::<&str>().unwrap();
5650
let object_path = args[2].get::<&str>().unwrap();
@@ -71,7 +65,7 @@ impl DBusConnection {
7165
})
7266
.to_glib_none()
7367
.0,
74-
glib::Closure::new(move |args| {
68+
glib::Closure::new_local(move |args| {
7569
let conn = args[0].get::<DBusConnection>().unwrap();
7670
let sender = args[1].get::<&str>().unwrap();
7771
let object_path = args[2].get::<&str>().unwrap();
@@ -83,7 +77,7 @@ impl DBusConnection {
8377
})
8478
.to_glib_none()
8579
.0,
86-
glib::Closure::new(move |args| {
80+
glib::Closure::new_local(move |args| {
8781
let conn = args[0].get::<DBusConnection>().unwrap();
8882
let sender = args[1].get::<&str>().unwrap();
8983
let object_path = args[2].get::<&str>().unwrap();

0 commit comments

Comments
 (0)