Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit d2390fb

Browse files
committed
Update for MainContext::ref_thread_default() not returning Option anymore
1 parent 3acdbd3 commit d2390fb

File tree

1 file changed

+28
-38
lines changed

1 file changed

+28
-38
lines changed

src/source_futures.rs

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,20 @@ where
5252

5353
if let Some(create_source) = create_source.take() {
5454
let main_context = MainContext::ref_thread_default();
55-
match main_context {
56-
None => panic!("Polled from an Executor not backed by a GLib main context"),
57-
Some(ref main_context) => {
58-
assert!(main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext");
59-
60-
// Channel for sending back the Source result to our future here.
61-
//
62-
// In theory we could directly continue polling the
63-
// corresponding task from the Source callback,
64-
// however this would break at the very least
65-
// the g_main_current_source() API.
66-
let (send, recv) = oneshot::channel();
67-
68-
let s = create_source(send);
69-
70-
s.attach(Some(main_context));
71-
*source = Some((s, recv));
72-
}
73-
}
55+
assert!(main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext");
56+
57+
// Channel for sending back the Source result to our future here.
58+
//
59+
// In theory we could directly continue polling the
60+
// corresponding task from the Source callback,
61+
// however this would break at the very least
62+
// the g_main_current_source() API.
63+
let (send, recv) = oneshot::channel();
64+
65+
let s = create_source(send);
66+
67+
s.attach(Some(&main_context));
68+
*source = Some((s, recv));
7469
}
7570

7671
// At this point we must have a receiver
@@ -224,25 +219,20 @@ where
224219

225220
if let Some(create_source) = create_source.take() {
226221
let main_context = MainContext::ref_thread_default();
227-
match main_context {
228-
None => panic!("Polled from an Executor not backed by a GLib main context"),
229-
Some(ref main_context) => {
230-
assert!(main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext");
231-
232-
// Channel for sending back the Source result to our future here.
233-
//
234-
// In theory we could directly continue polling the
235-
// corresponding task from the Source callback,
236-
// however this would break at the very least
237-
// the g_main_current_source() API.
238-
let (send, recv) = mpsc::unbounded();
239-
240-
let s = create_source(send);
241-
242-
s.attach(Some(main_context));
243-
*source = Some((s, recv));
244-
}
245-
}
222+
assert!(main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext");
223+
224+
// Channel for sending back the Source result to our future here.
225+
//
226+
// In theory we could directly continue polling the
227+
// corresponding task from the Source callback,
228+
// however this would break at the very least
229+
// the g_main_current_source() API.
230+
let (send, recv) = mpsc::unbounded();
231+
232+
let s = create_source(send);
233+
234+
s.attach(Some(&main_context));
235+
*source = Some((s, recv));
246236
}
247237

248238
// At this point we must have a receiver

0 commit comments

Comments
 (0)