Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement futures-0.3 `Spawn` for `&MainContext` #498

Merged
merged 1 commit into from Jun 17, 2019

Conversation

Projects
None yet
2 participants
@njam
Copy link
Contributor

commented Jun 15, 2019

I'm trying to use the MainContext as a futures-0.1 Executor with the help of the futures-0.1 compatibility layer.

It seems that the futures-0.3 Spawn needs to be implemented for a reference, so that's what I did (see 0.3.0-alpha.16: futures-util/src/compat/executor.rs).

I can confirm that with this change I can use the main-context as a futures-0.1 executor by calling futures::task::SpawnExt.compat() on it.

Does this make sense?

Implement futures-0.3 `Spawn` for `&MainContext`
This allows to use `MainContext` as a futures-0.1 `Executor` with the help of the futures-0.1 compatibility layer

@njam njam force-pushed the njam:futures01-executor branch from 5d6ad11 to d438334 Jun 15, 2019

@njam

This comment has been minimized.

Copy link
Contributor Author

commented Jun 15, 2019

btw you can see the same is done for futures-rs's ThreadPool here.

@sdroege

This comment has been minimized.

Copy link
Member

commented Jun 17, 2019

Thanks! The CI failures are not your fault but from gtk-rs/gtk#826 and your code is perfectly fine :)

Out of curiosity, which futures-0.1 APIs do you want to use on top of the std futures provided by glib/gio/etc?

@sdroege sdroege merged commit 94bbc9f into gtk-rs:master Jun 17, 2019

0 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@njam

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

I was trying to use existing futures-0.1 code to connect the Glib MainLoop (for the GUI) with a Tokio ThreadPool (for the main application logic), so I needed an Executor.

But I think I'll upgrade to futures-0.3, seems more sustainable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.