about summary refs log tree commit diff
path: root/src/libstd/rt/thread.rs
AgeCommit message (Collapse)AuthorLines
2014-06-11sync: Move underneath libstdAlex Crichton-348/+0
This commit is the final step in the libstd facade, #13851. The purpose of this commit is to move libsync underneath the standard library, behind the facade. This will allow core primitives like channels, queues, and atomics to all live in the same location. There were a few notable changes and a few breaking changes as part of this movement: * The `Vec` and `String` types are reexported at the top level of libcollections * The `unreachable!()` macro was copied to libcore * The `std::rt::thread` module was moved to librustrt, but it is still reexported at the same location. * The `std::comm` module was moved to libsync * The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`. It is now a private module with types/functions being reexported under `sync::comm`. This is a breaking change for any existing users of duplex streams. * All concurrent queues/deques were moved directly under libsync. They are also all marked with #![experimental] for now if they are public. * The `task_pool` and `future` modules no longer live in libsync, but rather live under `std::sync`. They will forever live at this location, but they may move to libsync if the `std::task` module moves as well. [breaking-change]
2014-06-08Fix spelling errors in comments.Joseph Crail-1/+1
2014-05-30windows: Allow snake_case errors for now.Kevin Butler-0/+1
2014-05-23core: Finish stabilizing the `mem` module.Alex Crichton-2/+2
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-15use sched_yield on linux and freebsdDaniel Micay-10/+0
pthread_yield is non-standard, while sched_yield is POSIX The Linux documentation recommends using the standard function. This is the only feature we're currently using that's present in glibc but not in musl.
2014-05-11core: Remove the cast moduleAlex Crichton-11/+10
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-09Register new snapshotsAlex Crichton-1/+1
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-8/+11
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-3/+3
2014-05-03Add lint check for negating uint literals and variables.Falco Hirschenberger-0/+1
See #11273 and #13318
2014-04-18std: Fail more gracefully on thread spawn errorsAlex Crichton-4/+17
On windows, correctly check for errors when spawning threads, and on both windows and unix handle the error more gracefully rather than printing an opaque assertion failure. Closes #13589
2014-04-10std: Be sure to call pthread_attr_destroyAlex Crichton-0/+2
On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is necessary to deallocate that memory. Closes #13420
2014-04-08Register new snapshotsAlex Crichton-6/+6
2014-03-31std: Switch field privacy as necessaryAlex Crichton-3/+3
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-27Fix fallout of removing default boundsAlex Crichton-7/+9
This is all purely fallout of getting the previous commit to compile.
2014-03-20Register new snapshotsAlex Crichton-2/+1
2014-03-11rustc: Support various flavors of linkagesAlex Crichton-37/+26
It is often convenient to have forms of weak linkage or other various types of linkage. Sadly, just using these flavors of linkage are not compatible with Rust's typesystem and how it considers some pointers to be non-null. As a compromise, this commit adds support for weak linkage to external symbols, but it requires that this is only placed on extern statics of type `*T`. Codegen-wise, we get translations like: // rust code extern { #[linkage = "extern_weak"] static foo: *i32; } // generated IR @foo = extern_weak global i32 @_some_internal_symbol = internal global *i32 @foo All references to the rust value of `foo` then reference `_some_internal_symbol` instead of the symbol `_foo` itself. This allows us to guarantee that the address of `foo` will never be null while the value may sometimes be null. An example was implemented in `std::rt::thread` to determine if `__pthread_get_minstack()` is available at runtime, and a test is checked in to use it for a static value as well. Function pointers a little odd because you still need to transmute the pointer value to a function pointer, but it's thankfully better than not having this capability at all.
2014-02-23std: Move unstable::stack to rt::stackBrian Anderson-3/+3
2014-02-09std: Add init and uninit to mem. Replace direct intrinsic usageBrian Anderson-3/+3
2014-01-31Use __pthread_get_minstack() when available.Ben Noordhuis-1/+46
glibc >= 2.15 has a __pthread_get_minstack() function that returns PTHREAD_STACK_MIN plus however many bytes are needed for thread-local storage. Use it when it's available because just PTHREAD_STACK_MIN is not enough in applications that have big thread-local storage requirements. Fixes #6233.
2014-01-31Retry on EINVAL from pthread_attr_setstacksize()Ben Noordhuis-5/+44
Enforce that the stack size is > RED_ZONE + PTHREAD_STACK_MIN. If the call to pthread_attr_setstacksize() subsequently fails with EINVAL, it means that the platform requires the stack size to be a multiple of the page size. In that case, round up to the nearest page and retry. Fixes #11694.
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-3/+3
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-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-1/+1
2014-01-06Revert "std: adjust requested stack size for thread-local storage."Huon Wilson-19/+1
This reverts commit f1b5f59287106fc511d29c425255bd343608065c. Using a private function of a library is a bad idea: several people (on Linux) were meeting with linking errors because of it (different/older versions of glibc).
2014-01-04std: adjust requested stack size for thread-local storage.Huon Wilson-1/+19
If there is a lot of data in thread-local storage some implementations of pthreads (e.g. glibc) fail if you don't request a stack large enough -- by adjusting for the minimum size we guarantee that our stacks are always large enough. Issue #6233.
2013-12-25Test fixes and rebase conflictsAlex Crichton-4/+0
* 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-24std: Update std::rt::thread to specify stack sizesAlex Crichton-8/+16
It's now possible to spawn an OS thread with a stack that has a specific size.
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-0/+6
This extracts everything related to green scheduling from libstd and introduces a new libgreen crate. This mostly involves deleting most of std::rt and moving it to libgreen. Along with the movement of code, this commit rearchitects many functions in the scheduler in order to adapt to the fact that Local::take now *only* works on a Task, not a scheduler. This mostly just involved threading the current green task through in a few locations, but there were one or two spots where things got hairy. There are a few repercussions of this commit: * tube/rc have been removed (the runtime implementation of rc) * There is no longer a "single threaded" spawning mode for tasks. This is now encompassed by 1:1 scheduling + communication. Convenience methods have been introduced that are specific to libgreen to assist in the spawning of pools of schedulers.
2013-12-24std: Introduce an unstable::stack moduleAlex Crichton-2/+2
This module will be used to manage the OS-specific TLS registers used to specify the bounds of the current rust stack (useful in 1:1 and M:N)
2013-12-16Test fallout from std::comm rewriteAlex Crichton-5/+9
2013-12-16Fallout of rewriting std::commAlex Crichton-78/+109
2013-11-27Improve the rt::thread moduleAlex Crichton-58/+145
* Added doc comments explaining what all public functionality does. * Added the ability to spawn a detached thread * Added the ability for the procs to return a value in 'join'
2013-11-24std: Fix transmute error on win64klutzy-1/+1
2013-11-18libstd: Change all `~fn()`s to `proc`s in the standard library.Patrick Walton-4/+4
This makes `Cell`s no longer necessary in most cases.
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-7/+0
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-10Register new snapshotsAlex Crichton-10/+2
2013-11-05Move implementation for threads to RustDirkjan Bussink-30/+97
This binds to the appropriate pthreads_* and Windows specific functions and calls them from Rust. This allows for removal of the C++ support code for threads. Fixes #10162
2013-10-28Register new snapshotsAlex Crichton-4/+3
2013-10-23Making fields in std and extra : private #4386reedlepee-3/+3
2013-10-19Use __morestack to detect stack overflowAlex Crichton-11/+32
This commit resumes management of the stack boundaries and limits when switching between tasks. This additionally leverages the __morestack function to run code on "stack overflow". The current behavior is to abort the process, but this is probably not the best behavior in the long term (for deails, see the comment I wrote up in the stack exhaustion routine).
2013-09-16switch Drop to `&mut self`Daniel Micay-1/+1
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-0/+6
2013-08-02librustc: Disallow "unsafe" for external functionsPatrick Walton-3/+3
2013-07-30std::rt: Change Thread interface to require an explicit joinBrian Anderson-4/+15
Makes it more obvious what's going on
2013-06-25Change finalize -> drop.Luqman Aden-1/+1
2013-06-01Remove all uses of `pub impl`. rs=stylePatrick Walton-2/+2
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-0/+44
This only changes the directory names; it does not change the "real" metadata names.