Created
August 17, 2018 15:38
-
-
Save bigbes/6df663473a7a49e5fe67d5e78ec3a7b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fiber = require('fiber') | |
local ch = fiber.channel(0) | |
local function len(tbl) | |
local cnt = 0; for _, _ in pairs(tbl) do cnt = cnt + 1 end; return cnt | |
end | |
fiber.create(function() while true do print('fiber count:', len(fiber.info())); fiber.sleep(1) end end) | |
local function closure() | |
ch:get(10) | |
end | |
for k = 1, 20000 do | |
fiber.create(closure) | |
fiber.sleep(0.001) | |
if k % 1000 == 0 then print('running', k, 'fibers') end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment