Park trait, ParkThread implementation and using it in LocalPool#1668
Park trait, ParkThread implementation and using it in LocalPool#1668stbuehler wants to merge 3 commits into
Conversation
|
Just rebased to current master. Is there anything I can do to help moving this (and maybe other pull requests) forward? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c24322f to
dfeae9c
Compare
|
So, I basically rewrote this PR - I still (7 years later :) ) think this is would be an interesting and useful addition to the I also added a separate Generic default params are not working well, so I renamed the actual type to |
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
- make LocalPool type alias with default ParkThread implementation matching previous behavior (default generic type doesn't work; would break in code like `LocalPool::new()`) - split non-park state into non-generic inner state - implement Park for LocalPool too
Hi,
I think it would be good to have a
Parkabstration (like the one in tokio) infutures-executor(this has already been proposed and merged in #665 for the tokio-reform branch, which has been abonded in #645).In #665
Parkwas renamed toSleep, but I thinkParkis the better choice:stdlib providesthread::parkfor a sleeping mechanism that can be cancelled ("unparked").Apart from the names
Sleepfrom #665 is basically the same as tokioPark; further changes to the API (compared to tokio):Park::park_timeoutintoPark::park, now taking aParkDurationenum: most implementations I've seen used shared code anyway.Park::parknow also includes a&mut EnterargumentUnparktrait,Parkno longer has an associatedUnparktype. Usingfutures_util::task::WakerRefinstead for the result of thewakerfunction (renamed fromunpark).I think reusing the
Wakerabstraction is rather obvious; but there are probably two open questions:Wakerinstead ofWakerRef?ParkDuration::Polland interpret a zero duration inParkDuration::Duration(..)as "poll only but don't yield"?This pull request also contains a
ParkThreadimplementation ofPark(based onstd::thread::parkand similar to whatLocalPoolwas using) and supports usingLocalPoolwith customParkimplentations (defaulting toParkThread). This wayLocalPoolcan be combined into a "local-thread runtime" with a timer and a reactor.References:
tokio_executor::parkstd::thread::park