Skip to content

Instantly share code, notes, and snippets.

View olsonjeffery's full-sized avatar
💭
:3

Jeff Olson olsonjeffery

💭
:3
View GitHub Profile
/// The Promise type. Can provide the value of a Future
pub struct Promise<A> (ChanOne<A>);
impl<A:Send> Promise<A> {
pub fn fulfill(&mut self, v: A) {
(*self).send(v);
}
}
use std::io::println;
use std::result::{Result, Ok};
use std::task::{spawn};
pub struct Foo(int);
pub trait Bar {
fn baz(&self);
}
@olsonjeffery
olsonjeffery / gist:6135919
Last active December 20, 2015 13:08
~object issue?
/home/jeff/src/rust/src/libstd/rt/uv/uvio.rs:312:27: 312:77 error: failed to find an implementation of trait ~rt::rtaio::RtaioTcpStreamAsync:Send for rt::uv::uvaio::UvTcpStreamAsync
/home/jeff/src/rust/src/libstd/rt/uv/uvio.rs:312 Ok(_) => cb(Ok(~UvTcpStreamAsync(watcher) as ~RtaioTcpStreamAsync)),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
jeff@mbp:~/src/rust/build$ make check-stage1-extra
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: using gcc
cfg: no pandoc found, omitting docs
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
@olsonjeffery
olsonjeffery / newsched_timer.rs
Last active December 20, 2015 00:39
rustc spew
jeff@mbp:~/src/sandbox$ rustc newsched_timer.rs
newsched_timer.rs:4:4: 4:19 warning: unused import [-W unused-imports (default)]
newsched_timer.rs:4 use std::option::*;
^~~~~~~~~~~~~~~
error: linking with `cc` failed with code 1
note: cc arguments: -L/home/jeff/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o newsched_timer newsched_timer.o -L/home/jeff/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-6c65cf4b443341b1-0.8-pre -lrustrt -lrt -lpthread -lrt -ldl -lm -lmorestack -lrustrt -Wl,-rpath,$ORIGIN/../../lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/home/jeff/lib/rustc/x86_64-unknown-linux-gnu/lib
note: newsched_timer.o: In function `main::_b34d73d589378df4::_0$x2e0':
newsched_timer.rc:(.text+0x69): undefined reference to `rt::io::timer::__extensions__::meth_29117::init::_5139afb69d2758a::_0$x2e8$x2dpre'
collect2: error: ld returned 1 exit status
@olsonjeffery
olsonjeffery / gist:5961159
Last active December 19, 2015 13:19
notes for newsched work
https://github.com/mozilla/rust/issues/6435
14:05 < ecr> olsonjeffery: it'd involve
- designing an RtioTimer interface in std::rt::rtio.rs,
- implementing Timer in std::rt::io on top of it,
- implementing RtioTimer for TimerWatcher in std::rt::uv::uvio.rs
14:09 < ecr> olsonjeffery: and you might want to look at the libuv timer interface as well to see if there's any additional functionality that still needs bindings (which would
give you the bottom layer of newsched I/O in std::rt::uv::uvll.rs).
14:12 <ecr> if I'm not responding in IRC, try email ([email protected]).
@olsonjeffery
olsonjeffery / gist:5145243
Created March 12, 2013 17:56
outstanding uses of ->malloc in src/rt
jeff@mbp:~/src/rust/build$ find ../src/rt/ -name '*.cpp' -exec grep '.->malloc' -H -n {} \;
../src/rt/rust_builtin.cpp:98: rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng),
../src/rt/rust_stack.cpp:61: stk_seg *stk = (stk_seg *)region->malloc(total_sz, "stack");
../src/rt/rust_stack.cpp:78: stk_seg *stk = (stk_seg *)exchange->malloc(total_sz);
../src/rt/rust_uv.cpp:40: void* ptr = rust_get_current_task()->kernel->malloc(size, tag);
../src/rt/boxed_region.cpp:22: (rust_opaque_box*)backing_region->malloc(total_size, "@");
unsafe fn get_list(p: &Path) -> ~[~str] {
use libc::{DIR, dirent_t};
use libc::{opendir, readdir, closedir};
extern mod rustrt {
unsafe fn rust_list_dir_val(ptr: *dirent_t)
-> *libc::c_char;
}
let input = p.to_str();
let mut strings = ~[];
let input_ptr = ::cast::transmute(&input[0]);
@olsonjeffery
olsonjeffery / gist:4759830
Created February 12, 2013 02:49
target-triples config for multi-arch rust build testing..
../configure --target-triples=x86_64-apple-darwin,i686-apple-darwin --disable-optimize --disable-optimize-cxx
@olsonjeffery
olsonjeffery / gist:4736874
Created February 8, 2013 05:33
using find+grep
find . -name '*.cpp' -exec grep '.->malloc' -H -n {} \;