Wolfgang Thallergcc 15.1.0ada185d1 year agoHistory
51 lines · 1.1 KB · D
RawDownload
import core.memory;import core.sys.posix.pthread : pthread_create, pthread_join;import core.sys.posix.sys.types : pthread_t;import core.thread; extern (C) void  rt_moduleTlsCtor();extern (C) void  rt_moduleTlsDtor(); extern(C)void* entry_point1(void*){    // try collecting - GC must ignore this call because this thread    // is not registered in runtime    GC.collect();    return null;} extern(C)void* entry_point2(void*){    // This thread gets registered in druntime, does some work and gets    // unregistered to be cleaned up manually    thread_attachThis();    rt_moduleTlsCtor();     auto x = new int[10];     rt_moduleTlsDtor();    thread_detachThis();    return null;} void main(){    // allocate some garbage    auto x = new int[1000];     {        pthread_t thread;        auto status = pthread_create(&thread, null, &entry_point1, null);        assert(status == 0);        pthread_join(thread, null);    }     {        pthread_t thread;        auto status = pthread_create(&thread, null, &entry_point2, null);        assert(status == 0);        pthread_join(thread, null);    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t