forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
224 lines (204 loc) · 12.1 KB
/
index.html
File metadata and controls
224 lines (204 loc) · 12.1 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScriptKit - JavaScriptEventLoop</title>
<link rel="stylesheet" type="text/css" href="/JavaScriptKit/all.css" media="all" />
</head>
<body>
<header>
<a href="/JavaScriptKit">
<strong>
JavaScriptKit
</strong>
<span>Documentation</span>
</a>
</header>
<!--
<form class="search">
<input type="search" placeholder="Search" />
</form>
-->
<nav>
<div class="wrapper">
<h2>On This Page</h2>
<ol><li><a href="#relationships">Relationships</a><ul><li><a href="#relationships">Conforms To</a></li></ul></li><li><a href="#properties">Properties</a><ul><li class="variable"><a href="#javascripteventloop.queuemicrotask">queueMicrotask</a></li><li class="variable"><a href="#javascripteventloop.settimeout">setTimeout</a></li><li class="variable"><a href="#javascripteventloop.shared">shared</a></li></ul></li><li><a href="#methods">Methods</a><ul><li class="function"><a href="#javascripteventloop.installglobalexecutor()">installGlobalExecutor()</a></li><li class="function"><a href="#javascripteventloop.enqueue(_:)">enqueue(_:)</a></li><li class="function"><a href="#javascripteventloop.asunownedserialexecutor()">asUnownedSerialExecutor()</a></li></ul></li></ol>
</div>
</nav>
<main>
<article>
<h1>
<small>Class</small>
<code class="name">JavaScriptEventLoop</code>
</h1>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="attribute">@</span><span class="attribute">available</span>(<span class="keyword">macOS</span> <span class="number literal">10.15</span>, <span class="keyword">iOS</span> <span class="number literal">13.0</span>, <span class="keyword">watchOS</span> <span class="number literal">6.0</span>, <span class="keyword">tvOS</span> <span class="number literal">13.0</span>, *)
<span class="keyword">public</span> <span class="attribute">final</span> <span class="keyword">class</span> <span class="type">JavaScriptEventLoop</span>: <span class="type">SerialExecutor</span>, <span class="attribute">@</span><span class="attribute">unchecked</span> <span class="type">Sendable</span> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>Singleton type responsible for integrating JavaScript event loop as a Swift concurrency executor, conforming to
<code>SerialExecutor</code> protocol from the standard library. To utilize it:</p>
</div>
<div class="discussion">
<ol>
<li>Make sure that your target depends on <code>JavaScriptEventLoop</code> in your <code>Packages.swift</code>:</li>
</ol>
<html><body><pre class="highlight"><code>.<span class="variable">target</span>(
<span class="variable">name</span>: <span class="string literal">"</span><span class="string literal">JavaScriptKitExample</span><span class="string literal">"</span>,
<span class="variable">dependencies</span>: [
<span class="string literal">"</span><span class="string literal">JavaScriptKit</span><span class="string literal">"</span>,
.<span class="variable">product</span>(<span class="variable">name</span>: <span class="string literal">"</span><span class="string literal">JavaScriptEventLoop</span><span class="string literal">"</span>, <span class="variable">package</span>: <span class="string literal">"</span><span class="string literal">JavaScriptKit</span><span class="string literal">"</span>)
]
)
</code></pre></body></html>
<ol start="2">
<li>Add an explicit import in the code that executes *<em>before</em> you start using <code>await</code> and/or <code>Task</code>
APIs (most likely in <code>main.swift</code>):</li>
</ol>
<html><body><pre class="highlight"><code><span class="keyword">import</span> <span class="variable">JavaScriptEventLoop</span>
</code></pre></body></html>
<ol start="3">
<li>Run this function *<em>before</em> you start using <code>await</code> and/or <code>Task</code> APIs (again, most likely in
<code>main.swift</code>):</li>
</ol>
<html><body><pre class="highlight"><code><span class="variable">JavaScriptEventLoop</span>.<span class="variable">installGlobalExecutor</span>()
</code></pre></body></html>
</div>
<section id="relationships">
<h2 hidden>Relationships</h2>
<figure>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %27 Pages: 1 -->
<svg width="872pt" height="116pt"
viewBox="0.00 0.00 872.00 116.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 112)">
<title>%27</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-112 868,-112 868,4 -4,4"/>
<!-- JavaScriptEventLoop -->
<g id="node1" class="node class current">
<title>JavaScriptEventLoop</title>
<g id="a_node1"><a xlink:href="/JavaScriptKit/JavaScriptEventLoop" xlink:title="JavaScriptEventLoop">
<path fill="none" stroke="#000000" stroke-width="3" d="M528,-108C528,-108 336,-108 336,-108 330,-108 324,-102 324,-96 324,-96 324,-84 324,-84 324,-78 330,-72 336,-72 336,-72 528,-72 528,-72 534,-72 540,-78 540,-84 540,-84 540,-96 540,-96 540,-102 534,-108 528,-108"/>
<text text-anchor="middle" x="432" y="-86.3" font-family="Menlo" font-size="14.00" fill="#000000">JavaScriptEventLoop</text>
</a>
</g>
</g>
<!-- SerialExecutor -->
<g id="node2" class="node unknown">
<title>SerialExecutor</title>
<path fill="none" stroke="#000000" d="M303,-36C303,-36 111,-36 111,-36 105,-36 99,-30 99,-24 99,-24 99,-12 99,-12 99,-6 105,0 111,0 111,0 303,0 303,0 309,0 315,-6 315,-12 315,-12 315,-24 315,-24 315,-30 309,-36 303,-36"/>
<text text-anchor="middle" x="207" y="-14.3" font-family="Menlo" font-size="14.00" fill="#000000">SerialExecutor</text>
</g>
<!-- JavaScriptEventLoop->SerialExecutor -->
<g id="edge1" class="edge conformsTo">
<title>JavaScriptEventLoop->SerialExecutor</title>
<path fill="none" stroke="#000000" d="M375.5134,-71.9243C344.4871,-61.9959 305.8297,-49.6255 273.3694,-39.2382"/>
<polygon fill="#000000" stroke="#000000" points="274.1008,-35.7975 263.5098,-36.0831 271.9673,-42.4645 274.1008,-35.7975"/>
</g>
<!-- @unchecked Sendable -->
<g id="node3" class="node unknown">
<title>@unchecked Sendable</title>
<path fill="none" stroke="#000000" d="M753,-36C753,-36 561,-36 561,-36 555,-36 549,-30 549,-24 549,-24 549,-12 549,-12 549,-6 555,0 561,0 561,0 753,0 753,0 759,0 765,-6 765,-12 765,-12 765,-24 765,-24 765,-30 759,-36 753,-36"/>
<text text-anchor="middle" x="657" y="-14.3" font-family="Menlo" font-size="14.00" fill="#000000">@unchecked Sendable</text>
</g>
<!-- JavaScriptEventLoop->@unchecked Sendable -->
<g id="edge2" class="edge conformsTo">
<title>JavaScriptEventLoop->@unchecked Sendable</title>
<path fill="none" stroke="#000000" d="M488.4866,-71.9243C519.5129,-61.9959 558.1703,-49.6255 590.6306,-39.2382"/>
<polygon fill="#000000" stroke="#000000" points="592.0327,-42.4645 600.4902,-36.0831 589.8992,-35.7975 592.0327,-42.4645"/>
</g>
</g>
</svg>
<figcaption hidden>Inheritance graph for JavaScriptEventLoop.</figcaption>
</figure>
<h3>Conforms To</h3>
<dl>
<dt class="unknown"><code>@unchecked Sendable</code></dt>
<dt class="unknown"><code>SerialExecutor</code></dt>
</dl>
</section>
<section id="properties">
<h2>Properties</h2>
<div role="article" class="variable" id="javascripteventloop.queuemicrotask">
<h3>
<code><a href="#javascripteventloop.queuemicrotask">queueMicrotask</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">var</span> <span class="variable">queueMicrotask</span>: <span class="attribute">@</span><span class="attribute">Sendable</span> (<span class="attribute">@</span><span class="attribute">escaping</span> () -> <span class="type">Void</span>) -> <span class="type">Void</span></body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>A function that queues a given closure as a microtask into JavaScript event loop.
See also: https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide</p>
</div>
</div>
<div role="article" class="variable" id="javascripteventloop.settimeout">
<h3>
<code><a href="#javascripteventloop.settimeout">setTimeout</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">var</span> <span class="variable">setTimeout</span>: <span class="attribute">@</span><span class="attribute">Sendable</span> (<span class="type">Double</span>, <span class="attribute">@</span><span class="attribute">escaping</span> () -> <span class="type">Void</span>) -> <span class="type">Void</span></body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>A function that invokes a given closure after a specified number of milliseconds.</p>
</div>
</div>
<div role="article" class="variable" id="javascripteventloop.shared">
<h3>
<code><a href="#javascripteventloop.shared">shared</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">let</span> <span class="variable">shared</span>: <a href="/JavaScriptKit/JavaScriptEventLoop"><span class="type">JavaScriptEventLoop</span></a> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>A singleton instance of the Executor</p>
</div>
</div>
</section>
<section id="methods">
<h2>Methods</h2>
<div role="article" class="function" id="javascripteventloop.installglobalexecutor()">
<h3>
<code><a href="#javascripteventloop.installglobalexecutor()">installGlobalExecutor()</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">func</span> <span class="function">installGlobalExecutor</span>() </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>Set JavaScript event loop based executor to be the global executor
Note that this should be called before any of the jobs are created.
This installation step will be unnecessary after custom executor are
introduced officially. See also <a href="https://github.com/rjmccall/swift-evolution/blob/custom-executors/proposals/0000-custom-executors.md#the-default-global-concurrent-executor">a draft proposal for custom
executors</a></p>
</div>
</div>
<div role="article" class="function" id="javascripteventloop.enqueue(_:)">
<h3>
<code><a href="#javascripteventloop.enqueue(_:)">enqueue(_:)</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">enqueue</span>(<span class="keyword">_</span> <span class="variable">job</span>: <span class="type">UnownedJob</span>) </body></html></code></pre>
</div>
</div>
<div role="article" class="function" id="javascripteventloop.asunownedserialexecutor()">
<h3>
<code><a href="#javascripteventloop.asunownedserialexecutor()">asUnownedSerialExecutor()</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">asUnownedSerialExecutor</span>() -> <span class="type">UnownedSerialExecutor</span> </body></html></code></pre>
</div>
</div>
</section>
</article>
</main>
<footer>
<p>
Generated on <time datetime="2022-10-26T01:29:08+0000">October 26, 2022</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a> <span class="version">1.0.0-rc.1</span>.
</p>
</footer>
</body>
</html>