This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1287 #[test] | |
1288 #[should_fail] | |
1289 #[ignore(cfg(windows))] | |
1290 fn test_tls_cleanup_on_failure() unsafe { | |
1291 fn str_key(+_x: @str) { } | |
1292 fn box_key(+_x: @@()) { } | |
1293 fn int_key(+_x: @int) { } | |
1294 local_data_set(str_key, @"parent data"); | |
1295 local_data_set(box_key, @@()); | |
1296 task::spawn{|| // spawn_linked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! A map type | |
import chained::hashmap; | |
export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash; | |
export unique_str_hash; | |
export bytes_hash, int_hash, uint_hash, set_add; | |
export hash_from_vec, hash_from_strs, hash_from_bytes; | |
export hash_from_ints, hash_from_uints; | |
export vec_from_set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
* A rust-scheduler-enabled concurrency primitive for mutual exclusion and | |
* blocking/signalling. | |
* | |
* This code is intimately linked with task killing, so interacts with tasks' | |
* kill_locks in a complicated way. Because killing a task also needs to punt | |
* it off of cvar wait queues, it needs to take the cvar's lock too. | |
* | |
* NB: Rules for locking order & data ownership are as follows: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn shared_state_task(..., other_ch: comm::chan<()>) { | |
while ... { | |
... | |
match msg { | |
... | |
deref { | |
... | |
if new_refcount == 0 { break; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use with extreme caution. | |
# You will probably need to \definecolor several of these. | |
IFS='\n' | |
while read line; do | |
echo -n "\\texttt{" | |
echo -n "$line" | sed 's/{/\\{/g' | sed 's/}/\\}/g' | sed 's/_/\\_/g' | sed 's/~/\\textasciitilde/g' | sed 's/ /~/g' | sed 's/^\t*//' | sed 's/%/\\%/g' | sed 's/&/\\\&/g' | \ | |
sed 's/\<fn\>/\\hilight{brown}{fn}/g' | \ | |
sed 's/\<do\>/\\hilight{brown}{do}/g' | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn send_message_to_memory_watcher() { | |
// this is code that all tasks will run | |
let chan = get_memory_watcher_chan(); | |
chan.send(...message...); | |
} | |
fn get_memory_watcher_chan() -> shared_chan<MemoryWatcherMessage> { | |
let shared_chan_ptr = rustrt::get_global_shared_chan_ptr(); | |
// Double-check locking. (look this up on wikipedia if you don't know what | |
// it means) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use either::{Either,Left,Right}; | |
// SharedMutableState is an unsafe internal library used by both the ARC and the RWARC. | |
use private::{SharedMutableState, shared_mutable_state, clone_shared_mutable_state, | |
get_shared_mutable_state, get_shared_immutable_state}; | |
type ARC<T: Send> = SharedMutableState<T>; | |
fn ARC<T: Send>(data: T) -> ARC<T> unsafe { shared_mutable_state(data) } | |
fn clone<T: Send>(x: &ARC<T>) -> ARC<T> unsafe { clone_shared_mutable_state(x) } | |
fn get<T: Send>(x: &a/ARC<T>) -> &a/T unsafe { get_shared_immutable_state(x) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} | |
module Main where | |
import Control.Monad (when) | |
import Control.Applicative ((<$>)) | |
class Nat n | |
newtype Zero = Zero () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Nat { } | |
enum Zero = (); | |
enum Suc<N: Nat> = N; | |
impl | |
// ---------- | |
Zero : Nat { } | |
impl <N: Nat> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn foo<'a>(blk: &fn(bar: &'a fn() -> &'a fn())) { | |
let x = 5; | |
let bar: &fn() = || { io::println(fmt!("%d", x)); }; | |
do blk || { bar }; | |
} | |
fn main() { | |
do foo |bar| { bar()(); } | |
} |
OlderNewer