summaryrefslogtreecommitdiff
path: root/test/test_join_detach.lua
blob: dd3ef11dcdb760ae9071ff915f54292ef03f425c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local llthreads = require"llthreads"
local utils     = require "utils"

do

local thread = llthreads.new(utils.thread_init .. [[
  local sleep = require"utils".sleep
  while true do sleep(1) end
]])

-- detached + joindable
thread:start(true, true)

local ok, err = thread:join(0)
print("thread:join(0): ", ok, err)
assert(ok == nil)
assert(err == "timeout")

end

-- enforce collect `thread` object
-- we should not hungup
for i = 1, 10 do collectgarbage("collect") end

print("Done!")