Skip to content

Move concurrent stuff from lib extra on a separate package #11910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ src/.DS_Store
/doc/rustdoc
/doc/rustuv
/doc/rustpkg
/doc/concurrency
/nd/
/llvm/
version.md
Expand Down
1 change: 1 addition & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ li {list-style-type: none; }
* [The `arena` allocation library](arena/index.html)
* [The `flate` compression library](flate/index.html)
* [The `glob` file path matching library](glob/index.html)
* [The `sync` mechanisms and primitives library](concurrency/index.html)

# Tooling

Expand Down
5 changes: 3 additions & 2 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
# automatically generated for all stage/host/target combinations.
################################################################################

TARGET_CRATES := std extra green rustuv native flate arena glob
TARGET_CRATES := std extra green rustuv native flate arena glob sync
HOST_CRATES := syntax rustc rustdoc rustpkg
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustpkg rustdoc rustc

DEPS_std := native:rustrt
DEPS_extra := std
DEPS_extra := std sync
DEPS_green := std
DEPS_rustuv := std native:uv native:uv_support
DEPS_native := std
Expand All @@ -66,6 +66,7 @@ DEPS_rustpkg := rustc
DEPS_flate := std native:miniz
DEPS_arena := std extra
DEPS_glob := std
DEPS_sync := std

TOOL_DEPS_compiletest := extra green rustuv
TOOL_DEPS_rustpkg := rustpkg green rustuv
Expand Down
10 changes: 2 additions & 8 deletions src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ Rust extras are part of the standard Rust distribution.
#[deny(non_camel_case_types)];
#[deny(missing_doc)];

extern mod sync;

// Utility modules

pub mod c_vec;

// Concurrency

pub mod sync;
pub mod arc;
pub mod comm;
pub mod future;
pub mod task_pool;

// Collections

pub mod container;
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use json;
use json::ToJson;
use serialize::{Encoder, Encodable, Decoder, Decodable};
use arc::{Arc,RWArc};
use sync::arc::{Arc,RWArc};
use treemap::TreeMap;
use std::str;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::io::{fs, File, BufferedWriter};
use std::str;
use std::vec;

use extra::arc::Arc;
use sync::arc::Arc;
use extra::json::ToJson;
use syntax::ast;
use syntax::attr;
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern mod syntax;
extern mod rustc;
extern mod extra;
extern mod sync;

use std::local_data;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use path_util::default_workspace;
pub use source_control::{safe_git_clone, git_clone_url};

use std::run;
use extra::arc::{Arc,RWArc};
use sync::arc::{Arc,RWArc};
use extra::workcache;
use extra::workcache::{Database, FreshnessMap};
use extra::treemap::TreeMap;
Expand Down
1 change: 1 addition & 0 deletions src/librustpkg/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
extern mod extra;
extern mod rustc;
extern mod syntax;
extern mod sync;

use std::{os, run, str, task};
use std::io::process;
Expand Down
4 changes: 2 additions & 2 deletions src/librustpkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::{os, run, str, task};
use std::io;
use std::io::fs;
use std::io::File;
use extra::arc::Arc;
use extra::arc::RWArc;
use sync::arc::Arc;
use sync::arc::RWArc;
use extra::tempfile::TempDir;
use extra::workcache;
use extra::workcache::Database;
Expand Down
9 changes: 1 addition & 8 deletions src/libextra/arc.rs → src/libsync/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* With simple pipes, without Arc, a copy would have to be made for each task.
*
* ```rust
* use extra::arc::Arc;
* use std::{rand, vec};
*
* let numbers = vec::from_fn(100, |i| (i as f32) * rand::random());
Expand All @@ -38,9 +37,6 @@
* ```
*/

#[allow(missing_doc)];


use sync;
use sync::{Mutex, RWLock};

