1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 2000-2009
5 * Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
7 * ---------------------------------------------------------------------------*/
14 #include "BeginPrivate.h"
16 /* typedef for SparkPool in RtsTypes.h */
18 #if defined(THREADED_RTS)
20 typedef WSDeque SparkPool;
23 void initSparkPools (void);
25 // Take a spark from the "write" end of the pool. Can be called
26 // by the pool owner only.
27 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool);
29 // Returns True if the spark pool is empty (can give a false positive
30 // if the pool is almost empty).
31 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque);
33 StgClosure * tryStealSpark (Capability *cap);
34 void freeSparkPool (SparkPool *pool);
35 void createSparkThread (Capability *cap);
36 void traverseSparkQueue(evac_fn evac, void *user, Capability *cap);
37 void pruneSparkQueue (Capability *cap);
39 INLINE_HEADER void discardSparks (SparkPool *pool);
40 INLINE_HEADER long sparkPoolSize (SparkPool *pool);
42 /* -----------------------------------------------------------------------------
44 * -------------------------------------------------------------------------- */
46 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool)
48 return popWSDeque(pool);
51 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque)
53 return looksEmptyWSDeque(deque);
56 INLINE_HEADER long sparkPoolSize (SparkPool *pool)
58 return dequeElements(pool);
61 INLINE_HEADER void discardSparks (SparkPool *pool)
63 discardElements(pool);
66 #endif // THREADED_RTS
68 #include "EndPrivate.h"