Commit Graph

374 Commits

Author SHA1 Message Date
Alex Crichton
674d24e2e6 Handle EINTR throughout libnative
Closes #11214
2014-01-05 09:19:40 -08:00
bors
b432e82515 auto merge of #11306 : alexcrichton/rust/native-bounds, r=pcwalton
This allows inspection of the current task's bounds regardless of what the
underlying task is.

Closes #11293
2014-01-04 10:16:51 -08:00
Alex Crichton
dcaf10f8de Add a stack_bounds function to the Runtime trait
This allows inspection of the current task's bounds regardless of what the
underlying task is.

Closes #11293
2014-01-04 00:08:03 -08:00
Brian Anderson
56ec9c23a4 Bump version to 0.9 2014-01-02 12:55:20 -08:00
bors
ee634e3ac4 auto merge of #11265 : c-a/rust/byteswap_from, r=alexcrichton
This patchset adds intrinsics similar to the to_[be|le][16|32|64] intrinsics but for going in the reverse direction, e.g. from big/little endian to host endian. Implementation wise they do exactly the same as the corresponding to_* functions but I think it anyway make sense to have them since using the to_* functions in the reverse direction is not entirely intuitive.

The first patch adds the intrinsics and the two following changes instances of bswap* to use the [to|from]_* intrinsics instead.
2014-01-02 00:51:51 -08:00
Carl-Anton Ingmarsson
19d8ab8d5a libnative: Use [from|to]_be16 instead of bswap16 2014-01-01 22:27:49 +01:00
bors
48918fab72 auto merge of #11212 : alexcrichton/rust/local-task-count, r=brson
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).
2014-01-01 13:21:48 -08:00
Alex Crichton
3f11f87382 Move task count bookeeping out of libstd
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).
2014-01-01 13:08:09 -08:00
bors
e61937a6bf auto merge of #11187 : alexcrichton/rust/once, r=brson
Rationale can be found in the first commit, but this is basically the same thing as `pthread_once`
2013-12-31 20:41:56 -08:00
Alex Crichton
c22fed9424 Convert relevant static mutexes to Once 2013-12-31 20:15:03 -08:00
Alex Crichton
bba78a2a89 Implement native UDP I/O 2013-12-31 11:34:22 -08:00
Alex Crichton
2a4f9d69af Implement native TCP I/O 2013-12-27 23:09:31 -08:00
Alex Crichton
1763f36c9d Bring native process bindings up to date
Move the tests into libstd, use the `iotest!` macro to test both native and uv
bindings, and use the cloexec trick to figure out when the child process fails
in exec.
2013-12-27 17:41:04 -08:00
Alex Crichton
ab431a20c0 Register new snapshots 2013-12-26 11:30:23 -08:00
Alex Crichton
6cad8f4f14 Test fixes and rebase conflicts
* vec::raw::to_ptr is gone
* Pausible => Pausable
* Removing @
* Calling the main task "<main>"
* Removing unused imports
* Removing unused mut
* Bringing some libextra tests up to date
* Allowing compiletest to work at stage0
* Fixing the bootstrap-from-c rmake tests
* assert => rtassert in a few cases
* printing to stderr instead of stdout in fail!()
2013-12-25 23:10:46 -08:00
Alex Crichton
1c4af5e3d9 rustuv: Remove the id() function from IoFactory
The only user of this was the homing code in librustuv, and it just manually
does the cast from a pointer to a uint now.
2013-12-24 19:59:54 -08:00
Alex Crichton
962af9198f native: Protect against spurious wakeups on cvars
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-24 19:59:54 -08:00
Alex Crichton
51c03c1f35 green: Properly wait for main before shutdown
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-24 19:59:54 -08:00
Alex Crichton
282f3d99a5 Test fixes and rebase problems
Note that this removes a number of run-pass tests which are exercising behavior
of the old runtime. This functionality no longer exists and is thoroughly tested
inside of libgreen and libnative. There isn't really the notion of "starting the
runtime" any more. The major notion now is "bootstrapping the initial task".
2013-12-24 19:59:53 -08:00
Alex Crichton
aad9fbf6b6 green: Fixing all tests from previous refactorings 2013-12-24 19:59:53 -08:00
Alex Crichton
3893716390 Finalize the green::Pool type
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-24 19:59:53 -08:00
Alex Crichton
f5d9b2ca6d native: Add tests and cleanup entry points
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-24 19:59:53 -08:00
Alex Crichton
018d60509c std: Get stdtest all passing again
This commit brings the library up-to-date in order to get all tests passing
again
2013-12-24 19:59:52 -08:00
Alex Crichton
6aadc9d188 native: Introduce libnative
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.
2013-12-24 14:42:00 -08:00