language: D (dmd) (dmd-2.042)
date: 987 days 21 hours ago
link:
visibility: public
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
 
private shared int __refCount;
private shared Mutex __mutex;
 
shared static this()
{
    __mutex = new shared(Mutex);
}
 
static this()
{
    version(Windows)
    {
        synchronized (__mutex) {
            if (__refCount++ == 0) {
                WSADATA wd;
 
                // Winsock will still load if an older version is present.
                // The version is just a request.
                int val;
                val = WSAStartup(0x2020, &wd);
                if(val) // Request Winsock 2.2 for IPv6.
                    throw new SocketException("Unable to initialize socket library", val);
            }
        }
    }
}
 
static ~this()
{
    version(Win32)
    {
        synchronized (__mutex) {
            if (--__refCount == 0)
                WSACleanup();
        }
    }
}