Do not link ghc stage1 using -threaded, only for stage2 or 3
[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 #if defined(PARALLEL_HASKELL)
15 #error Sparks.c using new internal structure, needs major overhaul!
16 #endif
17
18 /* typedef for SparkPool in RtsTypes.h */
19
20 #if defined(THREADED_RTS)
21
22 typedef WSDeque SparkPool;
23
24 // Initialisation
25 void initSparkPools (void);
26
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);
30
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);
34
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);
40
41 INLINE_HEADER void discardSparks  (SparkPool *pool);
42 INLINE_HEADER long sparkPoolSize  (SparkPool *pool);
43
44 /* -----------------------------------------------------------------------------
45  * PRIVATE below here
46  * -------------------------------------------------------------------------- */
47
48 INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool)
49 {
50     return popWSDeque(pool);
51 }
52
53 INLINE_HEADER rtsBool looksEmpty(SparkPool* deque)
54 {
55     return looksEmptyWSDeque(deque);
56 }
57
58 INLINE_HEADER long sparkPoolSize (SparkPool *pool) 
59
60     return dequeElements(pool);
61 }
62
63 INLINE_HEADER void discardSparks (SparkPool *pool)
64 {
65     discardElements(pool);
66 }
67
68 #endif // THREADED_RTS
69
70 #endif /* SPARKS_H */