on master help sign in
Add some todo comments
commitb65e94d0cfe1f4b7d96337d2f170d8bdd90c50ba authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 6 Jun 2018, 12:02 (8 years ago) parentc28f3f1
1 file changed+19
src/Streamly/Core.hs+19
src/Streamly/Core.hs+19
@@ -496,6 +496,10 @@ runqueueLIFO sv q = run
496496-- WAsync
497497-------------------------------------------------------------------------------
498498
499+-- XXX we can use the Ahead style sequence/heap mechanism to make the best
500+-- effort to always try to finish the streams on the left side of an expression
501+-- first as long as possible.
502+
499503{-# INLINE enqueueFIFO #-}
500504enqueueFIFO :: SVar m a -> LinkedQueue (Stream m a) -> Stream m a -> IO ()
501505enqueueFIFO sv q m = do
@@ -630,6 +634,13 @@ enqueueAhead sv q m = do
630634-- dequeuing from the work queue. If it finds that the task at the top of the
631635-- heap is the one that owns the current sequence number then it grabs the
632636-- token and starts with that.
637+--
638+-- XXX instead of queueing just the head element and the remaining computation
639+-- on the heap, evaluate as many as we can and place them on the heap. But we
640+-- need to give higher priority to the lower sequence numbers so that lower
641+-- priority tasks do not fill up the heap making higher priority tasks block
642+-- due to full heap. Maybe we can have a weighted space for them in the heap.
643+-- The weight is inversely proportional to the sequence number.
633644runqueueAhead :: MonadIO m => SVar m a -> IORef ([Stream m a], Int) -> m ()
634645runqueueAhead sv q = runHeap
635646
@@ -743,6 +754,14 @@ runqueueAhead sv q = runHeap
743754 then ((hp', seqNo), Just ent)
744755 else (hp, Nothing)
745756
757+-------------------------------------------------------------------------------
758+-- WAhead
759+-------------------------------------------------------------------------------
760+
761+-- XXX To be implemented. Use a linked queue like WAsync and put back the
762+-- remaining computation at the back of the queue instead of the heap, and
763+-- increment the sequence number.
764+
746765-- Thread tracking is needed for two reasons:
747766--
748767-- 1) Killing threads on exceptions. Threads may not be left to go away by