Skip to content

Commit

Permalink
Stub out ::sleep for win32 (#5947)
Browse files Browse the repository at this point in the history
Just calls LibC.Sleep for now, which blocks the whole program.
  • Loading branch information
RX14 committed Apr 15, 2018
1 parent 19360bc commit 68c8051
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib_c/x86_64-windows-msvc/c/synchapi.cr
@@ -0,0 +1,5 @@
require "c/int_safe"

lib LibC
fun Sleep(dwMilliseconds : DWORD)
end
4 changes: 3 additions & 1 deletion src/prelude.cr
Expand Up @@ -18,7 +18,9 @@ require "lib_c"
require "macros"
require "object"
require "comparable"
require "windows_stubs"
{% if flag?(:win32) %}
require "windows_stubs"
{% end %}
require "exception"
require "iterable"
require "iterator"
Expand Down
10 changes: 10 additions & 0 deletions src/windows_stubs.cr
@@ -1,3 +1,5 @@
require "c/synchapi"

struct CallStack
def self.skip(*args)
# do nothing
Expand Down Expand Up @@ -63,3 +65,11 @@ class Process
LibC.exit(status)
end
end

def sleep(seconds : Number)
sleep(seconds.seconds)
end

def sleep(time : Time::Span)
LibC.Sleep(time.total_milliseconds)
end

0 comments on commit 68c8051

Please sign in to comment.