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
#include <sstream> | |
#include <iostream> | |
struct formatter { | |
std::string format; | |
formatter(const std::string &format_) | |
: format(format_) {} | |
formatter(const formatter &other) = delete; | |
formatter(formatter &&other) |
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
Finalizer Logic | |
struct Ptr { | |
void *value; | |
} | |
Finalize(Ptr ptr) { | |
free(ptr.value); | |
} |
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::vec; | |
use std::util::replace; | |
pub struct FlatMap<K, V> { | |
priv data: ~[(K, V)], | |
} | |
impl<K, V> FlatMap<K, V> { | |
fn new(capacity: uint) -> FlatMap<K, V> { | |
FlatMap{data: vec::with_capacity(capacity)} |
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::unstable::sync::UnsafeArc; | |
use std::unstable::atomics::{AtomicPtr,Relaxed,Release,Acquire}; | |
use std::ptr::{mut_null, to_mut_unsafe_ptr}; | |
use std::cast; | |
use std::task; | |
use std::comm; | |
use std::fmt; | |
struct Node<T> { | |
next: AtomicPtr<Node<T>>, |
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 simple SSH server providing bash sessions | |
// | |
// Server: | |
// cd my/new/dir/ | |
// ssh-keygen -t rsa #generate server keypair | |
// go get -v . | |
// go run sshd.go | |
// | |
// Client: | |
// ssh foo@localhost -p 2022 #pass=bar |
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 future | |
// A Future represents the result of some asynchronous computation. | |
// Future returns the result of the work as an error, or nil if the work | |
// was performed successfully. | |
// Implementers must observe these invariants | |
// 1. There may be multiple concurrent callers, or Future may be called many | |
// times in sequence, it must always return the same value. | |
// 2. Future blocks until the work has been performed. | |
type Future func() error |
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
///! This package provides a skeleton for read-only access to FlatBuffer encoded binary data. | |
const std = @import("std"); | |
const assert = std.debug.assert; | |
const t = std.testing; | |
/// Header represents the data at offset 0 | |
/// it consists of an unsigned offset to the root table | |
/// and optionally a 4-byte file identifier | |
const Header = packed struct { | |
offset: u32, // root table offset |