Skip to content

Commit a495f9c

Browse files
committed
---
yaml --- r: 103950 b: refs/heads/try c: ec2f047 h: refs/heads/master v: v3
1 parent f5db708 commit a495f9c

File tree

340 files changed

+214
-3068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+214
-3068
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: 1fd2d7786013f98c59f099a2a0413b61a6e82d9d
5+
refs/heads/try: ec2f047aa9a09926b9c4192c447f44dda484ee6d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ src/.DS_Store
7575
/nd/
7676
/llvm/
7777
version.md
78-
*.tex
7978
keywords.md
8079
x86_64-apple-darwin/
8180
x86_64-unknown-linux-gnu/

branches/try/mk/docs.mk

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ HTML_DEPS := doc/
1919

2020
BASE_DOC_OPTS := --standalone --toc --number-sections
2121
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css \
22-
--include-before-body=doc/version_info.html --include-in-header=doc/favicon.inc
23-
TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md --to=latex
22+
--include-before-body=doc/version_info.html \
23+
--include-in-header=doc/favicon.inc --include-after-body=doc/footer.inc
24+
TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md \
25+
--from=markdown --include-before-body=doc/footer.tex --to=latex
2426
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub
2527

2628
D := $(S)src/doc
@@ -55,12 +57,21 @@ doc/rust.css: $(D)/rust.css | doc/
5557
@$(call E, cp: $@)
5658
$(Q)cp -a $< $@ 2> /dev/null
5759

60+
HTML_DEPS += doc/favicon.inc
61+
doc/favicon.inc: $(D)/favicon.inc | doc/
62+
@$(call E, cp: $@)
63+
$(Q)cp -a $< $@ 2> /dev/null
64+
5865
doc/full-toc.inc: $(D)/full-toc.inc | doc/
5966
@$(call E, cp: $@)
6067
$(Q)cp -a $< $@ 2> /dev/null
6168

62-
HTML_DEPS += doc/favicon.inc
63-
doc/favicon.inc: $(D)/favicon.inc | doc/
69+
HTML_DEPS += doc/footer.inc
70+
doc/footer.inc: $(D)/footer.inc | doc/
71+
@$(call E, cp: $@)
72+
$(Q)cp -a $< $@ 2> /dev/null
73+
74+
doc/footer.tex: $(D)/footer.tex | doc/
6475
@$(call E, cp: $@)
6576
$(Q)cp -a $< $@ 2> /dev/null
6677

