From ca8d926444c2a099e35131d964bd266dbf1c6b7c Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 20 May 2014 16:41:39 -0400 Subject: [PATCH] use libuv thread functions to ease portability, and hopefully work around #178 --- src/heartbeat.jl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/heartbeat.jl b/src/heartbeat.jl index 306e5c3c..bb30cbfa 100644 --- a/src/heartbeat.jl +++ b/src/heartbeat.jl @@ -8,21 +8,13 @@ function heartbeat_thread(sock::Ptr{Void}) ccall((:zmq_device,ZMQ.zmq), Cint, (Cint, Ptr{Void}, Ptr{Void}), 2, sock, sock) - nothing # not correct on Windows, but irrelevant since we never return + nothing end const heartbeat_c = cfunction(heartbeat_thread, Void, (Ptr{Void},)) -if @windows? false : true - const threadid = Array(Int, 128) # sizeof(pthread_t) is <= 8 on Linux & OSX -end +const threadid = Array(Int, 128) # sizeof(uv_thread_t) <= 8 on Linux, OSX, Win function start_heartbeat(sock) - @windows? begin - ccall(:_beginthread, Int, (Ptr{Void}, Cuint, Ptr{Void}), - heartbeat_c, 0, sock.data) - end : begin - ccall((:pthread_create, :libpthread), Cint, - (Ptr{Int}, Ptr{Void}, Ptr{Void}, Ptr{Void}), - threadid, C_NULL, heartbeat_c, sock.data) - end + ccall(:uv_thread_create, Cint, (Ptr{Int}, Ptr{Void}, Ptr{Void}), + threadid, heartbeat_c, sock.data) end