@@ -40,9 +40,6 @@ function Base.put!(store::StreamStore{T,B}, value) where {T,B}
40
40
end
41
41
@dagdebug thunk_id :stream " adding $value ($(length (store. output_streams)) outputs)"
42
42
for output_uid in keys (store. output_streams)
43
- if ! haskey (store. output_buffers, output_uid)
44
- initialize_output_stream! (store, output_uid)
45
- end
46
43
buffer = store. output_buffers[output_uid]
47
44
while isfull (buffer)
48
45
if ! isopen (store)
@@ -257,10 +254,13 @@ function initialize_input_stream!(our_store::StreamStore{OT,OB}, input_stream::S
257
254
end
258
255
initialize_input_stream! (our_store:: StreamStore , arg) = arg
259
256
function initialize_output_stream! (our_store:: StreamStore{T,B} , output_uid:: UInt ) where {T,B}
260
- @assert islocked (our_store. lock)
261
257
@dagdebug STREAM_THUNK_ID[] :stream " initializing output stream $output_uid "
262
- buffer = initialize_stream_buffer (B, T, our_store. output_buffer_amount)
263
- our_store. output_buffers[output_uid] = buffer
258
+ local buffer
259
+ @lock our_store. lock begin
260
+ buffer = initialize_stream_buffer (B, T, our_store. output_buffer_amount)
261
+ our_store. output_buffers[output_uid] = buffer
262
+ end
263
+
264
264
our_uid = our_store. uid
265
265
output_stream = our_store. output_streams[output_uid]
266
266
output_fetcher = our_store. output_fetchers[output_uid]
@@ -595,6 +595,16 @@ function stream!(sf::StreamingFunction, uid,
595
595
f = move (thunk_processor (), sf. f)
596
596
counter = 0
597
597
598
+ # Initialize output streams. We can't do this in add_waiters!() because the
599
+ # output handlers depend on the DTaskTLS, so they have to be set up from
600
+ # within the DTask.
601
+ store = sf. stream. store
602
+ for output_uid in keys (store. output_streams)
603
+ if ! haskey (store. output_buffers, output_uid)
604
+ initialize_output_stream! (store, output_uid)
605
+ end
606
+ end
607
+
598
608
while true
599
609
# Yield to other (streaming) tasks
600
610
yield ()
0 commit comments