blob: bf10a59d57944a2aa9d4b7ac61cf6b3cc834e129 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 2000-2006
*
* Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
*
* ---------------------------------------------------------------------------*/
#ifndef SPARKS_H
#define SPARKS_H
#if defined(THREADED_RTS)
StgClosure * findSpark (Capability *cap);
void initSparkPools (void);
void freeSparkPool (StgSparkPool *pool);
void createSparkThread (Capability *cap, StgClosure *p);
void updateSparkQueue (Capability *cap);
void traverseSparkQueue(evac_fn evac, void *user, Capability *cap);
INLINE_HEADER void discardSparks (StgSparkPool *pool);
INLINE_HEADER nat sparkPoolSize (StgSparkPool *pool);
INLINE_HEADER rtsBool emptySparkPool (StgSparkPool *pool);
INLINE_HEADER void discardSparksCap (Capability *cap);
INLINE_HEADER nat sparkPoolSizeCap (Capability *cap);
INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap);
#endif
/* -----------------------------------------------------------------------------
* PRIVATE below here
* -------------------------------------------------------------------------- */
#if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
INLINE_HEADER rtsBool
emptySparkPool (StgSparkPool *pool)
{
return (pool->hd == pool->tl);
}
INLINE_HEADER rtsBool
emptySparkPoolCap (Capability *cap)
{ return emptySparkPool(&cap->r.rSparks); }
INLINE_HEADER nat
sparkPoolSize (StgSparkPool *pool)
{
if (pool->hd <= pool->tl) {
return (pool->tl - pool->hd);
} else {
return (pool->lim - pool->hd + pool->tl - pool->base);
}
}
INLINE_HEADER nat
sparkPoolSizeCap (Capability *cap)
{ return sparkPoolSize(&cap->r.rSparks); }
INLINE_HEADER void
discardSparks (StgSparkPool *pool)
{
pool->hd = pool->tl;
}
INLINE_HEADER void
discardSparksCap (Capability *cap)
{ return discardSparks(&cap->r.rSparks); }
#elif defined(THREADED_RTS)
INLINE_HEADER rtsBool
emptySparkPoolCap (Capability *cap STG_UNUSED)
{ return rtsTrue; }
#endif
#endif /* SPARKS_H */
|