27.01.2015 Views

A Methodology for Fine- Grained Parallelism in JavaScript ...

A Methodology for Fine- Grained Parallelism in JavaScript ...

A Methodology for Fine- Grained Parallelism in JavaScript ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

extend kernel work function<br />

function createKernel(workfn)<br />

{<br />

var that = workfn;<br />

if (that._sluice_kernel !== true) {<br />

that._sluice_kernel = true;<br />

if (that.work == undef<strong>in</strong>ed)<br />

that.work = workfn;<br />

that.<strong>in</strong>s = [];<br />

that.outs = [];<br />

that.pop = createPop(that,0);<br />

that.popN = createPop(that);<br />

that.push = createPush(that,0);<br />

that.pushN = createPush(that);<br />

that.fiber = Fiber(<br />

function() {<br />

var r = false;<br />

while(r == false)<br />

r = that.work.call(that);<br />

return r;<br />

});<br />

// return a pop operation<br />

function createArrayPop(kernel,stream)<br />

{<br />

var k = kernel;<br />

if (stream != null) {<br />

var s = stream;<br />

return function() {<br />

var a = k.<strong>in</strong>s[s].data;<br />

while (!a.length) yield(k.<strong>in</strong>s[s].src == 1);<br />

var e = a.shift();<br />

return e;<br />

};<br />

} else {<br />

return function(s) {<br />

var a = k.<strong>in</strong>s[s].data;<br />

while (!a.length) yield(k.<strong>in</strong>s[s].src == 1);<br />

var e = a.shift();<br />

return e;<br />

};<br />

}<br />

}<br />

}<br />

}<br />

return that;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!