A Pen by francesco agati on CodePen.
Created
September 2, 2014 23:53
-
-
Save francescoagati/9d241c9eae7e1b57c678 to your computer and use it in GitHub Desktop.
A Pen by francesco agati.
This file contains hidden or 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
lib = do | |
sum: ([a,b], callback) -> callback a + b | |
square: (a) -> a * a | |
stream = (worker) -> (message,...params) -> Bacon.from-promise worker[message](params) | |
stream-pool = (workers) -> | |
cnt = 0 | |
max = workers.length - 1 | |
(message,...params) -> | |
cnt := 0 if cnt > max | |
worker = workers[cnt] | |
console.log cnt | |
cnt := cnt + 1 | |
Bacon.from-promise worker[message](params) | |
w = stream-pool [cw(lib) for x in [0 to 4]] | |
h= Bacon.combine-template do | |
a: w(\sum,1,2) | |
b: w(\sum,1,2) | |
c7: w(\sum,1,2) | |
c2: w(\sum,1,2) | |
c3: w(\sum,1,2) | |
c4: w(\sum,1,2) | |
c5: w(\sum,1,2) | |
c0: w(\sum,1,2) | |
c1: w(\sum,1,2) | |
c8: w(\sum,1,2) | |
h.log! | |
#worker.sum [2, 5] .then ((a) -> console.log a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment