summaryrefslogtreecommitdiff
path: root/rts/Schedule.h
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-01-15 15:04:08 -0800
committerEdward Z. Yang <ezyang@mit.edu>2013-01-16 13:49:01 -0800
commit0aae1e173b4731a60648960aa03910ccb16fe0e0 (patch)
tree4d9e2e7d57f86dd5e4fafc2879fd060388aa50ef /rts/Schedule.h
parent8f731f2ba83cd62da78a3ef8f1560902948f97a4 (diff)
downloadhaskell-0aae1e173b4731a60648960aa03910ccb16fe0e0.tar.gz
Better abstraction over run queues.
This adds some new functions: peekRunQueue, promoteInRunQueue, singletonRunQueue and truncateRunQueue which help abstract away manual linked list manipulation, making it easier to swap in a new queue implementation. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Diffstat (limited to 'rts/Schedule.h')
-rw-r--r--rts/Schedule.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/rts/Schedule.h b/rts/Schedule.h
index a44949ebb7..8b7caeaf07 100644
--- a/rts/Schedule.h
+++ b/rts/Schedule.h
@@ -183,7 +183,14 @@ popRunQueue (Capability *cap)
return t;
}
-extern void removeFromRunQueue (Capability *cap, StgTSO *tso);
+INLINE_HEADER StgTSO *
+peekRunQueue (Capability *cap)
+{
+ return cap->run_queue_hd;
+}
+
+void removeFromRunQueue (Capability *cap, StgTSO *tso);
+extern void promoteInRunQueue (Capability *cap, StgTSO *tso);
/* Add a thread to the end of the blocked queue.
*/
@@ -215,6 +222,22 @@ emptyRunQueue(Capability *cap)
return emptyQueue(cap->run_queue_hd);
}
+/* assumes that the queue is not empty; so combine this with
+ * an emptyRunQueue check! */
+INLINE_HEADER rtsBool
+singletonRunQueue(Capability *cap)
+{
+ ASSERT(!emptyRunQueue(cap));
+ return cap->run_queue_hd->_link == END_TSO_QUEUE;
+}
+
+INLINE_HEADER void
+truncateRunQueue(Capability *cap)
+{
+ cap->run_queue_hd = END_TSO_QUEUE;
+ cap->run_queue_tl = END_TSO_QUEUE;
+}
+
#if !defined(THREADED_RTS)
#define EMPTY_BLOCKED_QUEUE() (emptyQueue(blocked_queue_hd))
#define EMPTY_SLEEPING_QUEUE() (emptyQueue(sleeping_queue))