本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1KB

  1. // Copyright (C) 2018 G.J.R. Timmer <gjr.timmer@gmail.com>.
  2. //
  3. // Use of this source code is governed by an MIT-style
  4. // license that can be found in the LICENSE file.
  5. // +build cgo
  6. package sqlite3
  7. // usleep is a function available on *nix based systems.
  8. // This function is not present in Windows.
  9. // Windows has a sleep function but this works with seconds
  10. // and not with microseconds as usleep.
  11. //
  12. // This code should improve performance on windows because
  13. // without the presence of usleep SQLite waits 1 second.
  14. //
  15. // Source: 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
  16. /*
  17. #include <windows.h>
  18. void usleep(__int64 usec)
  19. {
  20. HANDLE timer;
  21. LARGE_INTEGER ft;
  22. // Convert to 100 nanosecond interval, negative value indicates relative time
  23. ft.QuadPart = -(10*usec);
  24. timer = CreateWaitableTimer(NULL, TRUE, NULL);
  25. SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
  26. WaitForSingleObject(timer, INFINITE);
  27. CloseHandle(timer);
  28. }
  29. */
  30. import "C"
  31. // EOF
上海开阖软件有限公司 沪ICP备12045867号-1