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