Comments (4)
Thinking about this carefully, I think this would be possible to implement: but not without adding some overhead to the crate. I might be able to hide it behind a non-default feature to ensure that most crate users don't need to pay the overhead, however.
That said, I'm not sure how this would interact with the async
feature: the implementation could end up getting quite complex.
For this reason, I'm reluctant to do this at the current time. I'm actually working on a complete implementation overhaul of the crate that might make implementing this significantly easier, however. If I end up implementing this, I'll let you know.
from flume.
As a point of interest, the into_inner
method was added in c13d0a4 and is now in version 0.10.6
.
from flume.
This is already supported!
https://docs.rs/flume/0.10.5/flume/struct.Sender.html#method.try_send
The function returns a Result
, with TrySendError<T>
as the Err
variant, allowing you to get back the value. For example:
match tx.try_send(foo) {
Ok(()) => /* Successfully sent */,
Err(TrySendError::Full(foo)) | Err(TrySendError::Disconnected(foo)) => /* Failed to send */,
}
I could probably make this easier with an fn into_inner(self) -> T
on TrySendError
though. I'll add this to the next release!
from flume.
Um... This is great news!
What do you think about Permit API?
Sometimes I find myself in a situation where I need to write en-bulk and all items are already there(no need to wait for), could such use case be made faster with Permits?
from flume.
Related Issues (20)
- `flume::Sender<T>` stops to send messages to `flume::Receiver<T>` when passed through `.await` point HOT 2
- The last messge won't be triggered in async code block. HOT 8
- `async`: `send_timeout` & `send_deadline` HOT 3
- Question: Fairness when multiple receivers are doing work-stealing HOT 2
- Document features HOT 1
- Generic over backing storage / statically allocated bounded channels HOT 1
- MPMC Not working or no Broadcasting HOT 3
- async selector HOT 2
- Semantic violation that involves rendezvous channel and selector HOT 4
- Lost message when selecing on MPMC in loop from multiple threads HOT 2
- Senders and receivers are both unusable in browser main thread in WASM
- Do we need to add a timeout for `recv_async`? HOT 1
- `SendFut::poll` should return `Poll::Pending` for rendezvous channels when no item is queued
- recv on an empty unbounded channel keeps the task busy. HOT 1
- Add a `force_send()` function to `flume::Sender`?
- Resize the capacity of bounded channels HOT 1
- Clarify behavior rendezvous channels HOT 10
- Memory leak in unbounded channels HOT 1
- chan.waiting `push_front` instead of `push_back`? Thread scheduling HOT 1
- Performance with many senders on multi-threaded runtime
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flume.