about summary refs log tree commit diff
path: root/src/libstd/comm/select.rs
AgeCommit message (Collapse)AuthorLines
2014-02-18Spellcheck library docs.Huon Wilson-1/+1
2014-02-13Rebase conflicts from this giant stack of patchesAlex Crichton-3/+3
List of PRs contained in this rollup: Closes #12167 r=alexcrichton Closes #12200 r=alexcrichton Closes #12206 r=pcwalton Closes #12209 r=huonw Closes #12211 r=pcwalton Closes #12217 r=brson Closes #12218 r=alexcrichton Closes #12220 r=alexcrichton Closes #12222 r=kballard Closes #12225 r=alexcrichton Closes #12227 r=kballard Closes #12237 r=alexcrichton Closes #12240 r=kballard
2014-02-13Relax an assertion in start_selection()Alex Crichton-2/+94
It asserted that the previous count was always nonnegative, but DISCONNECTED is a valid value for it to see. In order to continue to remember to store DISCONNECTED after DISCONNECTED was seen, I also added a helper method. Closes #12226
2014-02-13std::comm: replace Handle.id with a method.Huon Wilson-12/+12
The `id` shouldn't be changed by external code, and exposing it publicly allows to be accidentally changed. Also, remove the first element special case in the `select!` macro.
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-120/+192
This, the Nth rewrite of channels, is not a rewrite of the core logic behind channels, but rather their API usage. In the past, we had the distinction between oneshot, stream, and shared channels, but the most recent rewrite dropped oneshots in favor of streams and shared channels. This distinction of stream vs shared has shown that it's not quite what we'd like either, and this moves the `std::comm` module in the direction of "one channel to rule them all". There now remains only one Chan and one Port. This new channel is actually a hybrid oneshot/stream/shared channel under the hood in order to optimize for the use cases in question. Additionally, this also reduces the cognitive burden of having to choose between a Chan or a SharedChan in an API. My simple benchmarks show no reduction in efficiency over the existing channels today, and a 3x improvement in the oneshot case. I sadly don't have a pre-last-rewrite compiler to test out the old old oneshots, but I would imagine that the performance is comparable, but slightly slower (due to atomic reference counting). This commit also brings the bonus bugfix to channels that the pending queue of messages are all dropped when a Port disappears rather then when both the Port and the Chan disappear.
2014-02-11Shuffle around ownership in concurrent queuesAlex Crichton-6/+6
Beforehand, using a concurrent queue always mandated that the "shared state" be stored internally to the queues in order to provide a safe interface. This isn't quite as flexible as one would want in some circumstances, so instead this commit moves the queues to not containing the shared state. The queues no longer have a "default useful safe" interface, but rather a "default safe" interface (minus the useful part). The queues have to be shared manually through an Arc or some other means. This allows them to be a little more flexible at the cost of a usability hindrance. I plan on using this new flexibility to upgrade a channel to a shared channel seamlessly.
2014-01-31Introduce marker types for indicating variance and for opting outNiko Matsakis-2/+5
of builtin bounds. Fixes #10834. Fixes #11385. cc #5922.
2014-01-30Remove Times traitBrendan Zabarauskas-3/+3
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-6/+6
2014-01-26Fix privacy fallout from previous changeAlex Crichton-1/+1
2014-01-25auto merge of #11808 : huonw/rust/std-visible-types, r=brsonbors-0/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-26std,extra: Make some types public and other private.Huon Wilson-0/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-25auto merge of #11790 : lfairy/rust/rename-num-consts, r=alexcrichtonbors-3/+3
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` All tests pass, except for `run-pass/phase-syntax-link-does-resolve.rs`. I doubt that failure is related, though. Fixes #10010.
2014-01-25Uppercase numeric constantsChris Wong-3/+3
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-24Fix a spuriously tripped assert in select()Alex Crichton-1/+4
The race here happened when a port had its deschedule in select() canceled, but the other chan had already been dropped. This meant that the DISCONNECTED case was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this was done after aborting), causing an assert in abort_selection to trip. To fix this, the to_wake cell is just emptied before abort_selection is called (we know that we're the owner of it already).
2014-01-18Rename iterators for consistencyPalmer Cox-3/+3
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-15Allow more "error" values in try_recv()Alex Crichton-3/+6
This should allow callers to know whether the channel was empty or disconnected without having to block. Closes #11087
2013-12-24std: Get stdtest all passing againAlex Crichton-81/+13
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24std: Reimplement std::comm without the schedulerAlex Crichton-11/+17
Like the librustuv refactoring, this refactors std::comm to sever all ties with the scheduler. This means that the entire `comm::imp` module can be deleted in favor of implementations outside of libstd.
2013-12-23Fixing more doc testsAlex Crichton-1/+1
2013-12-23std: Fix all code examplesAlex Crichton-1/+2
2013-12-16Test fallout from std::comm rewriteAlex Crichton-5/+8
2013-12-16Fallout of rewriting std::commAlex Crichton-0/+2
2013-12-16Rewrite std::commAlex Crichton-0/+498
* Streams are now ~3x faster than before (fewer allocations and more optimized) * Based on a single-producer single-consumer lock-free queue that doesn't always have to allocate on every send. * Blocking via mutexes/cond vars outside the runtime * Streams work in/out of the runtime seamlessly * Select now works in/out of the runtime seamlessly * Streams will now fail!() on send() if the other end has hung up * try_send() will not fail * PortOne/ChanOne removed * SharedPort removed * MegaPipe removed * Generic select removed (only one kind of port now) * API redesign * try_recv == never block * recv_opt == block, don't fail * iter() == Iterator<T> for Port<T> * removed peek * Type::new * Removed rt::comm