Skip to content

Instantly share code, notes, and snippets.

@koki-h
koki-h / semaphore.js
Created May 18, 2020 04:06 — forked from gregkorossy/semaphore.js
A simple implementation of a semaphore in JS
function Semaphore(max) {
var counter = 0;
var waiting = [];
var take = function() {
if (waiting.length > 0 && counter < max){
counter++;
let promise = waiting.shift();
promise.resolve();
}
@koki-h
koki-h / semaphore.js
Last active May 18, 2020 04:06 — forked from gregkorossy/semaphore.js
A simple implementation of a semaphore in JS
function Semaphore(max) {
// 排他制御のためのセマフォ
// https://gist.github.com/Gericop/e33be1f201cf242197d9c4d0a1fa7335
var counter = 0;
var waiting = [];
var take = function() {
if (waiting.length > 0 && counter < max){
counter++;
@koki-h
koki-h / app.rb
Created November 30, 2009 15:09 — forked from aerith/app.rb
#!/usr/bin/ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'pathname'
get '*' do
base = Pathname.new(File.dirname(__FILE__)).parent
path = @params[:splat].first.gsub(/^\//, '')