/[suikacvs]/markup/html/html5/spec-ja/workers-non-normative.ja.html.u8
Suika

Contents of /markup/html/html5/spec-ja/workers-non-normative.ja.html.u8

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Thu Jul 17 06:15:55 2008 UTC (18 years ago) by wakaba
Branch: MAIN
Changes since 1.10: +266 -21 lines
*** empty log message ***

1 wakaba 1.1
2     <html lang=en-US-x-hixie>
3     <head>
4     <title>Web Workers</title>
5     <link href="http://www.whatwg.org/style/specification" rel=stylesheet>
6     <!-- Japanese-translation-only style rules -->
7     <style>
8     em {
9     text-decoration: underline;
10     }
11     ins.ja-note {
12     background-color: #EEFFFF;
13     color: black;
14     }
15     </style>
16     <link href="http://www.whatwg.org/images/icon" rel=icon>
17    
18     <body class=draft>
19     <div class=head>
20     <p><span class=ja-translation lang=ja><a class=logo href="http://www.whatwg.org/" rel=home><img lang=en alt=WHATWG
21     src="http://www.whatwg.org/images/logo"></a></span></p>
22    
23     <h1 id=web-workers>Web Workers</h1>
24    
25     <h2 class="no-num no-toc" id=draft><span class=ja-translation lang=ja>勧告案<ins class=ja-note>の非公式和訳</ins> &mdash;
26 wakaba 1.11 <ins class=ja-note>(原文出版日)</ins> 2008年7月17日</span></h2>
27 wakaba 1.1
28     <p><span class=ja-translation lang=ja>みなさんにも作業にご参加いただけます。 <a
29     href="http://www.whatwg.org/mailing-list">作業部会の議論用メイリング・リストに参加してください。</a></span></p>
30    
31     <p><span class=ja-translation lang=ja><strong>Web デザイナー!</strong> みなさんのための <a
32     href="http://blog.whatwg.org/faq/" lang=en>FAQ</a>、<a
33     href="http://forums.whatwg.org/">掲示板</a>、<a
34     href="http://www.whatwg.org/mailing-list#help">ヘルプ用メイリング・リスト</a>があります!
35    
36     </span><p>
37    
38     <!-- Japanese-translation-only notes -->
39 wakaba 1.3 <ins class=ja-note style="display: block" lang=ja>
40 wakaba 1.1 <p>この文書は、 WHATWG HTML5 仕様書の日本語訳です。
41     HTML5 の正式な仕様書は英語版だけであり、
42     この日本語訳はあくまで参考としてご利用ください。
43    
44 wakaba 1.3 <p lang=en>This document is a Japanese translation of
45 wakaba 1.1 the WHATWG HTML5 specification. Note that the only normative specification
46     for the HTML5 is the original English version and this Japanese
47     translation is non‐normative.
48 wakaba 1.3
49     <p>日本語訳は <a href="edit/" rel=edit>Web 界面</a>を使って編集できます。
50     編集結果はおよそ3時間おきに反映されます。
51     また、原文の変更には毎日自動的に追随しています。
52    
53 wakaba 1.8 <p lang=en>The Japanese text can be edited using the <a href="edit/" rel=edit>Web
54 wakaba 1.3 interface</a>. Any modifications will be reflected to this translation
55     in about three hours. Note that any changes to the original specification
56     will automatically be incorporated to this translation every day.
57 wakaba 1.1 </ins>
58    
59     <p><span><!-- dummy --></span></p>
60    
61     <dl>
62     <dt><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>この版</span><dd><a
63     href="http://www.whatwg.org/specs/web-workers/current-work/">http://www.whatwg.org/specs/web-workers/current-work/</a>
64    
65     <dt><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>改版履歴:</span><dd><span class=ja-translation lang=ja><span lang=en>Twitter</span> メッセージ (編集上の変更以外): <a
66     href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a></span><dd>Commit-Watchers mailing list: <a
67     href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a>
68    
69     <dd><span class=ja-translation lang=ja>対話的 <span lang=en>Web</span> 界面: <a href="http://html5.org/tools/web-workers-tracker">http://html5.org/tools/web-workers-tracker</a></span><dd><span class=ja-translation lang=ja><span lang=en>Subversion</span> 界面: <a href="http://svn.whatwg.org/webworkers/">http://svn.whatwg.org/webworkers/</a></span><dt><span class=ja-translation lang=ja>問題:</span><dd><span class=ja-translation lang=ja>フィードバックの送信先: <a
70     href="http://www.whatwg.org/mailing-list">[email protected]</a></span><dd><span class=ja-translation lang=ja>フィードバックの閲覧・投票: <a
71     href="http://www.whatwg.org/issues/">http://www.whatwg.org/issues/</a></span><dt><span class=ja-translation lang=ja>編集者:</span><dd>Ian Hickson, Google, [email protected]
72     </dl>
73    
74     <p class=copyright>&copy; Copyright 2004-2008 Apple Computer, Inc.,
75     Mozilla Foundation, and Opera Software ASA.</p>
76    
77     <p class=copyright>You are granted a license to use, reproduce and create
78     derivative works of this document.</p>
79     </div>
80    
81     <hr>
82    
83     <h2 class="no-num no-toc" id=abstract><span class=ja-translation lang=ja>概要</span></h2>
84    
85     <p><span class=ja-translation lang=ja>この仕様書は、 Web アプリケーションで主たる頁と並列に背景労働者スクリプトを動作させることを可能とする
86     API を定義します。
87     これによって、メッセージ・パッシングによるスレッド的操作を協調機構として利用できるようになります。</span><h2 class="no-num no-toc" id=status><span class=ja-translation lang=ja>この文書の状態</span></h2>
88    
89     <p><span class=ja-translation lang=ja><strong>この文書は作業中です!</strong>
90     この文書は、コメントへの対応や通常の開発の過程として、
91     毎時毎分とは言い過ぎですが毎日のペースで変更されています。
92     コメントは非常に歓迎していますので、
93     <a href="mailto:[email protected]">[email protected]</a>
94     へお送りください。よろしくお願いします。</span><p><span class=ja-translation lang=ja>現在の焦点は、第1案の開発です。</span><p><span class=ja-translation lang=ja>実装者は、この仕様書が安定していないことに注意するべきです。
95     <strong>実装者は議論に参加しておかないと、
96     仕様がその実装とは非互換に変更されてしまうかもしれません。</strong>
97     この仕様書がいずれ実装呼び掛けの段階に達するのよりも前にこの仕様を実装したい販売者は、
98 wakaba 1.7 <a href="http://www.whatwg.org/mailing-list">WHATWG メイリング・リスト</a>に参加し、
99 wakaba 1.1 議論に加わるべきです。</span><p><span class=ja-translation lang=ja>この仕様書は <a
100     href="http://www.w3.org/html/wg">W3C HTML WG</a>
101     によっても出版されています。2つの仕様書の目次以降は同一です。</span><h2 class="no-num no-toc" id=contents><span class=ja-translation lang=ja>目次
102     </span></h2>
103     <!--begin-toc-->
104    
105     <ul class=toc>
106     <li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
107     <ul class=toc>
108 wakaba 1.9 <li><a href="#tutorial"><span class=secno>1.1 </span>Tutorial</a>
109 wakaba 1.1
110 wakaba 1.4 <li><a href="#requirements"><span class=secno>1.2
111     </span>Requirements</a>
112 wakaba 1.1
113 wakaba 1.9 <li><a href="#conformance"><span class=secno>1.3 </span>Conformance
114 wakaba 1.1 requirements</a>
115     <ul class=toc>
116 wakaba 1.9 <li><a href="#dependencies"><span class=secno>1.3.1
117 wakaba 1.1 </span>Dependencies</a>
118     </ul>
119    
120 wakaba 1.9 <li><a href="#terminology"><span class=secno>1.4 </span>Terminology</a>
121     </ul>
122    
123     <li><a href="#inside"><span class=secno>2. </span>Inside workers</a>
124     <ul class=toc>
125     <li><a href="#the-windowworker"><span class=secno>2.1 </span>The
126     <code>WindowWorker</code> interface</a>
127    
128     <li><a href="#the-queue"><span class=secno>2.2 </span>The queue of
129     events</a>
130    
131 wakaba 1.11 <li><a href="#the-workers"><span class=secno>2.3 </span>The worker's
132     ports</a>
133    
134     <li><a href="#processing"><span class=secno>2.4 </span>Processing
135 wakaba 1.9 model</a>
136     </ul>
137    
138     <li><a href="#creating"><span class=secno>3. </span>Creating workers</a>
139     <ul class=toc>
140     <li><a href="#the-windowworkercreators"><span class=secno>3.1 </span>The
141     <code>WindowWorkerCreators</code> interface</a>
142 wakaba 1.1 </ul>
143    
144     <li class=no-num><a href="#references">References</a>
145    
146     <li class=no-num><a href="#acknowledgements">Acknowledgements</a>
147     </ul>
148     <!--end-toc-->
149    
150     <hr>
151    
152 wakaba 1.3 <h2 id=introduction><span class=ja-translation lang=ja><span class=secno>1. </span>はじめに</span></h2>
153 wakaba 1.1
154 wakaba 1.9 <h3 id=tutorial><span class=secno>1.1 </span>Tutorial</h3>
155 wakaba 1.1
156 wakaba 1.9 <p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class=big-issue>This section is missing.
157    
158     <h3 id=requirements><span class=ja-translation lang=ja><span class=secno>1.2 </span>要件</span></h3>
159 wakaba 1.1
160 wakaba 1.6 <p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p><span class=ja-translation lang=ja>この仕様書は、次に示す利用事例と要件に取り組むことを目指します。</span><ul>
161     <li><span class=ja-translation lang=ja>背景労働者: Web アプリケーションは、そのデータを鯖と同期しておく必要があります。
162     これは、鯖への更新の送信と鯖からの更新の両方を含み、
163     アプリケーションがオフラインとなった時の更新のバッファリングの取扱いも含みます。
164     そのための符号は利用者界面の符号とは独立しているのが理想でしょう。</span><li><span class=ja-translation lang=ja>URL: 労働者は、文字列からではなく、 URL から生み出される<em class=rfc2119 title="SHOULD">べきです</em>。
165     スクリプトはその出典へのアクセスを滅多に有しないからです。</span><li><span class=ja-translation lang=ja>メッセージ・キューイング: 労働者が初期化される前に送信されたメッセージが失われるべきでは<em class=rfc2119 title="SHOULD NOT">ありません</em>。</span><li><span class=ja-translation lang=ja>労働者はタイマーへのアクセスを有する<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>労働者はネットワークへのアクセスを有する<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>労働者はライブラリを使える<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>実装は労働者に <code>Node</code> オブジェクトや
166     <code>Document</code> オブジェクトを晒さなければならない<em class=rfc2119 title="SHOULD NOT">べきではありません</em>。</span><li><span class=ja-translation lang=ja>労働者は外界と何も共有する<em class=rfc2119 title="SHOULD NOT">べきではありません</em>。
167     例えば、労働者自体の中で労働者を現すオブジェクトと労働者を作成した文脈で労働者を表すオブジェクトは異なる<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>共有労働者: 同じ Web アプリケーションの複数の実現値は鯖に対する接続を1つだけ維持したいでしょう。</span><li><span class=ja-translation lang=ja>能力保証: ある iframe で動作している符号が他の iframe と何らかの権限 (例えば、
168     住所録へは追加するが読まない) を保証する接続を折衝することが可能である<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>委譲: ある労働者が別の労働者を生み出し、呼び出し元が委譲に気づかず、
169     かつ元の労働者がすべてのメッセージを仲介せずに、
170     当該労働者に対する要求を効率的に委譲できる<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>親が有用ではなくなった労働者は殺される<em class=rfc2119 title="SHOULD">べきです</em>。
171     労働者はこれが起こることを検知して華麗に終了することができる<em class=rfc2119 title="SHOULD">べきです</em>。</span></ul>
172 wakaba 1.4
173 wakaba 1.9 <h3 id=conformance><span class=ja-translation lang=ja><span class=secno>1.3 </span>適合性要件</span></h3>
174 wakaba 1.1
175     <p><span class=ja-translation lang=ja>この仕様書のすべての図、例、注意書きは、
176     規定の一部ではないと明記された節すべてと同様に、
177     規定の一部ではありません。
178     この仕様書のそれ以外のすべては規定の一部です。</span><p><span class=ja-translation lang=ja>この文書の規定の部分にあるキーワード「<em class=rfc2119 title="MUST">しなければなりません</em>」、
179     「<em class=rfc2119 title="MUST NOT">してはなりません</em>」、
180     「<em class=rfc2119 title="REQUIRED">必須です</em>」、「<em class=rfc2119 title="SHOULD">するべきです</em>」、
181     「<em class=rfc2119 title="SHOULD NOT">するべきではありません</em>」、
182     「<em class=rfc2119 title="RECOMMENDED">推奨します</em>」、「<em class=rfc2119 title="MAY">して構いません</em>」、
183     「<em class=rfc2119 title="OPTIONAL">任意です</em>」は、 RFC 2119 で説明されているように解釈します。
184     可読性の観点から、この仕様書<ins class=ja-note>の原文</ins>では、
185     これらの語<ins class=ja-note>の原語</ins>はすべて大文字では表記しません。
186     <a href="#refsRFC2119">[RFC2119]</a></span></p>
187     <!-- XXX but they should be
188     marked up -->
189    
190     <p><span class=ja-translation lang=ja>算法の一部として<ins class=ja-note>動作の指示の形で (原文では</ins>命令形で<ins class=ja-note>) </ins>記述された要件
191     (例えば「先頭の間隔文字をすべて除去します」や「偽を返し、これらの段階を停止します」)
192     は、算法の紹介で使われたキーワード (<em class=rfc2119 title="MUST">しなければなりません</em>、
193     <em class=rfc2119 title="SHOULD">するべきです</em>、<em class=rfc2119 title="MAY">して構いません</em>など) の意味により解釈します。</span><p><span class=ja-translation lang=ja>いくつかの適合性要件は属性やメソッドやオブジェクトの要件として説明されています。
194     そのような要件は、利用者エージェントに関する要件として解釈します。</span><p><span class=ja-translation lang=ja>算法や特定の段階として説明されている適合性要件は、
195     最終的な結果が等価である限り、任意の方法で実装して<em class=rfc2119 title="MAY">構いません</em>。
196     (特に、この仕様書で定義されている算法は追うのを簡単にしており、
197     高性能であることを目指してはいません。)</span><p><span class=ja-translation lang=ja>この仕様書で定義される適合性の級は、利用者エージェントのみです。</span><p><span class=ja-translation lang=ja>利用者エージェントは、サービス拒否攻撃を防ぐため、
198     記憶容量を使い尽くすことを防ぐため、
199     あるいは環境特有の制限に対応するためなどの目的で、
200 wakaba 1.9 別段の制約のない入力に対して実装特有の制限を設けて<em class=rfc2119 title="MAY">構いません</em>。</span><h4 id=dependencies><span class=ja-translation lang=ja><span class=secno>1.3.1 </span>依存性</span></h4>
201 wakaba 1.1
202     <p><span class=ja-translation lang=ja>この仕様書は他のいくつかの下位仕様書に依存しています。</span><dl>
203     <dt>HTML5
204    
205     <dd>
206     <p><span class=ja-translation lang=ja>HTML5 の多くの基礎的な概念をこの仕様書で使用します。
207     <a href="#refsHTML5">[HTML5]</a></span></p>
208    
209     <dt>ECMAScript
210    
211     <dd>
212     <p><span class=ja-translation lang=ja>この仕様書はスクリプト言語として JavaScript
213     を使うことを想定しています。 <a href="#refsJS">[JS]</a></span></p>
214    
215     <dt>WebIDL
216    
217     <dd>
218 wakaba 1.5 <p><span class=ja-translation lang=ja>この仕様書の IDL ブロックは WebIDL 仕様書における意味を用います。 <a href="#refsWebIDL">[WebIDL]</a></span></p>
219 wakaba 1.1 </dl>
220    
221 wakaba 1.9 <h3 id=terminology><span class=ja-translation lang=ja><span class=secno>1.4 </span>用語</span></h3>
222 wakaba 1.1
223     <p><span class=ja-translation lang=ja>簡単のため、<em>示す</em>、<em>表示する</em>、
224     <em>可視</em>などの用語を文書が利用者に対してレンダリングされる方法に言及する時に使うことがあります。
225     これらの語は視覚媒体を暗示することを意図していません。
226 wakaba 1.10 これらの語は他の媒体にも等価な方法で適用されると考えなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p><span class=ja-translation lang=ja>「<code title="">Foo</code> オブジェクト」という構文 (<code title="">Foo</code>
227     は実際には界面) を時々使いますが、より正確な「界面 <code title="">Foo</code>
228     を実装しているオブジェクト」の代わりに用いています。</span><p><span class=ja-translation lang=ja>DOM という語は、 Web アプリケーションでスクリプトに利用可能とされている API
229 wakaba 1.1 の集合を指して用い、必ずしも DOM 中核仕様書で定義されている実際の
230     <code>Document</code> オブジェクトその他の <code>Node</code>
231     オブジェクトの存在を暗示してはいません。<a
232     href="#refsDOM3CORE">[DOM3CORE]</a></span><p><span class=ja-translation lang=ja>DOM 属性は、その値が (例えば著者のスクリプトにより) 取り出される時<em>取得される</em>といい、
233     新しい値がその属性に割り当てられる時<em>設定される</em>といいます。</span><p><span class=ja-translation lang=ja>DOM オブジェクトが<dfn id=live>生きている</dfn>という場合、
234     そのオブジェクトを返す属性は常に同じオブジェクトを返さなければ<em class=rfc2119 title="MUST">ならない</em>
235     (毎回新しいオブジェクトを返すのではなく) 上に、
236     そのオブジェクトの属性やメソッドがそのオブジェクトの裏にある実際のデータのスナップ写真ではなく、
237 wakaba 1.10 データそのものに対して操作されなければ<em class=rfc2119 title="MUST">ならない</em>ことを意味します。
238     </span><h2 id=inside><span class=secno>2. </span>Inside workers</h2>
239 wakaba 1.9
240 wakaba 1.10 <h3 id=the-windowworker><span class=ja-translation lang=ja><span class=secno>2.1 </span><code><a href="#windowworker">WindowWorker</a></code> 界面</span></h3>
241 wakaba 1.9
242     <pre
243     class=idl>[NoInterfaceObject] interface <dfn id=windowworker>WindowWorker</dfn> {
244     readonly attribute boolean <a href="#name" title=dom-windowworker-name>name</a>;
245     readonly attribute boolean <a href="#closing" title=dom-windowworker-closing>closing</a>;
246 wakaba 1.11 void <a href="#close" title=dom-windowworker-close>close</a>();
247    
248     // event handler attributes
249     attribute <span>EventListener</span> <a href="#onjoin" title=handler-windowworker-onjoin>onjoin</a>;
250     attribute <span>EventListener</span> <a href="#onunload" title=handler-windowworker-onunload>onunload</a>;
251 wakaba 1.9 };</pre>
252    
253 wakaba 1.10 <p><span class=ja-translation lang=ja><code><a
254     href="#windowworker">WindowWorker</a></code> 界面を実装するオブジェクトは、
255     <code>Window</code> 界面 (引いては、 <code>WindowTimers</code> 界面と <code><a
256     href="#windowworkercreators">WindowWorkerCreators</a></code> 界面も)
257     と <code>EventTarget</code> 界面を実装しなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p><span class=ja-translation lang=ja><dfn id=name title=dom-windowworker-name><code>name</code></dfn>
258     属性は、<code><a
259     href="#windowworker">WindowWorker</a></code> オブジェクトが「<a
260     href="#run-a">労働者を起動</a>」する算法で作成された時に割り当てられた値を返さなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p>The <dfn id=closing
261 wakaba 1.9 title=dom-windowworker-closing><code>closing</code></dfn> attribute must
262     return false until the "<a href="#kill-a">kill a worker</a>" processing
263     model defined below sets it to false.
264    
265 wakaba 1.11 <p>The following are the <span>event handler DOM attributes</span> that
266     must be supported by objects implementing the <code><a
267     href="#windowworker">WindowWorker</a></code> interface:
268    
269     <dl>
270     <dt><dfn id=onjoin
271     title=handler-windowworker-onjoin><code>onjoin</code></dfn>
272    
273     <dd>
274     <p>Must be invoked whenever a <code
275     title=event-windowworker-join>join</code> event is targeted at or
276     bubbles through the <code><a
277     href="#windowworker">WindowWorker</a></code> object.
278    
279     <dt><dfn id=onunload
280     title=handler-windowworker-onunload><code>onunload</code></dfn>
281    
282     <dd>
283     <p>Must be invoked whenever a <code title=event-unload>unload</code>
284     event is targeted at or bubbles through the <code><a
285     href="#windowworker">WindowWorker</a></code> object.
286     </dl>
287    
288 wakaba 1.10 <h3 id=the-queue><span class=ja-translation lang=ja><span class=secno>2.2 </span>事象の待ち行列</span></h3>
289 wakaba 1.9
290 wakaba 1.10 <p><span class=ja-translation lang=ja>各 <code><a href="#windowworker">WindowWorker</a></code> オブジェクトは、
291 wakaba 1.11 <dfn id=queue>事象の待ち行列</dfn> (はじめは空) と関連付けられています。</span><p><span class=ja-translation lang=ja>待ち行列中の事象は、 DOM 事象か小休止呼び戻しとなることができます。</span><p>All asynchronous callbacks and events that would be called or dispatched
292     in the worker must be added to the worker's queue, with the "<a
293     href="#run-a">run a worker</a>" processing model below taking care of
294     actually calling the callbacks or dispatching the events.
295    
296     <p>Once the <code><a href="#windowworker">WindowWorker</a></code>'s <code
297     title=dom-windowworker-closing><a href="#closing">closing</a></code>
298     attribute is set to true, the queue must discard anything else that would
299     be added to it. Effectively, once the <code
300     title=dom-windowworker-closing><a href="#closing">closing</a></code>
301     attribute is true, timers stop firing, notifications for all pending
302     asynchronous operations are dropped, etc.
303    
304     <h3 id=the-workers><span class=secno>2.3 </span>The worker's ports</h3>
305    
306     <p>Workers communicate with other workers and with <span title="browsing
307     context">browsing contexts</span> through <span title="channel
308     messaging">message channels</span> and their <code>MessagePort</code>
309     objects.
310    
311     <p>Each <code><a href="#windowworker">WindowWorker</a></code> <var
312     title="">worker</var> has a list of <dfn id=the-workers0>the worker's
313     ports</dfn>, which consists of all the <code>MessagePort</code> objects
314     that are entangled with another port and that have one (but only one) port
315     whose <code title=dom-MessagePort-ownerWindow>ownerWindow</code> is <var
316     title="">worker</var>. This list includes all the <code>MessagePort</code>
317     objects that are in events pending in the <a href="#queue">queue of
318     events</a>.
319    
320     <h3 id=processing><span class=ja-translation lang=ja><span class=secno>2.4 </span>処理モデル
321 wakaba 1.10 </span></h3>
322 wakaba 1.9
323     <p>When a user agent is to <dfn id=run-a>run a worker</dfn> named <var
324 wakaba 1.11 title="">name</var> for a script with <span>URL</span> <var
325     title="">url</var>, a browsing context <var title="">owner browsing
326     context</var> and a <code>Document</code> <var title="">owner
327     document</var>, it must run the following steps in a completely separate
328     and parallel execution environment:
329 wakaba 1.9
330     <ol>
331     <li>
332 wakaba 1.11 <p>Attempt to <span>fetch</span><!-- XXX --> the resource identified by
333     <var title="">url</var>.</p>
334    
335     <p>If the attempt fails, then abort these steps and invoke the <a
336     href="#worker0" title="worker creation failed">error handling steps</a>
337     defined by the algorithm that called this one.</p>
338    
339     <p>If the attempt succeeds, then let <var title="">script</var> be the
340     resource that was obtained.</p>
341    
342     <p class=note>As with <code>script</code> elements, the MIME type of the
343     script is ignored. Unlike with <code>script</code> elements, there is no
344     way to override the type. It's always assumed to be JavaScript.</p>
345     <!-- XXX people will complain about
346     this. I guess we might want to examine the MIME type... -->
347    
348    
349     <li>
350 wakaba 1.9 <p>Create a new <code><a href="#windowworker">WindowWorker</a></code>
351     object, <var title="">window</var>.</p>
352    
353     <li>
354     <p>Set the <code title=dom-windowworker-name><a
355     href="#name">name</a></code> attribute of <var title="">window</var> to
356     the value of <var title="">name</var>.</p>
357    
358     <li>
359     <p>Let <var title="">script</var>'s <span>script execution context</span>
360     (and thus also <span>global object</span>) be <var
361     title="">window</var>.</p>
362    
363     <li>
364     <p>Let <var title="">script</var>'s <span>script browsing context</span>
365     be <var title="">owner browsing context</var>.</p>
366    
367     <li>
368     <p>Let <var title="">script</var>'s <span>script document context</span>
369     be <var title="">owner document</var>.</p>
370    
371     <li>
372 wakaba 1.11 <p>Invoke the <a href="#worker" title="worker creation succeeded">success
373     steps</a> defined by the algorithm that called this one. (This will add
374     an event to the <a href="#queue">queue of events</a>.)</p>
375    
376     <li>
377     <p>Start monitoring <var title="">worker</var>, such that whenever the
378     <var title="">window</var> object's <code
379     title=dom-windowworker-closing><a href="#closing">closing</a></code>
380     attribute is false and all <a href="#the-workers0">the worker's
381     ports</a> have their <code title=dom-MessagePort-active>active</code>
382     attributes set to false, the user agent suspends execution of script in
383     that worker until such time as either the <code
384     title=dom-windowworker-closing><a href="#closing">closing</a></code>
385     attribute switches to true or one of the <code>MessagePort</code>
386     objects in the list of <a href="#the-workers0">the worker's ports</a>
387     has an <code title=dom-MessagePort-active>active</code> attribute with
388     the value true.</p>
389    
390     <li>
391     <p>Start monitoring <var title="">worker</var>, such that as soon as the
392     list of <a href="#the-workers0">the worker's ports</a> becomes empty,
393     the <var title="">window</var> object's <code
394     title=dom-windowworker-closing><a href="#closing">closing</a></code>
395     attribute is set to true.</p>
396    
397     <p class=note>This can never happen at this point in the algorithm: as
398     soon as the worker ran the <a href="#worker" title="worker creation
399     succeeded">success steps</a>, the <a href="#queue">queue of events</a>
400     received a <code title=event-join>join</code> event with a
401     <code>MessagePort</code>.</p>
402    
403     <li>
404     <p>Run <var title="">script</var> until it either returns, fails to catch
405     an exception, or gets prematurely aborted by the "<a href="#kill-a">kill
406     a worker</a>" algorithm below.</p>
407    
408     <p class=note>If the script gets aborted by the "<a href="#kill-a">kill a
409     worker</a>" algorithm, then that same algorithm will cause there to only
410     be a single event in the <a href="#queue">queue of events</a> at the
411     next step, namely the <code title=message-unload>unload</code> event.
412     However, if the event is ignored then it will become true as soon as
413     that port is garbage collected.</p>
414 wakaba 1.9
415     <li>
416 wakaba 1.11 <p><i>Event loop</i>: Wait until either there is an event in the <a
417 wakaba 1.9 href="#queue">queue of events</a> associated with <var
418 wakaba 1.11 title="">window</var> or the <var title="">window</var> object's <code
419     title=dom-windowworker-closing><a href="#closing">closing</a></code>
420     attribute is set to true.</p>
421 wakaba 1.9
422     <li>
423     <p>Dispatch the oldest event or callback in the <a href="#queue">queue of
424 wakaba 1.11 events</a>, if any. The handling of this event or the execution of this
425     callback might get prematurely aborted by the "<a href="#kill-a">kill a
426     worker</a>" algorithm below.</p>
427 wakaba 1.9
428     <li>
429     <p>If there are any more events in the <a href="#queue">queue of
430     events</a> or if the <var title="">window</var> object's <code
431     title=dom-windowworker-closing><a href="#closing">closing</a></code>
432     attribute is set to false, then jump back to the step above labeled
433     <i>event loop</i>.</p>
434    
435     <li>
436     <p class=big-issue>timers, intervals, XMLHttpRequests, database
437     transactions, etc, must be killed; ports must be deactivated and
438 wakaba 1.11 unentangled (do not send unload)</p>
439 wakaba 1.9 </ol>
440    
441     <hr>
442    
443     <p>When a user agent is to <dfn id=kill-a>kill a worker</dfn>, it must run
444     the following steps in parallel with the worker's main loop (the "<a
445     href="#run-a">run a worker</a>" processing model defined above):
446    
447     <ol>
448     <li>
449     <p>Create an <code>Event</code> object with the event name <code
450     title=event-unload>unload</code>, which does not bubble and is not
451     cancelable, and add it to the worker's <code><a
452     href="#windowworker">WindowWorker</a></code> object's <a
453 wakaba 1.11 href="#queue">queue of events</a>, targetted at the <code><a
454     href="#windowworker">WindowWorker</a></code> object itself.
455    
456     <li>
457     <p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code>
458     object's <code title=dom-windowworker-closing><a
459     href="#closing">closing</a></code> attribute to true.
460 wakaba 1.9
461     <li>
462 wakaba 1.11 <p>Wait a user-agent-defined amount of time. If the "<a href="#run-a">run
463     a worker</a>" processing model defined above immediately starts running
464     event listeners registered for <code title=event-unload>unload</code>
465     event, this time should not be zero &mdash; the idea is that the <code
466     title=event-unload>unload</code> event can be used to clean up when
467     shutting down unexpectedly.
468 wakaba 1.9
469     <li>
470     <p>If there are any events in the <a href="#queue">queue of events</a>
471     other than the <code title=event-unload>unload</code> event that this
472     algorithm just added, discard them without dispatching them.
473    
474     <li>
475     <p>If the <code title=event-unload>unload</code> event that this
476     algorithm just added hasn't yet been dispatched, then abort the script
477     currently running in the worker.
478    
479     <li>
480     <p>Wait a user-agent-defined amount of time.
481    
482     <li>
483     <p>Abort the script currently running in the worker (if any script is
484     running, then it will be a handler for the <code
485     title=event-unload>unload</code> event).
486     </ol>
487    
488 wakaba 1.11 <hr>
489    
490     <p>When a script invokes the <dfn id=close
491     title=dom-windowworker-close><code>close()</code></dfn> method on a
492     <code><a href="#windowworker">WindowWorker</a></code> object, the user
493     agent must run the following steps:
494    
495     <ol>
496     <li>
497     <p>Create an <code>Event</code> object with the event name <code
498     title=event-unload>unload</code>, which does not bubble and is not
499     cancelable, and add it to the <code><a
500     href="#windowworker">WindowWorker</a></code> object's <a
501     href="#queue">queue of events</a>, targetted at the <code><a
502     href="#windowworker">WindowWorker</a></code> object itself.
503    
504     <li>
505     <p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code>
506     object's <code title=dom-windowworker-closing><a
507     href="#closing">closing</a></code> attribute to true.
508    
509     <li>
510     <p>For each <code>MessagePort</code> object that is entangled with
511     another port and that has one (but only one) port whose <code
512     title=dom-MessagePort-ownerWindow>ownerWindow</code> is the <code><a
513     href="#windowworker">WindowWorker</a></code> object on which the method
514     was invoked, run the following substeps:</p>
515    
516     <ol>
517     <li>
518     <p>Unentangle the two ports.
519    
520     <li>
521     <p>Set both ports' <code title=dom-MessagePort-active>active</code>
522     attribute to false.
523    
524     <li>
525     <p>At the next available opportunity, after any scripts have finished
526     executing<!-- XXX queue -->, <span>fire a simple event</span> called
527     <code title=event-unload>unload</code> at the other port (the one
528     whose <code title=dom-MessagePort-ownerWindow>ownerWindow</code> is
529     not the <code><a href="#windowworker">WindowWorker</a></code> object
530     on which the <code title=dom-windowworker-close><a
531     href="#close">close()</a></code> method was called).
532     </ol>
533     </ol>
534    
535 wakaba 1.9 <h2 id=creating><span class=secno>3. </span>Creating workers</h2>
536    
537 wakaba 1.10 <h3 id=the-windowworkercreators><span class=ja-translation lang=ja><span class=secno>3.1 </span><code><a href="#windowworkercreators">WindowWorkerCreators</a></code> 界面</span></h3>
538 wakaba 1.9
539     <pre
540     class=idl>[NoInterfaceObject] interface <dfn id=windowworkercreators>WindowWorkerCreators</dfn> {
541     <span>MessagePort</span> <span title=dom-WindowWorkerCreators-createWorker>createWorker</span>(in DOMString scriptURI);
542     <span>MessagePort</span> <span title=dom-WindowWorkerCreators-createNamedWorker>createNamedWorker</span>(in DOMString name, in DOMString scriptURI);
543     };</pre>
544    
545     <p>Objects that implement the <code>Window</code> interface must also
546     implement the <code><a
547     href="#windowworkercreators">WindowWorkerCreators</a></code> interface.
548 wakaba 1.11
549     <hr>
550    
551     <p>When the <code
552     title=dom-WindowWorkerCreators-createWorker>createWorker()</code> method
553     is invoked, the user agent must run the following steps:
554    
555     <ol>
556     <li class=big-issue>... <!--
557     resolve url
558     if that fails, throw
559     if it's not same-orgin, throw
560     run create worker steps
561     -->
562    
563     </ol>
564    
565     <hr>
566    
567     <p>When the <code
568     title=dom-WindowWorkerCreators-createNamedWorker>createNamedWorker()</code>
569     method is invoked, the user agent must run the following steps:
570    
571     <ol>
572     <li class=big-issue>... <!--
573     if /name/ = "", jump to createWorker() steps
574     resolve url
575     if that fails, throw
576     if it's not same-orgin, throw
577     look for named worker whose name is /name/ and that has closing=false and whose document's origin is the same as the calling scripts'
578     if you don't find one, run 'create worker' steps with given name and resulting absolute url; return returned port
579     check that resulting absolute url matches the one in the worker; if not, throw
580     create two ports
581     return port 1
582     invoke the "join a worker" steps with the two ports
583     -->
584    
585     </ol>
586    
587     <hr>
588    
589     <p>The steps to <dfn id=create>create a worker</dfn> are as follows:
590    
591     <ol>
592     <li class=big-issue>... <!--
593     create two ports
594     in a separate thread, 'run a worker' with name "" and resulting absolute url
595     return port 1
596     success steps: invoke the "join a worker" steps with the two ports
597     failure steps: fire 'error' on port1
598     -->
599    
600     </ol>
601    
602     <p class=big-issue><dfn id=worker>worker creation succeeded</dfn>, <dfn
603     id=worker0>worker creation failed</dfn>
604    
605     <hr>
606    
607     <p>The steps to <dfn id=join-a>join a worker</dfn> are as follows:
608    
609     <ol>
610     <li class=big-issue>... <!--
611     given two ports port1, port2, and a worker
612     entangle the ports
613     fire 'join' event on the worker, passing port2
614     fire 'load' event on port1.
615     -->
616    
617     </ol>
618 wakaba 1.9
619     <p class=big-issue>...
620    
621     <h2 class=no-num id=references><span class=ja-translation lang=ja>参考文献</span></h2>
622 wakaba 1.1
623     <p class=big-issue><span class=ja-translation lang=ja>この章は将来の仕様案で執筆します。</span><h2 class=no-num id=acknowledgements><span class=ja-translation lang=ja>謝辞</span></h2>
624     <!-- ACKS -->
625    
626 wakaba 1.9 <p><span class=ja-translation lang=ja>Maciej Stachowiak, Mike Smith の有用かつ重要なコメントに感謝します。</span><p>Huge thanks to the whole Gears team, who pioneered this technology and
627     whose experience has been a huge influence on this specification.

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24