| 1 |
module core.thread.test; // needs access to getStackTop()/getStackBottom() |
| 2 |
|
| 3 |
import core.stdc.stdio : printf; |
| 4 |
import core.thread; |
| 5 |
|
| 6 |
ubyte[16384] data; |
| 7 |
|
| 8 |
void showThreadInfo() nothrow |
| 9 |
{ |
| 10 |
try |
| 11 |
{ |
| 12 |
auto top = getStackTop(); |
| 13 |
auto bottom = getStackBottom(); |
| 14 |
printf("tlsdata: %p\n", data.ptr); |
| 15 |
printf("stack top: %p\n", getStackTop()); |
| 16 |
printf("stack bottom:%p\n", getStackBottom()); |
| 17 |
printf("used stack: %lld\n", cast(ulong)(bottom - top)); |
| 18 |
} |
| 19 |
catch(Exception e) |
| 20 |
{ |
| 21 |
assert(false, e.msg); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
void main() |
| 26 |
{ |
| 27 |
printf("### main\n"); |
| 28 |
showThreadInfo(); |
| 29 |
|
| 30 |
printf("### thread\n"); |
| 31 |
auto th = new Thread(&showThreadInfo, 16384); |
| 32 |
th.start(); |
| 33 |
th.join(); |
| 34 |
|
| 35 |
printf("### lowlevel thread\n"); |
| 36 |
auto llth = createLowLevelThread(() { showThreadInfo(); }); |
| 37 |
joinLowLevelThread(llth); |
| 38 |
} |