summaryrefslogtreecommitdiff
path: root/rts/Sparks.h
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2011-06-01 18:17:27 +0100
committerDuncan Coutts <duncan@well-typed.com>2011-07-18 16:31:13 +0100
commitededf355981fd08f52b4fab256f231179848073f (patch)
tree8e58b1f32cbee934de31f6012b19d5d55c6f08a1 /rts/Sparks.h
parente0b98b42847dea19aff24df2faa354c9d414fc87 (diff)
downloadhaskell-ededf355981fd08f52b4fab256f231179848073f.tar.gz
Change tryStealSpark so it does not consume fizzled sparks
We want to count fizzled sparks accurately. Now tryStealSpark returns fizzled sparks, and the callers now update the fizzled spark count.
Diffstat (limited to 'rts/Sparks.h')
-rw-r--r--rts/Sparks.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/rts/Sparks.h b/rts/Sparks.h
index d714cb5d09..e3ddc0cfaa 100644
--- a/rts/Sparks.h
+++ b/rts/Sparks.h
@@ -30,7 +30,7 @@ INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool);
// if the pool is almost empty).
INLINE_HEADER rtsBool looksEmpty(SparkPool* deque);
-StgClosure * tryStealSpark (Capability *cap);
+INLINE_HEADER StgClosure * tryStealSpark (SparkPool *cap);
INLINE_HEADER rtsBool fizzledSpark (StgClosure *);
void freeSparkPool (SparkPool *pool);
@@ -65,6 +65,27 @@ INLINE_HEADER void discardSparks (SparkPool *pool)
discardElements(pool);
}
+/* ----------------------------------------------------------------------------
+ *
+ * tryStealSpark: try to steal a spark from a Capability.
+ *
+ * Returns either:
+ * (a) a useful spark;
+ * (b) a fizzled spark (use fizzledSpark to check);
+ * (c) or NULL if the pool was empty, and can occasionally return NULL
+ * if there was a race with another thread stealing from the same
+ * pool. In this case, try again later.
+ *
+ -------------------------------------------------------------------------- */
+
+INLINE_HEADER StgClosure * tryStealSpark (SparkPool *pool)
+{
+ return stealWSDeque_(pool);
+ // use the no-loopy version, stealWSDeque_(), since if we get a
+ // spurious NULL here the caller may want to try stealing from
+ // other pools before trying again.
+}
+
INLINE_HEADER rtsBool fizzledSpark (StgClosure *spark)
{
return (GET_CLOSURE_TAG(spark) != 0 || !closure_SHOULD_SPARK(spark));