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
require 'thread' | |
class Waiter | |
def initialize | |
@mutex = Mutex.new | |
end | |
def can_eat? philosopher | |
left = philosopher.left_fork | |
right = philosopher.right_fork |
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
require 'rubygems' | |
require 'celluloid' | |
class Waiter | |
include Celluloid | |
FORK_FREE = 0 | |
FORK_USED = 1 | |
attr_reader :philosophers | |
attr_reader :forks | |
attr_reader :eating |
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 Control.Monad | |
import Control.Concurrent | |
import Control.Concurrent.STM | |
import System.Random | |
import Text.Printf | |
-- Forks | |
type Fork = TMVar Int | |
newFork :: Int -> IO Fork |
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
require 'rubygems' | |
require 'celluloid' | |
class Philosopher | |
include Celluloid | |
def initialize(name, left_fork, right_fork) | |
@name = name | |
@left_fork = left_fork | |
@right_fork = right_fork | |
self.think |
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
require 'rubygems' | |
require 'celluloid' | |
class Philosopher | |
include Celluloid | |
def initialize(name, left_fork, right_fork) | |
@name = name | |
@left_fork = left_fork | |
@right_fork = right_fork | |
self.think |
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
require 'thread' | |
class Ron | |
def initialize(name, left_fork, right_fork) | |
@name = name | |
@left_fork = left_fork | |
@right_fork = right_fork | |
while true | |
think | |
dine |
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
{-# LANGUAGE EmptyDataDecls #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# OPTIONS_GHC -fno-warn-orphans #-} |
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
require 'benchmark' | |
module Wrapper | |
def self.extended(klass) | |
klass.class_eval do | |
@@methods = {} | |
def self.methods | |
@@methods | |
end | |
def self.set_method k, v |
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
require 'benchmark' | |
require 'ostruct' | |
require 'rubygems' | |
require 'deep_struct' | |
require 'classy_struct' | |
require 'structure' | |
require 'deepopenstruct' | |
require 'recursive-open-struct' | |
require './fast_struct/lib/fast_struct' |
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
require 'rubygems' | |
require 'ruby2ruby' | |
require 'ruby_parser' | |
require 'set' | |
require 'trollop' | |
require 'contracts' | |
include Contracts | |
class Foo < SexpProcessor |