Before we begin, a few warnings.
- This talk contains code. It contains a lot of code, and you are encouraged to type it in and run it yourself. If you are allergic to code,
# credits to virtualenv | |
kerl_deactivate() | |
{ | |
if [ -n "$_KERL_PATH_REMOVABLE" ]; then | |
PATH=${PATH//${_KERL_PATH_REMOVABLE}:/} | |
export PATH | |
unset _KERL_PATH_REMOVABLE | |
fi | |
if [ -n "$_KERL_MANPATH_REMOVABLE" ]; then | |
MANPATH=${MANPATH//${_KERL_MANPATH_REMOVABLE}:/} |
$ mix test | |
Compiling NIF crate :rustler_test (/)... | |
Compiling lazy_static v0.1.16 | |
Compiling libc v0.2.17 | |
Compiling bitflags v0.7.0 | |
Compiling quote v0.3.5 | |
Compiling winapi v0.2.8 | |
Compiling unicode-xid v0.0.3 | |
Compiling log v0.3.6 | |
Compiling winapi-build v0.1.1 |
use std::hash::Hash; | |
use std::collections::{HashSet, VecDeque}; | |
use std::marker::PhantomData; | |
pub trait Digraph { | |
type Vertex: std::cmp::Eq; | |
type Neighbors: IntoIterator<Item=Self::Vertex>; | |
fn neighbors(&self, Self::Vertex) -> Self::Neighbors; |
import unicodedata | |
# Unique value meaning "not finished parsing" | |
class TimedOut: | |
def __repr__(self): return "TimedOut" | |
TimedOut = TimedOut() | |
BASIC_ESCAPES = { |
// OK so to start with here's the EventHandler trait, just like slack-rs | |
pub trait EventHandler { | |
// I don't know what kind of thing EventData should be. | |
// maybe Json? whatever events actually are in phoenix. | |
fn on_event(&mut self, channel_name: &str, event_type: &str, event_data: EventData); | |
fn on_connect(&mut self, ...); | |
fn on_close(&mut self, ...); | |
} | |
fn login_and_run<H: EventHandler>(handler: H, ...) {...} |
// usage: ./yep | head -n 1 | |
use std::time::Duration; | |
use std::thread::sleep; | |
fn main() { | |
loop { | |
println!("y"); // expected: panic | |
sleep(Duration::new(0, 250000000)); | |
} |
//! Some generic code for launching a service. | |
use std::sync::mpsc::{Sender, channel}; | |
use std::thread::{spawn, JoinHandle}; | |
/// Wrapper around a JoinHandle that automatically joins when dropped. | |
struct AutoJoinHandle(Option<JoinHandle<()>>); | |
impl Drop for AutoJoinHandle { | |
fn drop(&mut self) { |
// Incomplete channel implementation using a MPSC node-based queue. | |
// | |
// Algorithm: <http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue> | |
// | |
// Differences from `std::sync::mpsc::channel`: | |
// - blocking `recv` is not implemented | |
// - closing the channel by dropping senders is not implemented | |
// - closing the channel by dropping the receiver is not implemented | |
// - nodes are leaked when the receiver is dropped |
~/dev/programming-erlang$ erl | |
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] | |
Eshell V8.0 (abort with ^G) | |
1> timer:tc(loop, loop_test, [100, 10000]). | |
spawning processes... | |
starting test... | |
done! | |
{348645,ok} | |
2> timer:tc(loop, loop_test, [100, 10000]). |