| 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> — |
| 26 |
wakaba |
1.9 |
<ins class=ja-note>(原文出版日)</ins> 2008年7月16日</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>© 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 |
|
|
<li><a href="#processing"><span class=secno>2.3 </span>Processing |
| 132 |
|
|
model</a> |
| 133 |
|
|
</ul> |
| 134 |
|
|
|
| 135 |
|
|
<li><a href="#creating"><span class=secno>3. </span>Creating workers</a> |
| 136 |
|
|
<ul class=toc> |
| 137 |
|
|
<li><a href="#the-windowworkercreators"><span class=secno>3.1 </span>The |
| 138 |
|
|
<code>WindowWorkerCreators</code> interface</a> |
| 139 |
wakaba |
1.1 |
</ul> |
| 140 |
|
|
|
| 141 |
|
|
<li class=no-num><a href="#references">References</a> |
| 142 |
|
|
|
| 143 |
|
|
<li class=no-num><a href="#acknowledgements">Acknowledgements</a> |
| 144 |
|
|
</ul> |
| 145 |
|
|
<!--end-toc--> |
| 146 |
|
|
|
| 147 |
|
|
<hr> |
| 148 |
|
|
|
| 149 |
wakaba |
1.3 |
<h2 id=introduction><span class=ja-translation lang=ja><span class=secno>1. </span>はじめに</span></h2> |
| 150 |
wakaba |
1.1 |
|
| 151 |
wakaba |
1.9 |
<h3 id=tutorial><span class=secno>1.1 </span>Tutorial</h3> |
| 152 |
wakaba |
1.1 |
|
| 153 |
wakaba |
1.9 |
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class=big-issue>This section is missing. |
| 154 |
|
|
|
| 155 |
|
|
<h3 id=requirements><span class=ja-translation lang=ja><span class=secno>1.2 </span>要件</span></h3> |
| 156 |
wakaba |
1.1 |
|
| 157 |
wakaba |
1.6 |
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p><span class=ja-translation lang=ja>この仕様書は、次に示す利用事例と要件に取り組むことを目指します。</span><ul> |
| 158 |
|
|
<li><span class=ja-translation lang=ja>背景労働者: Web アプリケーションは、そのデータを鯖と同期しておく必要があります。 |
| 159 |
|
|
これは、鯖への更新の送信と鯖からの更新の両方を含み、 |
| 160 |
|
|
アプリケーションがオフラインとなった時の更新のバッファリングの取扱いも含みます。 |
| 161 |
|
|
そのための符号は利用者界面の符号とは独立しているのが理想でしょう。</span><li><span class=ja-translation lang=ja>URL: 労働者は、文字列からではなく、 URL から生み出される<em class=rfc2119 title="SHOULD">べきです</em>。 |
| 162 |
|
|
スクリプトはその出典へのアクセスを滅多に有しないからです。</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> オブジェクトや |
| 163 |
|
|
<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>。 |
| 164 |
|
|
例えば、労働者自体の中で労働者を現すオブジェクトと労働者を作成した文脈で労働者を表すオブジェクトは異なる<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 と何らかの権限 (例えば、 |
| 165 |
|
|
住所録へは追加するが読まない) を保証する接続を折衝することが可能である<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>委譲: ある労働者が別の労働者を生み出し、呼び出し元が委譲に気づかず、 |
| 166 |
|
|
かつ元の労働者がすべてのメッセージを仲介せずに、 |
| 167 |
|
|
当該労働者に対する要求を効率的に委譲できる<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>親が有用ではなくなった労働者は殺される<em class=rfc2119 title="SHOULD">べきです</em>。 |
| 168 |
|
|
労働者はこれが起こることを検知して華麗に終了することができる<em class=rfc2119 title="SHOULD">べきです</em>。</span></ul> |
| 169 |
wakaba |
1.4 |
|
| 170 |
wakaba |
1.9 |
<h3 id=conformance><span class=ja-translation lang=ja><span class=secno>1.3 </span>適合性要件</span></h3> |
| 171 |
wakaba |
1.1 |
|
| 172 |
|
|
<p><span class=ja-translation lang=ja>この仕様書のすべての図、例、注意書きは、 |
| 173 |
|
|
規定の一部ではないと明記された節すべてと同様に、 |
| 174 |
|
|
規定の一部ではありません。 |
| 175 |
|
|
この仕様書のそれ以外のすべては規定の一部です。</span><p><span class=ja-translation lang=ja>この文書の規定の部分にあるキーワード「<em class=rfc2119 title="MUST">しなければなりません</em>」、 |
| 176 |
|
|
「<em class=rfc2119 title="MUST NOT">してはなりません</em>」、 |
| 177 |
|
|
「<em class=rfc2119 title="REQUIRED">必須です</em>」、「<em class=rfc2119 title="SHOULD">するべきです</em>」、 |
| 178 |
|
|
「<em class=rfc2119 title="SHOULD NOT">するべきではありません</em>」、 |
| 179 |
|
|
「<em class=rfc2119 title="RECOMMENDED">推奨します</em>」、「<em class=rfc2119 title="MAY">して構いません</em>」、 |
| 180 |
|
|
「<em class=rfc2119 title="OPTIONAL">任意です</em>」は、 RFC 2119 で説明されているように解釈します。 |
| 181 |
|
|
可読性の観点から、この仕様書<ins class=ja-note>の原文</ins>では、 |
| 182 |
|
|
これらの語<ins class=ja-note>の原語</ins>はすべて大文字では表記しません。 |
| 183 |
|
|
<a href="#refsRFC2119">[RFC2119]</a></span></p> |
| 184 |
|
|
<!-- XXX but they should be |
| 185 |
|
|
marked up --> |
| 186 |
|
|
|
| 187 |
|
|
<p><span class=ja-translation lang=ja>算法の一部として<ins class=ja-note>動作の指示の形で (原文では</ins>命令形で<ins class=ja-note>) </ins>記述された要件 |
| 188 |
|
|
(例えば「先頭の間隔文字をすべて除去します」や「偽を返し、これらの段階を停止します」) |
| 189 |
|
|
は、算法の紹介で使われたキーワード (<em class=rfc2119 title="MUST">しなければなりません</em>、 |
| 190 |
|
|
<em class=rfc2119 title="SHOULD">するべきです</em>、<em class=rfc2119 title="MAY">して構いません</em>など) の意味により解釈します。</span><p><span class=ja-translation lang=ja>いくつかの適合性要件は属性やメソッドやオブジェクトの要件として説明されています。 |
| 191 |
|
|
そのような要件は、利用者エージェントに関する要件として解釈します。</span><p><span class=ja-translation lang=ja>算法や特定の段階として説明されている適合性要件は、 |
| 192 |
|
|
最終的な結果が等価である限り、任意の方法で実装して<em class=rfc2119 title="MAY">構いません</em>。 |
| 193 |
|
|
(特に、この仕様書で定義されている算法は追うのを簡単にしており、 |
| 194 |
|
|
高性能であることを目指してはいません。)</span><p><span class=ja-translation lang=ja>この仕様書で定義される適合性の級は、利用者エージェントのみです。</span><p><span class=ja-translation lang=ja>利用者エージェントは、サービス拒否攻撃を防ぐため、 |
| 195 |
|
|
記憶容量を使い尽くすことを防ぐため、 |
| 196 |
|
|
あるいは環境特有の制限に対応するためなどの目的で、 |
| 197 |
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> |
| 198 |
wakaba |
1.1 |
|
| 199 |
|
|
<p><span class=ja-translation lang=ja>この仕様書は他のいくつかの下位仕様書に依存しています。</span><dl> |
| 200 |
|
|
<dt>HTML5 |
| 201 |
|
|
|
| 202 |
|
|
<dd> |
| 203 |
|
|
<p><span class=ja-translation lang=ja>HTML5 の多くの基礎的な概念をこの仕様書で使用します。 |
| 204 |
|
|
<a href="#refsHTML5">[HTML5]</a></span></p> |
| 205 |
|
|
|
| 206 |
|
|
<dt>ECMAScript |
| 207 |
|
|
|
| 208 |
|
|
<dd> |
| 209 |
|
|
<p><span class=ja-translation lang=ja>この仕様書はスクリプト言語として JavaScript |
| 210 |
|
|
を使うことを想定しています。 <a href="#refsJS">[JS]</a></span></p> |
| 211 |
|
|
|
| 212 |
|
|
<dt>WebIDL |
| 213 |
|
|
|
| 214 |
|
|
<dd> |
| 215 |
wakaba |
1.5 |
<p><span class=ja-translation lang=ja>この仕様書の IDL ブロックは WebIDL 仕様書における意味を用います。 <a href="#refsWebIDL">[WebIDL]</a></span></p> |
| 216 |
wakaba |
1.1 |
</dl> |
| 217 |
|
|
|
| 218 |
wakaba |
1.9 |
<h3 id=terminology><span class=ja-translation lang=ja><span class=secno>1.4 </span>用語</span></h3> |
| 219 |
wakaba |
1.1 |
|
| 220 |
|
|
<p><span class=ja-translation lang=ja>簡単のため、<em>示す</em>、<em>表示する</em>、 |
| 221 |
|
|
<em>可視</em>などの用語を文書が利用者に対してレンダリングされる方法に言及する時に使うことがあります。 |
| 222 |
|
|
これらの語は視覚媒体を暗示することを意図していません。 |
| 223 |
wakaba |
1.9 |
これらの語は他の媒体にも等価な方法で適用されると考えなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p>The construction "a <code title="">Foo</code> object", where <code |
| 224 |
|
|
title="">Foo</code> is actually an interface, is sometimes used instead of |
| 225 |
|
|
the more accurate "an object implementing the interface <code |
| 226 |
|
|
title="">Foo</code>". |
| 227 |
|
|
|
| 228 |
|
|
<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.9 |
データそのものに対して操作されなければ<em class=rfc2119 title="MUST">ならない</em>ことを意味します。</span><h2 id=inside><span class=secno>2. </span>Inside workers</h2> |
| 238 |
|
|
|
| 239 |
|
|
<h3 id=the-windowworker><span class=secno>2.1 </span>The <code><a |
| 240 |
|
|
href="#windowworker">WindowWorker</a></code> interface</h3> |
| 241 |
|
|
|
| 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 |
|
|
};</pre> |
| 247 |
|
|
|
| 248 |
|
|
<p>Objects that implement the <code><a |
| 249 |
|
|
href="#windowworker">WindowWorker</a></code> interface must also implement |
| 250 |
|
|
the <code>Window</code> interface (and thus also the |
| 251 |
|
|
<code>WindowTimers</code> and <code><a |
| 252 |
|
|
href="#windowworkercreators">WindowWorkerCreators</a></code> interfaces) |
| 253 |
|
|
and the <code>EventTarget</code> interface. |
| 254 |
|
|
|
| 255 |
|
|
<p>The <dfn id=name title=dom-windowworker-name><code>name</code></dfn> |
| 256 |
|
|
attribute must return the value it was assigned when the <code><a |
| 257 |
|
|
href="#windowworker">WindowWorker</a></code> object was created by the "<a |
| 258 |
|
|
href="#run-a">run a worker</a>" algorithm. |
| 259 |
|
|
|
| 260 |
|
|
<p>The <dfn id=closing |
| 261 |
|
|
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 |
|
|
<h3 id=the-queue><span class=secno>2.2 </span>The queue of events</h3> |
| 266 |
|
|
|
| 267 |
|
|
<p>Each <code><a href="#windowworker">WindowWorker</a></code> object is |
| 268 |
|
|
asssociated with a <dfn id=queue>queue of events</dfn>, which is initially |
| 269 |
|
|
empty. |
| 270 |
|
|
|
| 271 |
|
|
<p>An event in the queue can be a DOM event or a timeout callback. |
| 272 |
|
|
|
| 273 |
|
|
<h3 id=processing><span class=secno>2.3 </span>Processing model</h3> |
| 274 |
|
|
|
| 275 |
|
|
<p>When a user agent is to <dfn id=run-a>run a worker</dfn> named <var |
| 276 |
|
|
title="">name</var> for a script <var title="">script</var>, a browsing |
| 277 |
|
|
context <var title="">owner browsing context</var> and a |
| 278 |
|
|
<code>Document</code> <var title="">owner document</var>, it must run the |
| 279 |
|
|
following steps in a completely separate and parallel execution |
| 280 |
|
|
environment: |
| 281 |
|
|
|
| 282 |
|
|
<ol> |
| 283 |
|
|
<li> |
| 284 |
|
|
<p>Create a new <code><a href="#windowworker">WindowWorker</a></code> |
| 285 |
|
|
object, <var title="">window</var>.</p> |
| 286 |
|
|
|
| 287 |
|
|
<li> |
| 288 |
|
|
<p>Set the <code title=dom-windowworker-name><a |
| 289 |
|
|
href="#name">name</a></code> attribute of <var title="">window</var> to |
| 290 |
|
|
the value of <var title="">name</var>.</p> |
| 291 |
|
|
|
| 292 |
|
|
<li> |
| 293 |
|
|
<p>Let <var title="">script</var>'s <span>script execution context</span> |
| 294 |
|
|
(and thus also <span>global object</span>) be <var |
| 295 |
|
|
title="">window</var>.</p> |
| 296 |
|
|
|
| 297 |
|
|
<li> |
| 298 |
|
|
<p>Let <var title="">script</var>'s <span>script browsing context</span> |
| 299 |
|
|
be <var title="">owner browsing context</var>.</p> |
| 300 |
|
|
|
| 301 |
|
|
<li> |
| 302 |
|
|
<p>Let <var title="">script</var>'s <span>script document context</span> |
| 303 |
|
|
be <var title="">owner document</var>.</p> |
| 304 |
|
|
|
| 305 |
|
|
<li> |
| 306 |
|
|
<p>Run <var title="">script</var> until it returns.</p> |
| 307 |
|
|
|
| 308 |
|
|
<li> |
| 309 |
|
|
<p><i>Event loop</i>: Wait until there is an event in the <a |
| 310 |
|
|
href="#queue">queue of events</a> associated with <var |
| 311 |
|
|
title="">window</var>.</p> |
| 312 |
|
|
|
| 313 |
|
|
<li> |
| 314 |
|
|
<p>Dispatch the oldest event or callback in the <a href="#queue">queue of |
| 315 |
|
|
events</a>. Events must be targetted at the <code><a |
| 316 |
|
|
href="#windowworker">WindowWorker</a></code> object.</p> |
| 317 |
|
|
|
| 318 |
|
|
<li> |
| 319 |
|
|
<p>If there are any more events in the <a href="#queue">queue of |
| 320 |
|
|
events</a> or if the <var title="">window</var> object's <code |
| 321 |
|
|
title=dom-windowworker-closing><a href="#closing">closing</a></code> |
| 322 |
|
|
attribute is set to false, then jump back to the step above labeled |
| 323 |
|
|
<i>event loop</i>.</p> |
| 324 |
|
|
|
| 325 |
|
|
<li> |
| 326 |
|
|
<p class=big-issue>timers, intervals, XMLHttpRequests, database |
| 327 |
|
|
transactions, etc, must be killed; ports must be deactivated and |
| 328 |
|
|
unentangled</p> |
| 329 |
|
|
</ol> |
| 330 |
|
|
|
| 331 |
|
|
<hr> |
| 332 |
|
|
|
| 333 |
|
|
<p>When a user agent is to <dfn id=kill-a>kill a worker</dfn>, it must run |
| 334 |
|
|
the following steps in parallel with the worker's main loop (the "<a |
| 335 |
|
|
href="#run-a">run a worker</a>" processing model defined above): |
| 336 |
|
|
|
| 337 |
|
|
<ol> |
| 338 |
|
|
<li> |
| 339 |
|
|
<p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code> |
| 340 |
|
|
object's <code title=dom-windowworker-closing><a |
| 341 |
|
|
href="#closing">closing</a></code> attribute to true. |
| 342 |
|
|
|
| 343 |
|
|
<li> |
| 344 |
|
|
<p>Create an <code>Event</code> object with the event name <code |
| 345 |
|
|
title=event-unload>unload</code>, which does not bubble and is not |
| 346 |
|
|
cancelable, and add it to the worker's <code><a |
| 347 |
|
|
href="#windowworker">WindowWorker</a></code> object's <a |
| 348 |
|
|
href="#queue">queue of events</a>. |
| 349 |
|
|
|
| 350 |
|
|
<li> |
| 351 |
|
|
<p>Wait a user-agent-defined amount of time. |
| 352 |
|
|
|
| 353 |
|
|
<li> |
| 354 |
|
|
<p>If there are any events in the <a href="#queue">queue of events</a> |
| 355 |
|
|
other than the <code title=event-unload>unload</code> event that this |
| 356 |
|
|
algorithm just added, discard them without dispatching them. |
| 357 |
|
|
|
| 358 |
|
|
<li> |
| 359 |
|
|
<p>If the <code title=event-unload>unload</code> event that this |
| 360 |
|
|
algorithm just added hasn't yet been dispatched, then abort the script |
| 361 |
|
|
currently running in the worker. |
| 362 |
|
|
|
| 363 |
|
|
<li> |
| 364 |
|
|
<p>Wait a user-agent-defined amount of time. |
| 365 |
|
|
|
| 366 |
|
|
<li> |
| 367 |
|
|
<p>Abort the script currently running in the worker (if any script is |
| 368 |
|
|
running, then it will be a handler for the <code |
| 369 |
|
|
title=event-unload>unload</code> event). |
| 370 |
|
|
</ol> |
| 371 |
|
|
|
| 372 |
|
|
<h2 id=creating><span class=secno>3. </span>Creating workers</h2> |
| 373 |
|
|
|
| 374 |
|
|
<h3 id=the-windowworkercreators><span class=secno>3.1 </span>The <code><a |
| 375 |
|
|
href="#windowworkercreators">WindowWorkerCreators</a></code> interface</h3> |
| 376 |
|
|
|
| 377 |
|
|
<pre |
| 378 |
|
|
class=idl>[NoInterfaceObject] interface <dfn id=windowworkercreators>WindowWorkerCreators</dfn> { |
| 379 |
|
|
<span>MessagePort</span> <span title=dom-WindowWorkerCreators-createWorker>createWorker</span>(in DOMString scriptURI); |
| 380 |
|
|
<span>MessagePort</span> <span title=dom-WindowWorkerCreators-createNamedWorker>createNamedWorker</span>(in DOMString name, in DOMString scriptURI); |
| 381 |
|
|
};</pre> |
| 382 |
|
|
|
| 383 |
|
|
<p>Objects that implement the <code>Window</code> interface must also |
| 384 |
|
|
implement the <code><a |
| 385 |
|
|
href="#windowworkercreators">WindowWorkerCreators</a></code> interface. |
| 386 |
|
|
|
| 387 |
|
|
<p class=big-issue>... |
| 388 |
|
|
|
| 389 |
|
|
<h2 class=no-num id=references><span class=ja-translation lang=ja>参考文献</span></h2> |
| 390 |
wakaba |
1.1 |
|
| 391 |
|
|
<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> |
| 392 |
|
|
<!-- ACKS --> |
| 393 |
|
|
|
| 394 |
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 |
| 395 |
|
|
whose experience has been a huge influence on this specification. |