diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-05-19 01:13:53 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-05-20 15:20:50 -0700 |
| commit | 43c6f32ece85a7df86ee041771a54c097dae6a13 (patch) | |
| tree | 56a6dd543abc30bdc0f77e30772bc2a6ca9ac146 | |
| parent | b0722c55f8205a43a0b8124ca179dada766c23ed (diff) | |
| download | rust-43c6f32ece85a7df86ee041771a54c097dae6a13.tar.gz rust-43c6f32ece85a7df86ee041771a54c097dae6a13.zip | |
core::rt: Add Local trait
| -rw-r--r-- | src/libcore/rt/local.rs | 17 | ||||
| -rw-r--r-- | src/libcore/rt/mod.rs | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/libcore/rt/local.rs b/src/libcore/rt/local.rs new file mode 100644 index 00000000000..ec54bcb99dd --- /dev/null +++ b/src/libcore/rt/local.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Local { + fn put_local(value: ~Self); + fn take_local() -> ~Self; + fn exists() -> bool; + fn borrow(f: &fn(&mut Self)); + fn unsafe_borrow() -> *mut Self; +} diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs index 208a6de46e8..37ac6ad3365 100644 --- a/src/libcore/rt/mod.rs +++ b/src/libcore/rt/mod.rs @@ -81,6 +81,10 @@ mod rtio; #[path = "uv/mod.rs"] pub mod uv; +/// The Local trait for types that are accessible via thread-local +/// or task-local storage. +pub mod local; + // FIXME #5248: The import in `sched` doesn't resolve unless this is pub! /// Bindings to pthread/windows thread-local storage. pub mod thread_local_storage; |
