1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 2000-2009
5 * Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
7 * ---------------------------------------------------------------------------*/
14 #if defined(PARALLEL_HASKELL)
15 #error Sparks.c using new internal structure, needs major overhaul!
18 /* typedef for SparkPool in RtsTypes.h */
20 #if defined(THREADED_RTS)
22 typedef WSDeque SparkPool;
25 void initSparkPools (void);
27 // Take a spark from the "write" end of the pool. Can be called
28 // by the pool owner only.
29 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool);
31 // Returns True if the spark pool is empty (can give a false positive
32 // if the pool is almost empty).
33 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque);
35 StgClosure * tryStealSpark (Capability *cap);
36 void freeSparkPool (SparkPool *pool);
37 void createSparkThread (Capability *cap);
38 void traverseSparkQueue(evac_fn evac, void *user, Capability *cap);
39 void pruneSparkQueue (evac_fn evac, void *user, Capability *cap);
41 INLINE_HEADER void discardSparks (SparkPool *pool);
42 INLINE_HEADER long sparkPoolSize (SparkPool *pool);
44 /* -----------------------------------------------------------------------------
46 * -------------------------------------------------------------------------- */
48 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool)
50 return popWSDeque(pool);
53 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque)
55 return looksEmptyWSDeque(deque);
58 INLINE_HEADER long sparkPoolSize (SparkPool *pool)
60 return dequeElements(pool);
63 INLINE_HEADER void discardSparks (SparkPool *pool)
65 discardElements(pool);
68 #endif // THREADED_RTS