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
pub struct Request { | |
head: Parts, | |
} | |
pub struct Parts { | |
pub method: String, | |
pub uri: String, | |
pub http_version: String, | |
} |
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
import exception.ParseException | |
import token._ | |
trait Lexer { | |
protected val input: String | |
protected var p: Int | |
protected var current: Char |
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
extern crate hyper; | |
extern crate tokio_core; | |
extern crate futures; | |
use hyper::{Client, Uri}; | |
use tokio_core::reactor::Core; | |
use futures::future::Future; | |
// 処理のブロックが起きてしまっている例 | |
fn main() { |
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
@FunctionalInterface | |
public interface ThrowableSupplier<T> { | |
T get() throws Exception; | |
} |
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
public void start() throws NioHttpServerException { | |
InputStream inputStream = inputStream(); | |
requestHandler | |
.apply(inputStream) | |
.toStream() | |
.map( | |
v -> { | |
switch (v.status()) { | |
case OK: |
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 void doRead(SocketChannel socketChannel) throws NioHttpServerException { | |
try { | |
ByteBuffer buf = ByteBuffer.allocate(1024); | |
socketChannel.read(buf); | |
buf.flip(); | |
Option<Request> maybeRequest = requestHandler.apply(buf); | |
buf.clear(); | |
Option<Either<Exception, Response>> maybeResponse = |
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::fmt; | |
use std::cell::RefCell; | |
pub struct Machine { | |
pub expression: RefCell<Token>, | |
} | |
impl Machine { | |
pub fn new(expression: Token) -> Self { | |
Machine { |
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
import scala.collection.mutable | |
import scala.util.Random | |
case class ChainedHashTable[A](private var t: Array[mutable.ListBuffer[A]], | |
private var d: Int, | |
private var n: Int = 0, | |
private var z: Int) | |
extends USet[A] { | |
private[this] lazy val w: Int = 32 |
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::future::Future; | |
use std::ops::{Deref, DerefMut}; | |
use std::pin::Pin; | |
use std::sync::mpsc::{channel, Receiver}; | |
use std::sync::{Arc, Condvar, Mutex}; | |
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; | |
use std::thread; | |
pub struct ReturnFuture<T>(Option<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
sealed trait IO[+A] { | |
import IO._ | |
def map[B](f: A => B): IO[B] = this match { | |
case Map(original, g, index) if index != 128 => | |
Map(original, g.andThen(f), index + 1) | |
case _ => Map(this, f, 0) | |
} |
OlderNewer