@@ -83,7 +94,7 @@ doc/rust.html: $(D)/rust.md doc/full-toc.inc $(HTML_DEPS) | doc/
8394
$(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/full-toc.inc --output=$@
8495

8596
DOCS += doc/rust.tex
86-
doc/rust.tex: $(D)/rust.md doc/version.md | doc/
97+
doc/rust.tex: $(D)/rust.md doc/footer.tex doc/version.md | doc/
8798
@$(call E, pandoc: $@)
8899
$(Q)$(CFG_NODE) $(D)/prep.js $< | \
89100
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
@@ -107,7 +118,7 @@ doc/tutorial.html: $(D)/tutorial.md $(HTML_DEPS)
107118
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
108119

109120
DOCS += doc/tutorial.tex
110-
doc/tutorial.tex: $(D)/tutorial.md doc/version.md
121+
doc/tutorial.tex: $(D)/tutorial.md doc/footer.tex doc/version.md
111122
@$(call E, pandoc: $@)
112123
$(Q)$(CFG_NODE) $(D)/prep.js $< | \
113124
$(CFG_PANDOC) $(TEX_OPTS) --output=$@

branches/try/mk/tests.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
242242
tidy:
243243
@$(call E, check: formatting)
244244
$(Q)find $(S)src -name '*.r[sc]' \
245+
| grep '^$(S)src/test' -v \
245246
| grep '^$(S)src/libuv' -v \
246247
| grep '^$(S)src/llvm' -v \
247248
| grep '^$(S)src/gyp' -v \

branches/try/src/doc/footer.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<footer><p>
2+
Copyright &copy; 2011-2014 The Rust Project Developers. Licensed under the
3+
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
4+
or the <a href="http://opensource.org/licenses/MIT">MIT license</a>, at your option.
5+
</p><p>
6+
This file may not be copied, modified, or distributed except according to those terms.
7+
</p></footer>

branches/try/src/doc/footer.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright © 2011-2014 The Rust Project Developers. Licensed under the
2+
\href{http://www.apache.org/licenses/LICENSE-2.0}{Apache License,
3+
Version 2.0} or the \href{http://opensource.org/licenses/MIT}{MIT
4+
license}, at your option.
5+
6+
This file may not be copied, modified, or distributed except according
7+
to those terms.

branches/try/src/doc/guide-runtime.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ extern mod green;
236236
237237
#[start]
238238
fn start(argc: int, argv: **u8) -> int {
239-
green::start(argc, argv, main)
239+
green::start(argc, argv, proc() {
240+
main();
241+
})
240242
}
241243
242244
fn main() {}

branches/try/src/doc/rust.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
body {
1616
margin: 0 auto;
1717
padding: 0 15px;
18-
margin-bottom: 4em;
1918
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
2019
font-size: 14px;
2120
color: #333;
@@ -76,6 +75,15 @@ p {
7675
margin: 0 0 10px;
7776
}
7877

78+
footer {
79+
border-top: 1px solid #ddd;
80+
font-size: 12px;
81+
font-style: italic;
82+
padding-top: 4px;
83+
margin-top: 4em;
84+
margin-bottom: 1em;
85+
}
86+
7987
/* Links layout
8088
========================================================================== */
8189
a {

branches/try/src/etc/tidy.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
err=0
1616
cols=100
17-
cr_flag="xfail-tidy-cr"
18-
tab_flag="xfail-tidy-tab"
19-
linelength_flag="xfail-tidy-linelength"
2017

2118
# Be careful to support Python 2.4, 2.6, and 3.x here!
2219
config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],
@@ -49,22 +46,12 @@ def do_license_check(name, contents):
4946

5047
current_name = ""
5148
current_contents = ""
52-
check_tab = True
53-
check_cr = True
54-
check_linelength = True
55-
5649

5750
try:
5851
for line in fileinput.input(file_names,
5952
openhook=fileinput.hook_encoded("utf-8")):
6053

6154
if fileinput.filename().find("tidy.py") == -1:
62-
if line.find(cr_flag) != -1:
63-
check_cr = False
64-
if line.find(tab_flag) != -1:
65-
check_tab = False
66-
if line.find(linelength_flag) != -1:
67-
check_linelength = False
6855
if line.find("// XXX") != -1:
6956
report_err("XXX is no longer necessary, use FIXME")
7057
if line.find("TODO") != -1:
@@ -85,16 +72,16 @@ def do_license_check(name, contents):
8572
if "SNAP" in line:
8673
report_warn("unmatched SNAP line: " + line)
8774

88-
if check_tab and (line.find('\t') != -1 and
75+
if (line.find('\t') != -1 and
8976
fileinput.filename().find("Makefile") == -1):
9077
report_err("tab character")
91-
if check_cr and not autocrlf and line.find('\r') != -1:
78+
if not autocrlf and line.find('\r') != -1:
9279
report_err("CR character")
9380
if line.endswith(" \n") or line.endswith("\t\n"):
9481
report_err("trailing whitespace")
9582
line_len = len(line)-2 if autocrlf else len(line)-1
9683

97-
if check_linelength and line_len > cols:
84+
if line_len > cols:
9885
report_err("line longer than %d chars" % cols)
9986

10087
if fileinput.isfirstline() and current_name != "":
@@ -103,9 +90,6 @@ def do_license_check(name, contents):
10390
if fileinput.isfirstline():
10491
current_name = fileinput.filename()
10592
current_contents = ""
106-
check_cr = True
107-
check_tab = True
108-
check_linelength = True
10993

11094
current_contents += line
11195

branches/try/src/libgreen/lib.rs

Lines changed: 3 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -12,156 +12,10 @@
1212
//!
1313
//! This library provides M:N threading for rust programs. Internally this has
1414
//! the implementation of a green scheduler along with context switching and a
15-
//! stack-allocation strategy. This can be optionally linked in to rust
16-
//! programs in order to provide M:N functionality inside of 1:1 programs.
15+
//! stack-allocation strategy.
1716
//!
18-
//! # Architecture
19-
//!
20-
//! An M:N scheduling library implies that there are N OS thread upon which M
21-
//! "green threads" are multiplexed. In other words, a set of green threads are
22-
//! all run inside a pool of OS threads.
23-
//!
24-
//! With this design, you can achieve _concurrency_ by spawning many green
25-
//! threads, and you can achieve _parallelism_ by running the green threads
26-
//! simultaneously on multiple OS threads. Each OS thread is a candidate for
27-
//! being scheduled on a different core (the source of parallelism), and then
28-
//! all of the green threads cooperatively schedule amongst one another (the
29-
//! source of concurrency).
30-
//!
31-
//! ## Schedulers
32-
//!
33-
//! In order to coordinate among green threads, each OS thread is primarily
34-
//! running something which we call a Scheduler. Whenever a reference to a
35-
//! Scheduler is made, it is synonymous to referencing one OS thread. Each
36-
//! scheduler is bound to one and exactly one OS thread, and the thread that it
37-
//! is bound to never changes.
38-
//!
39-
//! Each scheduler is connected to a pool of other schedulers (a `SchedPool`)
40-
//! which is the thread pool term from above. A pool of schedulers all share the
41-
//! work that they create. Furthermore, whenever a green thread is created (also
42-
//! synonymously referred to as a green task), it is associated with a
43-
//! `SchedPool` forevermore. A green thread cannot leave its scheduler pool.
44-
//!
45-
//! Schedulers can have at most one green thread running on them at a time. When
46-
//! a scheduler is asleep on its event loop, there are no green tasks running on
47-
//! the OS thread or the scheduler. The term "context switch" is used for when
48-
//! the running green thread is swapped out, but this simply changes the one
49-
//! green thread which is running on the scheduler.
50-
//!
51-
//! ## Green Threads
52-
//!
53-
//! A green thread can largely be summarized by a stack and a register context.
54-
//! Whenever a green thread is spawned, it allocates a stack, and then prepares
55-
//! a register context for execution. The green task may be executed across
56-
//! multiple OS threads, but it will always use the same stack and it will carry
57-
//! its register context across OS threads.
58-
//!
59-
//! Each green thread is cooperatively scheduled with other green threads.
60-
//! Primarily, this means that there is no pre-emption of a green thread. The
61-
//! major consequence of this design is that a green thread stuck in an infinite
62-
//! loop will prevent all other green threads from running on that particular
63-
//! scheduler.
64-
//!
65-
//! Scheduling events for green threads occur on communication and I/O
66-
//! boundaries. For example, if a green task blocks waiting for a message on a
67-
//! channel some other green thread can now run on the scheduler. This also has
68-
//! the consequence that until a green thread performs any form of scheduling
69-
//! event, it will be running on the same OS thread (unconditionally).
70-
//!
71-
//! ## Work Stealing
72-
//!
73-
//! With a pool of schedulers, a new green task has a number of options when
74-
//! deciding where to run initially. The current implementation uses a concept
75-
//! called work stealing in order to spread out work among schedulers.
76-
//!
77-
//! In a work-stealing model, each scheduler maintains a local queue of tasks to
78-
//! run, and this queue is stolen from by other schedulers. Implementation-wise,
79-
//! work stealing has some hairy parts, but from a user-perspective, work
80-
//! stealing simply implies what with M green threads and N schedulers where
81-
//! M > N it is very likely that all schedulers will be busy executing work.
82-
//!
83-
//! # Considerations when using libgreen
84-
//!
85-
//! An M:N runtime has both pros and cons, and there is no one answer as to
86-
//! whether M:N or 1:1 is appropriate to use. As always, there are many
87-
//! advantages and disadvantages between the two. Regardless of the workload,
88-
//! however, there are some aspects of using green thread which you should be
89-
//! aware of:
90-
//!
91-
//! * The largest concern when using libgreen is interoperating with native
92-
//! code. Care should be taken when calling native code that will block the OS
93-
//! thread as it will prevent further green tasks from being scheduled on the
94-
//! OS thread.
95-
//!
96-
//! * Native code using thread-local-storage should be approached
97-
//! with care. Green threads may migrate among OS threads at any time, so
98-
//! native libraries using thread-local state may not always work.
99-
//!
100-
//! * Native synchronization primitives (e.g. pthread mutexes) will also not
101-
//! work for green threads. The reason for this is because native primitives
102-
//! often operate on a _os thread_ granularity whereas green threads are
103-
//! operating on a more granular unit of work.
104-
//!
105-
//! * A green threading runtime is not fork-safe. If the process forks(), it
106-
//! cannot expect to make reasonable progress by continuing to use green
107-
//! threads.
108-
//!
109-
//! Note that these concerns do not mean that operating with native code is a
110-
//! lost cause. These are simply just concerns which should be considered when
111-
//! invoking native code.
112-
//!
113-
//! # Starting with libgreen
114-
//!
115-
//! ```rust
116-
//! extern mod green;
117-
//!
118-
//! #[start]
119-
//! fn start(argc: int, argv: **u8) -> int { green::start(argc, argv, main) }
120-
//!
121-
//! fn main() {
122-
//! // this code is running in a pool of schedulers
123-
//! }
124-
//! ```
125-
//!
126-
//! # Using a scheduler pool
127-
//!
128-
//! ```rust
129-
//! use std::task::TaskOpts;
130-
//! use green::{SchedPool, PoolConfig};
131-
//! use green::sched::{PinnedTask, TaskFromFriend};
132-
//!
133-
//! let config = PoolConfig::new();
134-
//! let mut pool = SchedPool::new(config);
135-
//!
136-
//! // Spawn tasks into the pool of schedulers
137-
//! pool.spawn(TaskOpts::new(), proc() {
138-
//! // this code is running inside the pool of schedulers
139-
//!
140-
//! spawn(proc() {
141-
//! // this code is also running inside the same scheduler pool
142-
//! });
143-
//! });
144-
//!
145-
//! // Dynamically add a new scheduler to the scheduler pool. This adds another
146-
//! // OS thread that green threads can be multiplexed on to.
147-
//! let mut handle = pool.spawn_sched();
148-
//!
149-
//! // Pin a task to the spawned scheduler
150-
//! let task = pool.task(TaskOpts::new(), proc() { /* ... */ });
151-
//! handle.send(PinnedTask(task));
152-
//!
153-
//! // Schedule a task on this new scheduler
154-
//! let task = pool.task(TaskOpts::new(), proc() { /* ... */ });
155-
//! handle.send(TaskFromFriend(task));
156-
//!
157-
//! // Handles keep schedulers alive, so be sure to drop all handles before
158-
//! // destroying the sched pool
159-
//! drop(handle);
160-
//!
161-
//! // Required to shut down this scheduler pool.
162-
//! // The task will fail if `shutdown` is not called.
163-
//! pool.shutdown();
164-
//! ```
17+
//! This can be optionally linked in to rust programs in order to provide M:N
18+
//! functionality inside of 1:1 programs.
16519
16620
#[crate_id = "green#0.10-pre"];
16721
#[license = "MIT/ASL2"];

branches/try/src/libnative/lib.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! The native I/O and threading crate
11+
//! The native runtime crate
1212
//!
1313
//! This crate contains an implementation of 1:1 scheduling for a "native"
1414
//! runtime. In addition, all I/O provided by this crate is the thread blocking
1515
//! version of I/O.
16-
//!
17-
//! # Starting with libnative
18-
//!
19-
//! ```rust
20-
//! extern mod native;
21-
//!
22-
//! #[start]
23-
//! fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) }
24-
//!
25-
//! fn main() {
26-
//! // this code is running on the main OS thread
27-
//! }
28-
//! ```
29-
//!
30-
//! # Force spawning a native task
31-
//!
32-
//! ```rust
33-
//! extern mod native;
34-
//!
35-
//! fn main() {
36-
//! // We're not sure whether this main function is run in 1:1 or M:N mode.
37-
//!
38-
//! native::task::spawn(proc() {
39-
//! // this code is guaranteed to be run on a native thread
40-
//! });
41-
//! }
42-
//! ```
4316
4417
#[crate_id = "native#0.10-pre"];
4518
#[license = "MIT/ASL2"];

0 commit comments

Comments
 (0)