Overview.htm
changeset 139 ea63ef46f36e
parent 138 6cc871794be1
child 140 93d7056adf94
equal deleted inserted replaced
138:6cc871794be1 139:ea63ef46f36e
  1016 						Data sources may respond to retrieval requests with data larger than requested.
  1016 						Data sources may respond to retrieval requests with data larger than requested.
  1017 						Requests and delivery of data don't need to 1-to-1 correspond.
  1017 						Requests and delivery of data don't need to 1-to-1 correspond.
  1018 						Data sources may produce data and send to <a>ReadableStream</a> unsolicitedly without receiving any retrieval request.
  1018 						Data sources may produce data and send to <a>ReadableStream</a> unsolicitedly without receiving any retrieval request.
  1019 					</li>
  1019 					</li>
  1020 					<li>
  1020 					<li>
  1021 						Accepts and acknowledges <dfn>read-abort</dfn> signal which means the associated <a>ReadableStream</a> has completed consuming bytes from this data source optionally with indication of any error.
  1021 						Accepts and acknowledges <dfn>read-abort</dfn> signal which means the associated <a>ReadableStream</a> has completed consuming data from this data source optionally with indication of any error.
  1022 					</li>
  1022 					</li>
  1023 				</ul>
  1023 				</ul>
  1024 			</p>
  1024 			</p>
  1025 
  1025 
  1026 			<p>
  1026 			<p>
  1047 				This interface is designed to work even if operations on <a>dataSource</a> are asynchronous.
  1047 				This interface is designed to work even if operations on <a>dataSource</a> are asynchronous.
  1048 				If <a>dataSource</a> is synchronously accessible, some of the algorithms can be simplified.
  1048 				If <a>dataSource</a> is synchronously accessible, some of the algorithms can be simplified.
  1049 			</section>
  1049 			</section>
  1050 
  1050 
  1051 			<p>
  1051 			<p>
  1052 				A ReadableStream has an associated <a>data source</a> referred by <dfn>dataSource</dfn> from which the ReadableStream retrieves bytes.
  1052 				A <a>ReadableStream</a> has an associated <a>data source</a> referred by <dfn>dataSource</dfn> from which the ReadableStream retrieves data.
  1053 				The data source model is explained in <a href="#h2_data_source">this section</a>.
  1053 				The data source model is explained in <a href="#h2_data_source">this section</a>.
  1054 				A data source can be shared by multiple ReadableStream instances when <code>fork()</code> is used.
  1054 				A data source can be shared by multiple ReadableStream instances when <code>fork()</code> is used.
  1055 				A ReadableStream is registered with a data source on construction and given a reader ID.
  1055 				A ReadableStream is registered with a data source on construction and given a reader ID.
  1056 				The <a>dataSource</a> of a ReadableStream refers to its data source, and <dfn>readerId</dfn> of a ReadableStream refers to its reader ID.
  1056 				The <a>dataSource</a> of a ReadableStream refers to its data source, and <dfn>readerId</dfn> of a ReadableStream refers to its reader ID.
  1057 			</p>
  1057 			</p>
  1258 					<li>Set <a>amountBeingReturned</a> to <var>amountConsumed</var></li>
  1258 					<li>Set <a>amountBeingReturned</a> to <var>amountConsumed</var></li>
  1259 
  1259 
  1260 					<li>Set <a>readUpToPullAmount</a> to 0</li>
  1260 					<li>Set <a>readUpToPullAmount</a> to 0</li>
  1261 
  1261 
  1262 					<li>Let <var>readPromise</var> to <var>pendingRead.promise</var></li>
  1262 					<li>Let <var>readPromise</var> to <var>pendingRead.promise</var></li>
  1263 					<li>Set <a>pendingRead</a> to null</li>
  1263 					<li>Set <a>pendingRead</a> to <code>null</code></li>
  1264 					<li>Fulfill <var>readPromise</var> with <var>result</var></li>
  1264 					<li>Fulfill <var>readPromise</var> with <var>result</var></li>
  1265 				</ol>
  1265 				</ol>
  1266 			</p>
  1266 			</p>
  1267 
  1267 
  1268 			<p>
  1268 			<p>
  1311 
  1311 
  1312 				<ol>
  1312 				<ol>
  1313 					<li>
  1313 					<li>
  1314 						Let <var>onFulfilled</var> be a callback which runs the steps below:
  1314 						Let <var>onFulfilled</var> be a callback which runs the steps below:
  1315 
  1315 
  1316 						<dl class="switch">
  1316 						<ol>
  1317 							<dt>If <a>eofReached</a> is set or <a>pendingRead</a>.<var>size</var> is 0</dt>
  1317 							<li>Let <var>writtenAmounts</var> be the first argument</li>
  1318 							<dd>
  1318 							<li>
  1319 								<ol>
  1319 								<dl class="switch">
  1320 									<li>Set <a>pipePullAmount</a> to 0</li>
  1320 									<dt>If <a>eofReached</a> is set or <a>pendingRead</a>.<var>size</var> is 0</dt>
  1321 
  1321 									<dd>
  1322 									<li>Unset <a>readPending</a></li>
  1322 										<ol>
  1323 
  1323 											<li>Set <a>pipePullAmount</a> to 0</li>
  1324 									<li>Let <var>result</var> be a newly-created <a>StreamReadResult</a></li>
  1324 
  1325 
  1325 											<li>Let <var>pipePromise</var> be <a>pendingRead</a>.<var>promise</var></li>
  1326 									<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to <code>undefined</code>.
  1326 											<li>Set <a>pendingRead</a> to <code>null</code></li>
  1327 									<li>Set <var>result</var>.<a href="#widl-StreamReadResult-eof">eof</a> to <code>true</code> if <a>eofReached</a></li>
  1327 
  1328 									<li>Set <var>result</var>.<a href="#widl-StreamReadResult-amountConsumed">amountConsumed</a> to <var>totalAmountTransferred</var></li>
  1328 											<li>Let <var>result</var> be a newly-created <a>StreamReadResult</a></li>
  1329 									<li>
  1329 
  1330 										Fulfill <var>pipePromise</var> with <var>result</var>
  1330 											<li>Set <var>result</var>.<a href="#widl-StreamReadResult-data">data</a> to <code>undefined</code></li>
       
  1331 											<li>Set <var>result</var>.<a href="#widl-StreamReadResult-eof">eof</a> to <code>true</code> if <a>eofReached</a></li>
       
  1332 											<li>Set <var>result</var>.<a href="#widl-StreamReadResult-amountConsumed">amountConsumed</a> to the sum of elements in <var>writtenAmounts</var></li>
       
  1333 											<li>
       
  1334 												Fulfill <var>pipePromise</var> with <var>result</var>
       
  1335 												<section class="note">
       
  1336 													At this point, <a>amountBeingReturned</a> is not yet reset
       
  1337 												</section>
       
  1338 											</li>
       
  1339 										</ol>
  1331 										<section class="note">
  1340 										<section class="note">
  1332 											At this point, <a>amountBeingReturned</a> is not yet reset
  1341 											Need to revisit. Finish when write to the destination completes?
  1333 										</section>
  1342 										</section>
  1334 									</li>
  1343 									</dd>
  1335 								</ol>
  1344 									<dt>Otherwise</dt>
  1336 								<section class="note">
  1345 									<dd>
  1337 									Need to revisit. Finish when write to the destination completes?
  1346 									</dd>
  1338 								</section>
  1347 								</dl>
  1339 							</dd>
  1348 							</li>
  1340 							<dt>Otherwise</dt>
  1349 						</ol>
  1341 							<dd>
       
  1342 							</dd>
       
  1343 						</dl>
       
  1344 					</li>
  1350 					</li>
  1345 
  1351 
  1346 					<li>
  1352 					<li>
  1347 						<dl class="switch">
  1353 						<dl class="switch">
  1348 							<dt>If <a>pendingRead</a>.<var>size</var> is <code>undefined</code></dt>
  1354 							<dt>If <a>pendingRead</a>.<var>size</var> is <code>undefined</code></dt>