about summary refs log tree commit diff
path: root/src/libnative/task.rs
AgeCommit message (Collapse)AuthorLines
2014-02-16Clean up std::task docs, make TaskBuilder a real builderKevin Ballard-1/+0
Delete all the documentation from std::task that references linked failure. Tweak TaskBuilder to be more builder-like. .name() is now .named() and .add_wrapper() is now .with_wrapper(). Remove .watched() and .unwatched() as they didn't actually do anything.
2014-02-16Convert some unnecessary StaticNativeMutexes to NativeMutexes.Huon Wilson-9/+3
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-3/+3
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-9/+6
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-13Don't require an allocation for on_exit messagesAlex Crichton-5/+2
Instead, use an enum to allow running both a procedure and sending the task result over a channel. I expect the common case to be sending on a channel (e.g. task::try), so don't require an extra allocation in the common case. cc #11389
2014-02-07Delete send_str, rewrite clients on top of MaybeOwned<'static>Kevin Ballard-1/+1
Declare a `type SendStr = MaybeOwned<'static>` to ease readibility of types that needed the old SendStr behavior. Implement all the traits for MaybeOwned that SendStr used to implement.
2014-02-03std: Remove try_send_deferred plus all falloutAlex Crichton-1/+3
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-03native: Require all results are used and fix falloutAlex Crichton-1/+2
2014-01-30Remove Times traitBrendan Zabarauskas-1/+1
`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 libnativeScott Lawrence-16/+16
2014-01-16Fixing a typo: bookeeping -> bookkeepingDerek Chiang-4/+4
2014-01-09auto merge of #11360 : huonw/rust/stack_bounds, r=alexcrichtonbors-6/+9
We just approximate with a 2MB stack for native::start.
2014-01-07auto merge of #11353 : alexcrichton/rust/improve-logging, r=brsonbors-1/+5
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-07std::rt: require known stack bounds for all tasks.Huon Wilson-6/+9
We just approximate with a 1 or 2 MB stack for native::start.
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-1/+5
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-05Guarantee that native tasks wait for childrenAlex Crichton-1/+5
There was a scheduling race where a child may not increment the global task count before the parent exits, and the parent would then think that there are no more tasks left.
2014-01-04Add a stack_bounds function to the Runtime traitAlex Crichton-5/+22
This allows inspection of the current task's bounds regardless of what the underlying task is. Closes #11293
2014-01-01Move task count bookeeping out of libstdAlex Crichton-0/+3
For libgreen, bookeeping should not be global but rather on a per-pool basis. Inside libnative, it's known that there must be a global counter with a mutex/cvar. The benefit of taking this strategy is to remove this functionality from libstd to allow fine-grained control of it through libnative/libgreen. Notably, helper threads in libnative can manually decrement the global count so they don't count towards the global count of threads. Also, the shutdown process of *all* sched pools is now dependent on the number of tasks in the pool being 0 rather than this only being a hardcoded solution for the initial sched pool in libgreen. This involved adding a Local::try_take() method on the Local trait in order for the channel wakeup to work inside of libgreen. The channel send was happening from a SchedTask when there is no Task available in TLS, and now this is possible to work (remote wakeups are always possible, just a little slower).
2013-12-27Implement native TCP I/OAlex Crichton-7/+5
2013-12-24native: Protect against spurious wakeups on cvarsAlex Crichton-13/+29
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-24green: Properly wait for main before shutdownAlex Crichton-8/+2
There was a race in the code previously where schedulers would *immediately* shut down after spawning the main task (because the global task count would still be 0). This fixes the logic by blocking the sched pool task in receving on a port instead of spawning a task into the pool to receive on a port. The modifications necessary were to have a "simple task" running by the time the code is executing, but this is a simple enough thing to implement and I forsee this being necessary to have implemented in the future anyway.
2013-12-24green: Fixing all tests from previous refactoringsAlex Crichton-0/+1
2013-12-24Finalize the green::Pool typeAlex Crichton-45/+5
The scheduler pool now has a much more simplified interface. There is now a clear distinction between creating the pool and then interacting the pool. When a pool is created, all schedulers are not active, and only later if a spawn is done does activity occur. There are four operations that you can do on a pool: 1. Create a new pool. The only argument to this function is the configuration for the scheduler pool. Currently the only configuration parameter is the number of threads to initially spawn. 2. Spawn a task into this pool. This takes a procedure and task configuration options and spawns a new task into the pool of schedulers. 3. Spawn a new scheduler into the pool. This will return a handle on which to communicate with the scheduler in order to do something like a pinned task. 4. Shut down the scheduler pool. This will consume the scheduler pool, request all of the schedulers to shut down, and then wait on all the scheduler threads. Currently this will block the invoking OS thread, but I plan on making 'Thread::join' not a thread-blocking call. These operations can be used to encode all current usage of M:N schedulers, as well as providing a simple interface through which a pool can be modified. There is currently no way to remove a scheduler from a pool of scheduler, as there's no way to guarantee that a scheduler has exited. This may be added in the future, however (as necessary).
2013-12-24native: Add tests and cleanup entry pointsAlex Crichton-0/+97
This adds a few smoke tests associated with libnative tasks (not much code to test here anyway), and cleans up the entry points a little bit to be a little more like libgreen. The I/O code doesn't need much testing because that's all tested in libstd (with the iotest! macro).
2013-12-24std: Get stdtest all passing againAlex Crichton-3/+8
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24native: Introduce libnativeAlex Crichton-0/+257
This commit introduces a new crate called "native" which will be the crate that implements the 1:1 runtime of rust. This currently entails having an implementation of std::rt::Runtime inside of libnative as well as moving all of the native I/O implementations to libnative. The current snag is that the start lang item must currently be defined in libnative in order to start running, but this will change in the future. Cool fact about this crate, there are no extra features that are enabled. Note that this commit does not include any makefile support necessary for building libnative, that's all coming in a later commit.