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
private final LinkedBlockingQueue<Message> messageQueue = new LinkedBlockingQueue<Message>(); | |
// The sender argument is an enum describing who sent the message: the user, the app, or the person on the other end. | |
public void sendMessage(String address, String message, Sender sender) { | |
messageQueue.offer(Message.create(address, message, sender)); | |
startSenderThread(); | |
} | |
private Thread senderThread; |
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
package org.logician.sorta | |
import scala.util.Random | |
import scala.math | |
import scala.collection.mutable | |
import scala.collection.mutable.ArrayBuffer | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Austin |
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
Reading data from 'callgrind.out.3548'... | |
-------------------------------------------------------------------------------- | |
Profile data file 'callgrind.out.3548' (creator: callgrind-3.10.0.SVN) | |
-------------------------------------------------------------------------------- | |
I1 cache: | |
D1 cache: | |
LL cache: | |
Timerange: Basic block 0 - 29927136284 | |
Trigger: Program termination | |
Profiled target: ./img-dup --dir=/home/austin/Dropbox/ (PID 3548, part 1) |
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 std::num::FloatMath; | |
struct Tri { | |
sides: [Option<f32>, ..3], | |
angles: [Option<f32>, ..3], | |
ambiguous: Option<Box<Tri>>, | |
} | |
impl Tri { | |
fn from_vec(vals: &[Option<f32>]) -> Tri { |
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 Prepend<T> { | |
fn prepend(&mut self, t: T); | |
} | |
impl<S: Str> Prepend<S> for String { | |
fn prepend(&mut self, s: S) { | |
unsafe { | |
self.as_mut_vec().prepend(s.as_slice().as_bytes()); | |
} | |
} |
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
#![feature(phase)] | |
#![no_std] | |
#![feature(globs)] | |
#[phase(plugin, link)] | |
extern crate "std" as std; | |
#[prelude_import] | |
use std::prelude::*; | |
use std::collections::HashMap; | |
struct Foo<'a> { |
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 std::io::{self, Read, Write}; | |
fn xor(x: char, y: char) -> char { | |
// Rust lacks the ternary operator. | |
// Since if-blocks are expressions, it'd be redundant. | |
if x != y { '1' } else { '0' } | |
} | |
fn or(x: char, y: char) -> char { | |
if x == '1' || y == '1' { '1' } else { '0' } |
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
PS C:\Users\Austin\Rust\wingui> cargo rustc -p winapi -- -Ztime-passes | |
Compiling winapi v0.2.4 | |
time: 0.225; rss: 66MB parsing | |
time: 0.066; rss: 71MB configuration 1 | |
time: 0.000; rss: 71MB recursion limit | |
time: 0.003; rss: 71MB gated macro checking | |
time: 0.000; rss: 71MB crate injection | |
time: 0.011; rss: 73MB macro loading | |
time: 0.000; rss: 73MB plugin loading | |
time: 0.000; rss: 73MB plugin registration |
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
#![cfg_attr(test, feature(test))] | |
#[cfg(test)] | |
#[macro_use] | |
extern crate lazy_static; | |
use std::mem; | |
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; | |
pub const INIT: AtomicBitSet = AtomicBitSet { |
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
$ # Generate 8 MB of random data | |
$ head -c 8M < /dev/urandom > data.txt | |
$ # Flush and clear the cache so we get the data from disk | |
$ sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && cargo script posix_fadvise_test.rs | |
3 | |
Compiling posix_fadvise_test v0.1.0 (file:///home/austin/.cargo/script-cache/file-posix_fadvise_test-8d6a7e80a3131286) | |
Advised result: HashResult { hash: [173, 168, 157, 204, 185, 126, 165, 177, 195, 111, 94, 179, 252, 59, 25, 169], time: Duration { secs: 0, nanos: 10050785 } } | |
$ # Comment out the call to advise_willneed, save, flush again and re-run | |
$ sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && cargo script posix_fadvise_test.rs | |
3 |
OlderNewer