Expand Down Expand Up @@ -419,8 +415,6 @@ impl<T:Freeze + Send> RWArc<T> {
* # Example
*
* ```rust
* use extra::arc::RWArc;
*
* let arc = RWArc::new(1);
* arc.write_downgrade(|mut write_token| {
* write_token.write_cond(|state, condvar| {
Expand Down Expand Up @@ -556,8 +550,7 @@ impl<'a, T:Freeze + Send> RWReadMode<'a, T> {
#[cfg(test)]
mod tests {

use arc::*;

use super::{Arc, RWArc, MutexArc};
use std::task;

#[test]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/libextra/future.rs → src/libsync/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* # Example
*
* ```rust
* use extra::future::Future;
* use concurrency::future::Future;
* # fn fib(n: uint) -> uint {42};
* # fn make_a_sandwich() {};
* let mut delayed_fib = Future::spawn(proc() { fib(5000) });
Expand Down
30 changes: 30 additions & 0 deletions src/libsync/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2012-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.

/*!
* Concurrency-enabled mechanisms and primitives.
*/

#[crate_id = "sync#0.10-pre"];
#[crate_type = "rlib"];
#[crate_type = "lib"];
#[license = "MIT/ASL2"];

pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode};
pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode, RWLockReadMode};
pub use comm::{DuplexStream, SyncChan, SyncPort};
pub use task_pool::TaskPool;
pub use future::Future;

pub mod arc;
pub mod sync;
pub mod comm;
pub mod task_pool;
pub mod future;
2 changes: 1 addition & 1 deletion src/libextra/sync.rs → src/libsync/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ impl Barrier {

#[cfg(test)]
mod tests {
use sync::*;
use sync::{RWLock, Mutex, Barrier, Semaphore, Condvar};

use std::cast;
use std::result;
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions src/test/bench/msgsend-ring-mutex-arcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
// This test creates a bunch of tasks that simultaneously send to each
// other in a ring. The messages should all be basically
// independent.
// This is like msgsend-ring-pipes but adapted to use Arcs.
// This is like msgsend-ring-pipes but adapted to use Arc.

// This also serves as a pipes test, because Arcs are implemented with pipes.

extern mod extra;
extern mod sync;

use extra::arc;
use extra::future::Future;
use sync::arc;
use sync::future::Future;
use extra::time;
use std::os;
use std::uint;
Expand Down
5 changes: 3 additions & 2 deletions src/test/bench/msgsend-ring-rw-arcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// This also serves as a pipes test, because Arcs are implemented with pipes.

extern mod extra;
extern mod sync;

use extra::arc;
use extra::future::Future;
use sync::arc;
use sync::future::Future;
use extra::time;
use std::os;
use std::uint;
Expand Down
3 changes: 2 additions & 1 deletion src/test/bench/shootout-binarytrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

extern mod extra;
extern mod arena;
extern mod sync;

use std::iter::range_step;
use extra::future::Future;
use sync::future::Future;
use arena::TypedArena;

enum Tree<'a> {
Expand Down
6 changes: 3 additions & 3 deletions src/test/bench/shootout-spectralnorm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

// xfail-test arcs no longer unwrap

extern mod extra;
extern mod sync;

use std::from_str::FromStr;
use std::iter::count;
use std::num::min;
use std::os;
use std::vec::from_elem;
use extra::arc::Arc;
use extra::arc::RWArc;
use sync::arc::Arc;
use sync::arc::RWArc;

fn A(i: uint, j: uint) -> f64 {
((i + j) * (i + j + 1) / 2 + i + 1) as f64
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/arc-cant-nest-rw-arc-3177.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
use extra::arc::RWArc;
extern mod sync;
use sync::arc::RWArc;

fn main() {
let arc1 = RWArc::new(true);
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

// error-pattern: lifetime of return value does not outlive the function call
extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None; //~ ERROR lifetime of variable does not enclose its declaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

// error-pattern: lifetime of variable does not enclose its declaration
extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

// error-pattern: lifetime of variable does not enclose its declaration
extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/functional-struct-update-noncopyable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// issue 7327

// xfail-fast #7103
extern mod extra;
use extra::arc::Arc;
extern mod sync;
use sync::arc::Arc;

struct A { y: Arc<int>, x: Arc<int> }

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/future_not_copyable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
extern mod sync;

use extra::future::Future;
use sync::future::Future;

fn main() {
let f = Future::from_value(());
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/mutex-arc-nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
extern mod sync;

use std::task;
use extra::arc::{MutexArc};
use sync::arc::{MutexArc};

fn test_mutex_arc_nested() {
let arc = ~MutexArc::new(1);
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/no-capture-arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

// error-pattern: use of moved value

extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;

use std::task;

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/no-reuse-move-arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;

use std::task;

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/once-cant-call-twice-on-heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// This program would segfault if it were legal.

#[feature(once_fns)];
extern mod extra;
use extra::arc;
extern mod sync;
use sync::arc;

fn foo(blk: proc()) {
blk();
Expand Down
Loading