blob: 739d25c1737dc1a42c7af555b47b182487a545a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
---
title: ParallelArray
slug: Web/JavaScript/Reference/Global_Objects/ParallelArray
tags:
- JavaScript
- ParallelArray
- 过时
translation_of: Archive/Web/ParallelArray
---
<p>The goal of <strong><code>ParallelArray</code></strong> was to enable data-parallelism in web applications. The higher-order functions available on <code>ParallelArray</code> attempted to execute in parallel, though they may fall back to sequential execution if necessary. To ensure that your code executes in parallel, it is suggested that the functions should be limited to the <a href="http://smallcultfollowing.com/babysteps/blog/2013/04/30/parallelizable-javascript-subset/">parallelizable subset of JS that Firefox supports</a>.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">new ParallelArray()
new ParallelArray([element0, element1, ...])
new ParallelArray(arrayLength, elementalFunction)</pre>
<h2 id="ParallelArray_instances"><code>ParallelArray</code> instances</h2>
<h3 id="属性">属性</h3>
<dl>
<dt>length</dt>
<dd>Reflects the number of elements in the <code>ParallelArray</code>.</dd>
</dl>
<h3 id="方法">方法</h3>
<dl>
<dt>map</dt>
<dt>reduce</dt>
<dt>scan</dt>
<dt>scatter</dt>
<dt>filter</dt>
<dt>flatten</dt>
<dt>partition</dt>
<dt>get</dt>
</dl>
<h2 id="示例">示例</h2>
<h3 id="Using_map_in_parallel">Using <code>map</code> in parallel</h3>
<pre class="brush: js">var p = new ParallelArray([0, 1, 2, 3, 4]);
var m = p.map(function (v) {
return v + 1;
});</pre>
<h2 id="参见">参见</h2>
<ul>
<li><a href="http://wiki.ecmascript.org/doku.php?id=strawman:data_parallelism">Ecmascript ParallelArray strawman</a></li>
</ul>
|