-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add Oneshot implementation #21
Comments
Great idea, Let me think about the API and the possibility of implementation for a few days. Other community members can discuss and think about it too. |
I want to add these points to the issue, buffered one-shot and blocking one-shot channels are completely different in design. to implement those I think we need: |
We can use an enum to merge these public structures into 4 types. but there will be an unknown performance impact. |
Its usage is a:
Exactly what I want for this. https://github.com/botika/unblock/blob/master/src/lib.rs#L132-L137 |
I have an idea for a completely lock-free design for an unbuffered Oneshot channel. |
@botika implementation added to the library but I will not release it to crates.io until we run some tests on it and complete the documentation. |
Fails
|
here you have two options: using something like:
or doing the job with |
you also need to convert the sender and use the sync API: |
Looks good. But it has Miri error when test multiple thread: MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-ignore-leaks" cargo miri test --all-features
...
test test_thread ... error: Undefined Behavior: trying to retag from <wildcard> for SharedReadWrite permission at alloc1885061[0x8], but no exposed tags have suitable permission in the borrow stack for this location
--> /home/lucky/.cargo/git/checkouts/kanal-35bf5e2ecaf10304/d3702c0/src/signal.rs:224:9
|
224 | (*this).ptr.copy(d);
| ^^^^^^^^^^^^^^^^^^^
| |
| trying to retag from <wildcard> for SharedReadWrite permission at alloc1885061[0x8], but no exposed tags have suitable permission in the borrow stack for this location
| this error occurs as part of retag at alloc1885061[0x8..0x10]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
= note: BACKTRACE:
= note: inside `kanal::signal::Signal::<()>::send_copy` at /home/lucky/.cargo/git/checkouts/kanal-35bf5e2ecaf10304/d3702c0/src/signal.rs:224:9
= note: inside `kanal::signal::SignalTerminator::<()>::send_copy` at /home/lucky/.cargo/git/checkouts/kanal-35bf5e2ecaf10304/d3702c0/src/signal.rs:268:9
= note: inside `kanal::oneshot::OneshotSender::<()>::send` at /home/lucky/.cargo/git/checkouts/kanal-35bf5e2ecaf10304/d3702c0/src/oneshot.rs:244:33
note: inside closure at /home/lucky/workspace/unblock/src/lib.rs:149:21
--> /home/lucky/workspace/unblock/src/lib.rs:185:9
|
185 | run!(f in self)
| ^^^^^^^^^^^^^^^
= note: inside `<[closure@unblock::Executor::spawn<(), fn() {sleep}>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/lucky/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:510:5
= note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/lucky/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2000:9
note: inside `unblock::Executor::main_loop` at /home/lucky/workspace/unblock/src/lib.rs:198:17
--> /home/lucky/workspace/unblock/src/lib.rs:198:17
|
198 | runnable();
| ^^^^^^^^^^
note: inside closure at /home/lucky/workspace/unblock/src/lib.rs:242:36
--> /home/lucky/workspace/unblock/src/lib.rs:242:36
|
242 | .spawn(move || self.main_loop())
| ^^^^^^^^^^^^^^^^
= note: this error originates in the macro `run` (in Nightly builds, run with -Z macro-backtrace for more info) |
I'm receiving |
Need MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-ignore-leaks" cargo miri test --no-default-features --features mt,kanal,lazy In my machine (ryzen 9) is all ok |
unfortunately, I can't reproduce either Miri error or deadlock, I'm going to write a fuzzer to see if it's possible to reproduce the problem that you are encountering, I'm stopping the pre8 release until this problem is solved. |
seems fixed with the latest commit: https://github.com/fereidani/unblock/actions/runs/3941226089/jobs/6743356805 |
Looks good in my test. Can you bump version? |
Thanks for finding the bug, it was a mistype by me. |
From what you have, a async
oneshot
without a clone that I can use to synchronize pairs of threads would not be complicated.And also features to be able to reduce the compilation time.
And also I can help!
The text was updated successfully, but these errors were encountered: