luapower / pthread Goto Github PK
View Code? Open in Web Editor NEWPOSIX threads binding +windows binaries http://luapower.com/pthread
POSIX threads binding +windows binaries http://luapower.com/pthread
Hi Cosmin,
If I understand correctly, commit 55c64d0 dropped 32bit abi. Is that true? Which are the reasons?
Best
Victor Bombi
Hi,
While playing with condition variables, I found that time = os.time() + timeout
is bad for using timeouts less than a second.
I would like to make a PR with this changes:
ffi.cdef[[
typedef int clockid_t;
int clock_gettime(clockid_t clk_id, timespec *tp);
]]
local function prepare_timeout(timeout)
local tsl = ffi.new'timespec'
C.clock_gettime(0,tsl)
local int, frac = math.modf(timeout)
tsl.s = tsl.s + int
tsl.ns = tsl.ns + frac * 1e9
while (tsl.ns >= 1e9) do
tsl.ns = tsl.ns - 1e9;
tsl.s = tsl.s + 1
end
return tsl
end
function cond.wait(cond, mutex, timeout)
if time then
local ts = prepare_timeout(timeout)
return checktimeout(C.pthread_cond_timedwait(cond, mutex, ts))
else
checkz(C.pthread_cond_wait(cond, mutex))
return true
end
end
What do you think?
Victor Bombi
test_pthread_creation() from https://github.com/luapower/thread/blob/master/thread_test.lua crashes on mingw64 (maybe a compile bug or a 64bit pointer bug...)
works on OSX and Linux on x64 which makes me believe it's a mingw issue...
pthread_timedjoin_np
would be the easier choice but I am afraid it will not be available on OSX or am I wrong?
It seems to be so and also fails in mingw
https://www.gnu.org/software/gnulib/manual/html_node/pthread_005ftimedjoin_005fnp.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.