Debian Codegraph @

sqlite3_usleep_windows.go

raw
1 // Copyright (C) 2018 G.J.R. Timmer <[email protected]>.
2 //
3 // Use of this source code is governed by an MIT-style
4 // license that can be found in the LICENSE file.
5
6 //go:build cgo
7
8 package sqlite3
9
10 // usleep is a function available on *nix based systems.
11 // This function is not present in Windows.
12 // Windows has a sleep function but this works with seconds
13 // and not with microseconds as usleep.
14 //
15 // This code should improve performance on windows because
16 // without the presence of usleep SQLite waits 1 second.
17 //
18 // Source: https://github.com/php/php-src/blob/PHP-5.0/win32/time.c
19 // License: https://github.com/php/php-src/blob/PHP-5.0/LICENSE
20 // Details: https://stackoverflow.com/questions/5801813/c-usleep-is-obsolete-workarounds-for-windows-mingw?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
21
22 /*
23 #include <windows.h>
24
25 void usleep(__int64 usec)
26 {
27 HANDLE timer;
28 LARGE_INTEGER ft;
29
30 // Convert to 100 nanosecond interval, negative value indicates relative time
31 ft.QuadPart = -(10*usec);
32
33 timer = CreateWaitableTimer(NULL, TRUE, NULL);
34 SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
35 WaitForSingleObject(timer, INFINITE);
36 CloseHandle(timer);
37 }
38 */
39 import "C"
40
41 // EOF