about summary refs log tree commit diff
path: root/src/libstd/comm/mod.rs
AgeCommit message (Collapse)AuthorLines
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-498/+307
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-67/+65
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-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-1/+0
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-03std: Remove try_send_deferred plus all falloutAlex Crichton-13/+7
Now that extra::sync primitives are built on a proper mutex instead of a pthreads one, there's no longer any use for this function.
2014-02-03std: Fix tests with io_error usageAlex Crichton-1/+1
2014-01-31Introduce marker types for indicating variance and for opting outNiko Matsakis-7/+17
of builtin bounds. Fixes #10834. Fixes #11385. cc #5922.
2014-01-30Remove Times traitBrendan Zabarauskas-16/+16
`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-67/+67
2014-01-25auto merge of #11808 : huonw/rust/std-visible-types, r=brsonbors-1/+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-1/+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-25Uppercase numeric constantsChris Wong-2/+2
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-18Rename iterators for consistencyPalmer Cox-4/+4
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-16Fix test to account for new temporary lifetime rules, which cause the ↵Niko Matsakis-1/+1
channel to be dropped prematurely.
2014-01-15Allow more "error" values in try_recv()Alex Crichton-16/+88
This should allow callers to know whether the channel was empty or disconnected without having to block. Closes #11087
2014-01-07std: Fill in all missing importsAlex Crichton-1/+1
Fallout from the previous commits
2013-12-29Actually block in a windows cvarAlex Crichton-3/+0
Turns out with an argument of 0 the function always returns immediately! Closes #11003
2013-12-29auto merge of #11134 : lucab/rust/lucab/libstd-doc, r=cmrbors-1/+1
Uniform the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index.
2013-12-28Guard a maybe_yield in Chan with can_reschedAlex Crichton-1/+1
I forgot to add this back in after I removed can_resched and then realized I had to add it back.
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-24std: Remove must deferred sending functionsAlex Crichton-34/+5
These functions are all unnecessary now, and they only have meaning in the M:N context. Removing these functions uncovered a bug in the librustuv timer bindings, but it was fairly easy to cover (and the test is already committed). These cannot be completely removed just yet due to their usage in the WaitQueue of extra::sync, and until the mutex in libextra is rewritten it will not be possible to remove the deferred sends for channels.
2013-12-24native: Protect against spurious wakeups on cvarsAlex Crichton-1/+1
This is a very real problem with cvars on normal systems, and all of channels will not work if spurious wakeups are accepted. This problem is just solved with a synchronized flag (accessed in the cvar's lock) to see whether a signal() actually happened or whether it's spurious.
2013-12-24std: Implement yields on receives for channelsAlex Crichton-5/+20
This will prevent a deadlock when a task spins in a try_recv when using channel communication routines is a clear location for a M:N scheduling to happen.
2013-12-24std: Get stdtest all passing againAlex Crichton-230/+182
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-14/+23
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-23std: Fix all code examplesAlex Crichton-2/+2
2013-12-21Guarantee comm primitives are not FreezeAlex Crichton-0/+4
None of these primitives should be Freeze because sharing them in an Arc is a very bad idea. Closes #11039
2013-12-16Test fallout from std::comm rewriteAlex Crichton-1/+6
2013-12-16Rewrite std::commAlex Crichton-0/+1371
* 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