d: Merge upstream dmd 47871363d, druntime, c52e28b7, phobos 99e9c1b77.
[official-gcc.git] / libphobos / libdruntime / core / thread / context.d
blobe477269b8492ef3613a0718a45c69bd8a9089953
1 /**
2 * The thread module provides support for thread creation and management.
4 * Copyright: Copyright Sean Kelly 2005 - 2012.
5 * License: Distributed under the
6 * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
7 * (See accompanying file LICENSE)
8 * Authors: Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak
9 * Source: $(DRUNTIMESRC core/thread/context.d)
12 module core.thread.context;
14 struct StackContext
16 void* bstack, tstack;
18 /// Slot for the EH implementation to keep some state for each stack
19 /// (will be necessary for exception chaining, etc.). Opaque as far as
20 /// we are concerned here.
21 void* ehContext;
22 StackContext* within;
23 StackContext* next, prev;
26 struct Callable
28 void opAssign(void function() fn) pure nothrow @nogc @safe
30 () @trusted { m_fn = fn; }();
31 m_type = Call.FN;
33 void opAssign(void delegate() dg) pure nothrow @nogc @safe
35 () @trusted { m_dg = dg; }();
36 m_type = Call.DG;
38 void opCall()
40 switch (m_type)
42 case Call.FN:
43 m_fn();
44 break;
45 case Call.DG:
46 m_dg();
47 break;
48 default:
49 break;
52 private:
53 enum Call
55 NO,
56 FN,
59 Call m_type = Call.NO;
60 union
62 void function() m_fn;
63 void delegate() m_dg;