Remove old GUM/GranSim code
[ghc-hetmet.git] / rts / Sparks.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 2000-2009
4  *
5  * Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
6  * 
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef SPARKS_H
10 #define SPARKS_H
11
12 #include "WSDeque.h"
13
14 /* typedef for SparkPool in RtsTypes.h */
15
16 #if defined(THREADED_RTS)
17
18 typedef WSDeque SparkPool;
19
20 // Initialisation
21 void initSparkPools (void);
22
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);
26
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);
30
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);
36
37 INLINE_HEADER void discardSparks  (SparkPool *pool);
38 INLINE_HEADER long sparkPoolSize  (SparkPool *pool);
39
40 /* -----------------------------------------------------------------------------
41  * PRIVATE below here
42  * -------------------------------------------------------------------------- */
43
44 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool)
45 {
46     return popWSDeque(pool);
47 }
48
49 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque)
50 {
51     return looksEmptyWSDeque(deque);
52 }
53
54 INLINE_HEADER long sparkPoolSize (SparkPool *pool) 
55
56     return dequeElements(pool);
57 }
58
59 INLINE_HEADER void discardSparks (SparkPool *pool)
60 {
61     discardElements(pool);
62 }
63
64 #endif // THREADED_RTS
65
66 #endif /* SPARKS_H */