Skip to content
Snippets Groups Projects
Commit 63af98aa authored by dg's avatar dg
Browse files

update lua lanes to 2.0.10

git-svn-id: http://svn.net-core.org/repos/t-engine4@2488 51575b47-30f0-44d4-a5cc-537603b46e54
parent 464e5968
No related branches found
No related tags found
No related merge requests found
......@@ -27,4 +27,7 @@ else
print("LuaVM:", _VERSION)
end
-- Setup correct lua path
package.path = "/?.lua"
math.randomseed(os.time())
......@@ -11,7 +11,7 @@
--[[
===============================================================================
Copyright (C) 2008 Asko Kauppi <akauppi@gmail.com>
Copyright (C) 2008-10 Asko Kauppi <akauppi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -135,7 +135,7 @@ function send( ud, key, ... )
local m= limits[key]
if m and len+n > m then
return false -- would exceed the limit; try again later
return false -- would exceed the limit; try again later
end
for i=1,n do
......
......@@ -6,7 +6,8 @@
-- Author: Asko Kauppi <akauppi@gmail.com>
--
-- History:
-- Jun-08 AKa: major revise
-- 3-Dec-10 BGe: Added support to generate a lane from a string
-- Jun-08 AKa: major revise
-- 15-May-07 AKa: pthread_join():less version, some speedup & ability to
-- handle more threads (~ 8000-9000, up from ~ 5000)
-- 26-Feb-07 AKa: serialization working (C side)
......@@ -15,7 +16,7 @@
--[[
===============================================================================
Copyright (C) 2007-08 Asko Kauppi <akauppi@gmail.com>
Copyright (C) 2007-10 Asko Kauppi <akauppi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -89,7 +90,7 @@ ABOUT=
author= "Asko Kauppi <akauppi@gmail.com>",
description= "Running multiple Lua states in parallel",
license= "MIT/X11",
copyright= "Copyright (c) 2007-08, Asko Kauppi",
copyright= "Copyright (c) 2007-10, Asko Kauppi",
version= _version,
}
......@@ -123,6 +124,14 @@ end
--
-- lane_h.state: "pending"/"running"/"waiting"/"done"/"error"/"cancelled"
--
-- Note: Would be great to be able to have '__ipairs' metamethod, that gets
-- called by 'ipairs()' function to custom iterate objects. We'd use it
-- for making sure a lane has ended (results are available); not requiring
-- the user to precede a loop by explicit 'h[0]' or 'h:join()'.
--
-- Or, even better, 'ipairs()' should start valuing '__index' instead
-- of using raw reads that bypass it.
--
local lane_mt= {
__index= function( me, k )
if type(k) == "number" then
......@@ -260,8 +269,9 @@ function gen( ... )
end
local func= select(n,...)
if type(func)~="function" then
error( "Last parameter not function: "..tostring(func) )
local functype = type(func)
if functype ~= "function" and functype ~= "string" then
error( "Last parameter not function or string: "..tostring(func))
end
-- Check 'libs' already here, so the error goes in the right place
......@@ -302,9 +312,10 @@ lane_proxy= function( ud )
local proxy= {
_ud= ud,
-- void= me:cancel()
-- true|false= me:cancel()
--
cancel= function(me) thread_cancel(me._ud) end,
cancel= function(me, time, force) return thread_cancel(me._ud, time, force) end,
-- [...] | [nil,err,stack_tbl]= me:join( [wait_secs=-1] )
--
......@@ -486,7 +497,7 @@ if first_time then
return next_wakeup -- may be 'nil'
end
--[[
-----
-- Snore loop (run as a lane on the background)
--
......@@ -495,14 +506,18 @@ if first_time then
-- We let the timer lane be a "free running" thread; no handle to it
-- remains.
--
gen( "io", { priority=max_prio }, function()
gen( "io", { priority=max_prio, globals={threadName="LanesTimer"} }, function()
while true do
local next_wakeup= check_timers()
-- Sleep until next timer to wake up, or a set/clear command
--
local secs= next_wakeup and (next_wakeup - now_secs()) or nil
local secs
if next_wakeup then
secs = next_wakeup - now_secs()
if secs < 0 then secs = 0 end
end
local linda= timer_gateway:receive( secs, TGW_KEY )
if linda then
......@@ -515,6 +530,7 @@ if first_time then
end
end
end )()
]]
end
-----
......
/* bin2c.lua generated code -- DO NOT EDIT
*
* To use from C source:
* char my_chunk[]=
* #include "my.lch"
*/
{
27, 76,117, 97, 81, 0, 1, 4, 4, 4, 8, 0, 12, 0, 0, 0, 64,107,101,101,
112,101,114, 46,108,117, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9,
45, 0, 0, 0, 5, 0, 0, 0, 69, 64, 0, 0, 28, 64, 0, 1, 5, 0, 0, 0,
69,128, 0, 0, 70,192,192, 0, 28,128, 0, 1, 69, 0, 0, 0,133,128, 0, 0,
134, 0, 65, 1, 92,128, 0, 1,164, 0, 0, 0, 0, 0,128, 0,202, 0, 0, 0,
10, 1, 0, 0, 74, 1, 0, 0,164, 65, 0, 0, 0, 0,128, 1, 0, 0, 0, 2,
0, 0,128, 2,228,129, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 36,194, 0, 0,
0, 0, 0, 3, 7, 66, 1, 0, 36, 2, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0,
7,130, 1, 0, 36, 66, 1, 0, 0, 0, 0, 3, 7,194, 1, 0, 36,130, 1, 0,
0, 0, 0, 3, 7, 2, 2, 0, 36,194, 1, 0, 0, 0, 0, 3, 7, 66, 2, 0,
36, 2, 2, 0, 0, 0,128, 1, 0, 0, 0, 2, 0, 0,128, 2, 7,130, 2, 0,
30, 0,128, 0, 11, 0, 0, 0, 4, 7, 0, 0, 0, 97,115,115,101,114,116, 0,
4, 13, 0, 0, 0,110,105,108, 95,115,101,110,116,105,110,101,108, 0, 4, 6,
0, 0, 0,116, 97, 98,108,101, 0, 4, 7, 0, 0, 0,114,101,109,111,118,101,
0, 4, 7, 0, 0, 0, 99,111,110, 99, 97,116, 0, 4, 5, 0, 0, 0,115,101,
110,100, 0, 4, 8, 0, 0, 0,114,101, 99,101,105,118,101, 0, 4, 6, 0, 0,
0,108,105,109,105,116, 0, 4, 4, 0, 0, 0,115,101,116, 0, 4, 4, 0, 0,
0,103,101,116, 0, 4, 6, 0, 0, 0, 99,108,101, 97,114, 0, 9, 0, 0, 0,
0, 0, 0, 0, 46, 0, 0, 0, 50, 0, 0, 0, 1, 0, 3, 6, 16, 0, 0, 0,
69, 0, 0, 0, 90, 0, 0, 0, 22,192, 2,128, 69, 0, 0, 0, 70, 64,192, 0,
75,128,192, 0,196, 0, 0, 0, 10, 1, 0, 0,101, 1, 0, 0, 34, 65, 0, 0,
65,193, 0, 0,220,128,128, 1, 1, 1, 1, 0,213, 0,129, 1, 92, 64,128, 1,
30, 0,128, 0, 5, 0, 0, 0, 4, 3, 0, 0, 0,105,111, 0, 4, 7, 0, 0,
0,115,116,100,101,114,114, 0, 4, 6, 0, 0, 0,119,114,105,116,101, 0, 4,
2, 0, 0, 0, 9, 0, 4, 2, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0,
0, 47, 0, 0, 0, 47, 0, 0, 0, 47, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0,
0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0,
0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0,
0, 50, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 97,114,103, 0, 0, 0, 0,
0, 15, 0, 0, 0, 1, 0, 0, 0, 13, 0, 0, 0,116, 97, 98,108,101, 95, 99,
111,110, 99, 97,116, 0, 0, 0, 0, 0, 84, 0, 0, 0, 93, 0, 0, 0, 3, 1,
0, 4, 21, 0, 0, 0, 68, 0, 0, 0, 70, 0,128, 0, 90, 64, 0, 0, 22, 0,
2,128, 68, 0, 0, 0,138, 0, 0, 0, 73,128, 0, 0, 68, 0,128, 0,138, 0,
0, 0, 73,128, 0, 0, 68, 0, 0, 1,138, 0, 0, 0, 73,128, 0, 0, 68, 0,
0, 0, 70, 0,128, 0,132, 0,128, 0,134, 0, 0, 1,196, 0, 0, 1,198, 0,
128, 1, 94, 0, 0, 2, 30, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0,
0, 0, 87, 0, 0, 0, 87, 0, 0, 0, 87, 0, 0, 0, 87, 0, 0, 0, 88, 0,
0, 0, 88, 0, 0, 0, 88, 0, 0, 0, 89, 0, 0, 0, 89, 0, 0, 0, 89, 0,
0, 0, 90, 0, 0, 0, 90, 0, 0, 0, 90, 0, 0, 0, 92, 0, 0, 0, 92, 0,
0, 0, 92, 0, 0, 0, 92, 0, 0, 0, 92, 0, 0, 0, 92, 0, 0, 0, 92, 0,
0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0, 0, 0,
0, 20, 0, 0, 0, 3, 0, 0, 0, 6, 0, 0, 0, 95,100, 97,116, 97, 0, 10,
0, 0, 0, 95,105,110, 99,111,109,105,110,103, 0, 8, 0, 0, 0, 95,108,105,
109,105,116,115, 0, 0, 0, 0, 0, 96, 0, 0, 0,106, 0, 0, 0, 2, 3, 0,
16, 40, 0, 0, 0,197, 0, 0, 0, 27, 1, 0, 0, 22,128, 0,128, 27, 1,128,
0, 22, 0, 0,128, 0, 1, 0, 1,220, 64, 0, 1,196, 0, 0, 0, 0, 1,128,
0,220, 0, 1, 1,133, 65, 0, 0,198,129,128, 1,156,129, 0, 1,197,129, 0,
0, 6,130, 0, 2, 26, 66, 0, 0, 22, 0, 0,128, 10, 2, 0, 0,220, 1, 1,
1, 22, 64, 1,128, 0, 3, 0, 3, 65,195, 0, 0,133, 67, 0, 0,192, 3,128,
5,156,131, 0, 1,149,129, 3, 6,225,129, 0, 0, 22,192,253,127,196, 1,128,
0, 1, 2, 1, 0, 64, 2, 0, 0,129, 66, 1, 0,197, 66, 0, 0, 0, 3, 0,
1,220,130, 0, 1, 1,131, 1, 0, 21, 2, 3, 4, 64, 2, 0, 3,220, 65,128,
1, 30, 0,128, 0, 7, 0, 0, 0, 4, 7, 0, 0, 0, 97,115,115,101,114,116,
0, 4, 9, 0, 0, 0,116,111,115,116,114,105,110,103, 0, 4, 7, 0, 0, 0,
105,112, 97,105,114,115, 0, 4, 3, 0, 0, 0, 44, 32, 0, 4, 5, 0, 0, 0,
42, 42, 42, 32, 0, 4, 3, 0, 0, 0, 32, 40, 0, 4, 4, 0, 0, 0, 41, 58,
32, 0, 0, 0, 0, 0, 40, 0, 0, 0, 97, 0, 0, 0, 97, 0, 0, 0, 97, 0,
0, 0, 97, 0, 0, 0, 97, 0, 0, 0, 97, 0, 0, 0, 97, 0, 0, 0, 99, 0,
0, 0, 99, 0, 0, 0, 99, 0, 0, 0,101, 0, 0, 0,101, 0, 0, 0,101, 0,
0, 0,102, 0, 0, 0,102, 0, 0, 0,102, 0, 0, 0,102, 0, 0, 0,102, 0,
0, 0,102, 0, 0, 0,102, 0, 0, 0,103, 0, 0, 0,103, 0, 0, 0,103, 0,
0, 0,103, 0, 0, 0,103, 0, 0, 0,103, 0, 0, 0,102, 0, 0, 0,103, 0,
0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0,
0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0, 0, 0,105, 0,
0, 0,105, 0, 0, 0,106, 0, 0, 0, 12, 0, 0, 0, 6, 0, 0, 0,116,105,
116,108,101, 0, 0, 0, 0, 0, 39, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0,
0, 0, 0, 39, 0, 0, 0, 4, 0, 0, 0,107,101,121, 0, 0, 0, 0, 0, 39,
0, 0, 0, 5, 0, 0, 0,100, 97,116, 97, 0, 10, 0, 0, 0, 39, 0, 0, 0,
9, 0, 0, 0,105,110, 99,111,109,105,110,103, 0, 10, 0, 0, 0, 39, 0, 0,
0, 2, 0, 0, 0, 95, 0, 10, 0, 0, 0, 39, 0, 0, 0, 2, 0, 0, 0,115,
0, 13, 0, 0, 0, 39, 0, 0, 0, 16, 0, 0, 0, 40,102,111,114, 32,103,101,
110,101,114, 97,116,111,114, 41, 0, 19, 0, 0, 0, 28, 0, 0, 0, 12, 0, 0,
0, 40,102,111,114, 32,115,116, 97,116,101, 41, 0, 19, 0, 0, 0, 28, 0, 0,
0, 14, 0, 0, 0, 40,102,111,114, 32, 99,111,110,116,114,111,108, 41, 0, 19,
0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 95, 0, 20, 0, 0, 0, 26, 0, 0,
0, 2, 0, 0, 0,118, 0, 20, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 7,
0, 0, 0,116, 97, 98,108,101,115, 0, 3, 0, 0, 0, 87, 82, 0, 0, 0, 0,
0,121, 0, 0, 0,158, 0, 0, 0, 1, 2, 3, 16, 56, 0, 0, 0,196, 0, 0,
0, 0, 1, 0, 0,220, 0, 1, 1,133, 1, 0, 0,193, 65, 0, 0, 37, 2, 0,
0,156,129, 0, 0, 23,128, 64, 3, 22, 64, 0,128,194, 1,128, 0,222, 1, 0,
1,198, 65, 0, 2, 23,192,192, 3, 22, 64, 0,128,202, 1, 0, 0, 9,193,129,
0,198, 65,128, 1,218, 1, 0, 0, 22, 0, 1,128,198, 65, 0, 2,212, 1,128,
3,204,193, 1,130,218, 65, 0, 0, 22, 0, 0,128,193,129, 0, 0, 6, 66,128,
2, 26, 2, 0, 0, 22, 0, 1,128, 76,130,129, 3, 24, 64, 2, 4, 22, 64, 0,
128, 66, 2, 0, 0, 94, 2, 0, 1, 65, 2, 1, 0,128, 2, 0, 3,193, 2, 1,
0, 96,130, 3,128, 69, 3, 0, 0,128, 3, 0, 6,229, 3, 0, 0, 92,131, 0,
0, 23,192,192, 6, 22, 0, 0,128, 69, 67, 1, 0, 23,128,192, 3, 22,128, 0,
128,201, 64,131, 0,193, 1, 1, 0, 22,128, 0,128,134, 67, 0, 2,137, 67,131,
3,204, 1,193, 3, 95,194,251,127, 66, 2,128, 0, 94, 2, 0, 1, 30, 0,128,
0, 6, 0, 0, 0, 4, 7, 0, 0, 0,115,101,108,101, 99,116, 0, 4, 2, 0,
0, 0, 35, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0,240, 63, 4, 13, 0, 0, 0,110,105,108, 95,115,101,110,116,105,110,101,108,
0, 0, 0, 0, 0, 56, 0, 0, 0,123, 0, 0, 0,123, 0, 0, 0,123, 0, 0,
0,125, 0, 0, 0,125, 0, 0, 0,125, 0, 0, 0,125, 0, 0, 0,126, 0, 0,
0,126, 0, 0, 0,126, 0, 0, 0,126, 0, 0, 0,130, 0, 0, 0,130, 0, 0,
0,130, 0, 0, 0,131, 0, 0, 0,131, 0, 0, 0,134, 0, 0, 0,134, 0, 0,
0,134, 0, 0, 0,134, 0, 0, 0,134, 0, 0, 0,134, 0, 0, 0,134, 0, 0,
0,134, 0, 0, 0,134, 0, 0, 0,135, 0, 0, 0,137, 0, 0, 0,137, 0, 0,
0,137, 0, 0, 0,137, 0, 0, 0,137, 0, 0, 0,138, 0, 0, 0,138, 0, 0,
0,141, 0, 0, 0,141, 0, 0, 0,141, 0, 0, 0,141, 0, 0, 0,142, 0, 0,
0,142, 0, 0, 0,142, 0, 0, 0,142, 0, 0, 0,145, 0, 0, 0,145, 0, 0,
0,146, 0, 0, 0,149, 0, 0, 0,149, 0, 0, 0,150, 0, 0, 0,151, 0, 0,
0,151, 0, 0, 0,153, 0, 0, 0,153, 0, 0, 0,154, 0, 0, 0,141, 0, 0,
0,157, 0, 0, 0,157, 0, 0, 0,158, 0, 0, 0, 14, 0, 0, 0, 3, 0, 0,
0,117,100, 0, 0, 0, 0, 0, 55, 0, 0, 0, 4, 0, 0, 0,107,101,121, 0,
0, 0, 0, 0, 55, 0, 0, 0, 4, 0, 0, 0, 97,114,103, 0, 0, 0, 0, 0,
55, 0, 0, 0, 5, 0, 0, 0,100, 97,116, 97, 0, 3, 0, 0, 0, 55, 0, 0,
0, 9, 0, 0, 0,105,110, 99,111,109,105,110,103, 0, 3, 0, 0, 0, 55, 0,
0, 0, 7, 0, 0, 0,108,105,109,105,116,115, 0, 3, 0, 0, 0, 55, 0, 0,
0, 2, 0, 0, 0,110, 0, 7, 0, 0, 0, 55, 0, 0, 0, 4, 0, 0, 0,108,
101,110, 0, 25, 0, 0, 0, 55, 0, 0, 0, 2, 0, 0, 0,109, 0, 26, 0, 0,
0, 55, 0, 0, 0, 12, 0, 0, 0, 40,102,111,114, 32,105,110,100,101,120, 41,
0, 36, 0, 0, 0, 53, 0, 0, 0, 12, 0, 0, 0, 40,102,111,114, 32,108,105,
109,105,116, 41, 0, 36, 0, 0, 0, 53, 0, 0, 0, 11, 0, 0, 0, 40,102,111,
114, 32,115,116,101,112, 41, 0, 36, 0, 0, 0, 53, 0, 0, 0, 2, 0, 0, 0,
105, 0, 37, 0, 0, 0, 52, 0, 0, 0, 4, 0, 0, 0,118, 97,108, 0, 41, 0,
0, 0, 52, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0,116, 97, 98,108,101,115,
0, 0, 0, 0, 0,167, 0, 0, 0,189, 0, 0, 0, 2, 1, 3, 14, 40, 0, 0,
0,132, 0, 0, 0,192, 0, 0, 0,156, 0, 1, 1, 65, 1, 0, 0,133, 65, 0,
0,193,129, 0, 0, 37, 2, 0, 0,156,129, 0, 0,193, 1, 0, 0, 96,193, 6,
128, 69, 66, 0, 0,128, 2, 0, 4,229, 2, 0, 0, 92,130, 0, 0,134, 66, 2,
1, 87,192, 64, 5, 22, 0, 5,128,198, 66,130, 1,218, 2, 0, 0, 22, 64, 2,
128,198, 66,130, 1,198, 2,192, 5, 87,192,192, 5, 22, 64, 1,128,196, 2,128,
0, 6, 67,130, 1, 65, 3, 0, 0,220,130,128, 1,137,192,130, 4, 22, 0, 0,
128,137,192,192, 4,197, 2, 1, 0, 23,192, 2, 5, 22, 0, 0,128,131, 2, 0,
5,192, 2, 0, 5, 0, 3,128, 4,222, 2,128, 1, 95,129,248,127, 30, 0,128,
0, 5, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0,240, 63, 4, 7, 0, 0, 0,115,
101,108,101, 99,116, 0, 4, 2, 0, 0, 0, 35, 0, 0, 4, 13, 0, 0, 0,110,
105,108, 95,115,101,110,116,105,110,101,108, 0, 0, 0, 0, 0, 40, 0, 0, 0,
169, 0, 0, 0,169, 0, 0, 0,169, 0, 0, 0,171, 0, 0, 0,171, 0, 0, 0,
171, 0, 0, 0,171, 0, 0, 0,171, 0, 0, 0,171, 0, 0, 0,171, 0, 0, 0,
172, 0, 0, 0,172, 0, 0, 0,172, 0, 0, 0,172, 0, 0, 0,173, 0, 0, 0,
175, 0, 0, 0,175, 0, 0, 0,176, 0, 0, 0,176, 0, 0, 0,176, 0, 0, 0,
176, 0, 0, 0,176, 0, 0, 0,176, 0, 0, 0,176, 0, 0, 0,178, 0, 0, 0,
178, 0, 0, 0,178, 0, 0, 0,178, 0, 0, 0,178, 0, 0, 0,178, 0, 0, 0,
180, 0, 0, 0,182, 0, 0, 0,182, 0, 0, 0,182, 0, 0, 0,183, 0, 0, 0,
185, 0, 0, 0,185, 0, 0, 0,185, 0, 0, 0,171, 0, 0, 0,189, 0, 0, 0,
11, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0, 0, 0, 0, 39, 0, 0, 0, 4,
0, 0, 0, 97,114,103, 0, 0, 0, 0, 0, 39, 0, 0, 0, 5, 0, 0, 0,100,
97,116, 97, 0, 3, 0, 0, 0, 39, 0, 0, 0, 9, 0, 0, 0,105,110, 99,111,
109,105,110,103, 0, 3, 0, 0, 0, 39, 0, 0, 0, 2, 0, 0, 0, 95, 0, 3,
0, 0, 0, 39, 0, 0, 0, 12, 0, 0, 0, 40,102,111,114, 32,105,110,100,101,
120, 41, 0, 9, 0, 0, 0, 39, 0, 0, 0, 12, 0, 0, 0, 40,102,111,114, 32,
108,105,109,105,116, 41, 0, 9, 0, 0, 0, 39, 0, 0, 0, 11, 0, 0, 0, 40,
102,111,114, 32,115,116,101,112, 41, 0, 9, 0, 0, 0, 39, 0, 0, 0, 2, 0,
0, 0,105, 0, 10, 0, 0, 0, 38, 0, 0, 0, 4, 0, 0, 0,107,101,121, 0,
14, 0, 0, 0, 38, 0, 0, 0, 4, 0, 0, 0,118, 97,108, 0, 15, 0, 0, 0,
38, 0, 0, 0, 2, 0, 0, 0, 7, 0, 0, 0,116, 97, 98,108,101,115, 0, 13,
0, 0, 0,116, 97, 98,108,101, 95,114,101,109,111,118,101, 0, 0, 0, 0, 0,
195, 0, 0, 0,200, 0, 0, 0, 1, 3, 0, 6, 5, 0, 0, 0,196, 0, 0, 0,
0, 1, 0, 0,220, 0, 1, 1, 73,129,128, 0, 30, 0,128, 0, 0, 0, 0, 0,
0, 0, 0, 0, 5, 0, 0, 0,197, 0, 0, 0,197, 0, 0, 0,197, 0, 0, 0,
199, 0, 0, 0,200, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0,
0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0,107,101,121, 0, 0, 0, 0, 0, 4,
0, 0, 0, 2, 0, 0, 0,110, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0,
0, 95, 0, 3, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 95, 0, 3, 0, 0,
0, 4, 0, 0, 0, 7, 0, 0, 0,108,105,109,105,116,115, 0, 3, 0, 0, 0,
4, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0,116, 97, 98,108,101,115, 0, 0,
0, 0, 0,206, 0, 0, 0,214, 0, 0, 0, 1, 3, 0, 6, 6, 0, 0, 0,196,
0, 0, 0, 0, 1, 0, 0,220, 0, 1, 1,201,128,128, 0, 9, 1,192, 0, 30,
0,128, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0,208, 0, 0, 0,
208, 0, 0, 0,208, 0, 0, 0,212, 0, 0, 0,213, 0, 0, 0,214, 0, 0, 0,
6, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0, 0, 0, 0, 5, 0, 0, 0, 4,
0, 0, 0,107,101,121, 0, 0, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0,118,
97,108, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0,100, 97,116, 97, 0,
3, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0,105,110, 99,111,109,105,110,103,
0, 3, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 95, 0, 3, 0, 0, 0, 5,
0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0,116, 97, 98,108,101,115, 0, 0, 0,
0, 0,220, 0, 0, 0,229, 0, 0, 0, 1, 2, 0, 7, 10, 0, 0, 0,132, 0,
0, 0,192, 0, 0, 0,156, 0, 1, 1, 70, 65, 0, 1,133, 1, 0, 0, 23,128,
129, 2, 22, 0, 0,128, 67, 1,128, 2, 94, 1, 0, 1, 30, 0,128, 0, 1, 0,
0, 0, 4, 13, 0, 0, 0,110,105,108, 95,115,101,110,116,105,110,101,108, 0,
0, 0, 0, 0, 10, 0, 0, 0,222, 0, 0, 0,222, 0, 0, 0,222, 0, 0, 0,
224, 0, 0, 0,225, 0, 0, 0,225, 0, 0, 0,225, 0, 0, 0,226, 0, 0, 0,
228, 0, 0, 0,229, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0,
0, 0, 0, 9, 0, 0, 0, 4, 0, 0, 0,107,101,121, 0, 0, 0, 0, 0, 9,
0, 0, 0, 5, 0, 0, 0,100, 97,116, 97, 0, 3, 0, 0, 0, 9, 0, 0, 0,
2, 0, 0, 0, 95, 0, 3, 0, 0, 0, 9, 0, 0, 0, 2, 0, 0, 0, 95, 0,
3, 0, 0, 0, 9, 0, 0, 0, 4, 0, 0, 0,118, 97,108, 0, 4, 0, 0, 0,
9, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0,116, 97, 98,108,101,115, 0, 0,
0, 0, 0,237, 0, 0, 0,242, 0, 0, 0, 3, 1, 0, 2, 7, 0, 0, 0, 68,
0, 0, 0, 73, 0, 64, 0, 68, 0,128, 0, 73, 0, 64, 0, 68, 0, 0, 1, 73,
0, 64, 0, 30, 0,128, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
239, 0, 0, 0,239, 0, 0, 0,240, 0, 0, 0,240, 0, 0, 0,241, 0, 0, 0,
241, 0, 0, 0,242, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0,117,100, 0, 0,
0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 6, 0, 0, 0, 95,100, 97,116, 97,
0, 10, 0, 0, 0, 95,105,110, 99,111,109,105,110,103, 0, 8, 0, 0, 0, 95,
108,105,109,105,116,115, 0, 45, 0, 0, 0, 39, 0, 0, 0, 39, 0, 0, 0, 39,
0, 0, 0, 43, 0, 0, 0, 43, 0, 0, 0, 43, 0, 0, 0, 43, 0, 0, 0, 44,
0, 0, 0, 44, 0, 0, 0, 44, 0, 0, 0, 44, 0, 0, 0, 50, 0, 0, 0, 50,
0, 0, 0, 59, 0, 0, 0, 68, 0, 0, 0, 77, 0, 0, 0, 93, 0, 0, 0, 93,
0, 0, 0, 93, 0, 0, 0, 93, 0, 0, 0,106, 0, 0, 0,106, 0, 0, 0,106,
0, 0, 0,158, 0, 0, 0,158, 0, 0, 0,121, 0, 0, 0,189, 0, 0, 0,189,
0, 0, 0,189, 0, 0, 0,167, 0, 0, 0,200, 0, 0, 0,200, 0, 0, 0,195,
0, 0, 0,214, 0, 0, 0,214, 0, 0, 0,206, 0, 0, 0,229, 0, 0, 0,229,
0, 0, 0,220, 0, 0, 0,242, 0, 0, 0,242, 0, 0, 0,242, 0, 0, 0,242,
0, 0, 0,237, 0, 0, 0,242, 0, 0, 0, 8, 0, 0, 0, 13, 0, 0, 0,116,
97, 98,108,101, 95,114,101,109,111,118,101, 0, 7, 0, 0, 0, 44, 0, 0, 0,
13, 0, 0, 0,116, 97, 98,108,101, 95, 99,111,110, 99, 97,116, 0, 11, 0, 0,
0, 44, 0, 0, 0, 3, 0, 0, 0, 87, 82, 0, 13, 0, 0, 0, 44, 0, 0, 0,
6, 0, 0, 0, 95,100, 97,116, 97, 0, 14, 0, 0, 0, 44, 0, 0, 0, 10, 0,
0, 0, 95,105,110, 99,111,109,105,110,103, 0, 15, 0, 0, 0, 44, 0, 0, 0,
8, 0, 0, 0, 95,108,105,109,105,116,115, 0, 16, 0, 0, 0, 44, 0, 0, 0,
7, 0, 0, 0,116, 97, 98,108,101,115, 0, 20, 0, 0, 0, 44, 0, 0, 0, 6,
0, 0, 0, 68, 69, 66, 85, 71, 0, 23, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0,
0,};
This diff is collapsed.
/*
* THREADING.C Copyright (c) 2007-08, Asko Kauppi
* THREADING.C Copyright (c) 2007-10, Asko Kauppi
*
* Lua Lanes OS threading specific code.
*
......@@ -10,7 +10,7 @@
/*
===============================================================================
Copyright (C) 2007-08 Asko Kauppi <akauppi@gmail.com>
Copyright (C) 2007-10 Asko Kauppi <akauppi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -178,6 +178,11 @@ static void prepare_timeout( struct timespec *ts, time_d abs_secs ) {
ts->tv_sec= floor( abs_secs );
ts->tv_nsec= ((long)((abs_secs - ts->tv_sec) * 1000.0 +0.5)) * 1000000UL; // 1ms = 1000000ns
if (ts->tv_nsec == 1000000000UL)
{
ts->tv_nsec = 0;
ts->tv_sec = ts->tv_sec + 1;
}
}
#endif
......
......@@ -37,7 +37,7 @@ typedef unsigned int uint_t;
/* Do this BEFORE including time.h so that it is declaring _mktime32()
* as it would have declared mktime().
*/
//# define mktime _mktime32
# define mktime _mktime32
#endif
#include <time.h>
......
/*
* TOOLS.C Copyright (c) 2002-08, Asko Kauppi
* TOOLS.C Copyright (c) 2002-10, Asko Kauppi
*
* Lua tools to support Lanes.
*/
......@@ -7,7 +7,7 @@
/*
===============================================================================
Copyright (C) 2002-08 Asko Kauppi <akauppi@gmail.com>
Copyright (C) 2002-10 Asko Kauppi <akauppi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -40,8 +40,6 @@ THE SOFTWARE.
#include <ctype.h>
#include <stdlib.h>
static volatile lua_CFunction hijacked_tostring; // = NULL
MUTEX_T deep_lock;
MUTEX_T mtid_lock;
......@@ -616,7 +614,7 @@ uint_t get_mt_id( lua_State *L, int i ) {
// [-2]: reg[REG_MTID]
// [-1]: nil/uint
id= lua_tointeger(L,-1); // 0 for nil
id= (uint_t)lua_tointeger(L,-1); // 0 for nil
lua_pop(L,1);
STACK_MID(L,1)
......@@ -660,73 +658,60 @@ static int buf_writer( lua_State *L, const void* b, size_t n, void* B ) {
* Returns TRUE if the table was cached (no need to fill it!); FALSE if
* it's a virgin.
*/
static
bool_t push_cached_table( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t i ) {
bool_t ret;
ASSERT_L( hijacked_tostring );
ASSERT_L( L2_cache_i != 0 );
STACK_GROW(L,2);
STACK_GROW(L2,3);
// Create an identity string for table at [i]; it should stay unique at
// least during copying of the data (then we can clear the caches).
//
STACK_CHECK(L)
lua_pushcfunction( L, hijacked_tostring );
lua_pushvalue( L, i );
lua_call( L, 1 /*args*/, 1 /*retvals*/ );
//
// [-1]: "table: 0x...."
STACK_END(L,1)
ASSERT_L( lua_type(L,-1) == LUA_TSTRING );
static bool_t push_cached_table( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t i )
{
bool_t ret;
// L2_cache[id_str]= [{...}]
//
STACK_CHECK(L2)
ASSERT_L( L2_cache_i != 0 );
// We don't need to use the from state ('L') in ID since the life span
// is only for the duration of a copy (both states are locked).
//
lua_pushstring( L2, lua_tostring(L,-1) );
lua_pop(L,1); // remove the 'tostring(tbl)' value (in L!)
STACK_GROW(L2,3);
//fprintf( stderr, "<< ID: %s >>\n", lua_tostring(L2,-1) );
// L2_cache[id_str]= [{...}]
//
STACK_CHECK(L2)
lua_pushvalue( L2, -1 );
lua_rawget( L2, L2_cache_i );
//
// [-2]: identity string ("table: 0x...")
// [-1]: table|nil
if (lua_isnil(L2,-1)) {
lua_pop(L2,1);
lua_newtable(L2);
lua_pushvalue(L2,-1);
lua_insert(L2,-3);
//
// [-3]: new table (2nd ref)
// [-2]: identity string
// [-1]: new table
// We don't need to use the from state ('L') in ID since the life span
// is only for the duration of a copy (both states are locked).
//
lua_pushlightuserdata( L2, (void*)lua_topointer( L, i )); // push a light userdata uniquely representing the table
lua_rawset(L2, L2_cache_i);
//
// [-1]: new table (tied to 'L2_cache' table')
//fprintf( stderr, "<< ID: %s >>\n", lua_tostring(L2,-1) );
ret= FALSE; // brand new
lua_pushvalue( L2, -1 );
lua_rawget( L2, L2_cache_i );
//
// [-2]: identity table pointer lightuserdata
// [-1]: table|nil
} else {
lua_remove(L2,-2);
ret= TRUE; // from cache
}
STACK_END(L2,1)
//
// L2 [-1]: table to use as destination
if (lua_isnil(L2,-1))
{
lua_pop(L2,1);
lua_newtable(L2);
lua_pushvalue(L2,-1);
lua_insert(L2,-3);
//
// [-3]: new table (2nd ref)
// [-2]: identity table pointer lightuserdata
// [-1]: new table
ASSERT_L( lua_istable(L2,-1) );
return ret;
lua_rawset(L2, L2_cache_i);
//
// [-1]: new table (tied to 'L2_cache' table')
ret= FALSE; // brand new
}
else
{
lua_remove(L2,-2);
ret= TRUE; // from cache
}
STACK_END(L2,1)
//
// L2 [-1]: table to use as destination
ASSERT_L( lua_istable(L2,-1) );
return ret;
}
......@@ -738,82 +723,76 @@ bool_t push_cached_table( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t
*/
static void inter_copy_func( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t i );
static
void push_cached_func( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t i ) {
// TBD: Merge this and same code for tables
ASSERT_L( hijacked_tostring );
ASSERT_L( L2_cache_i != 0 );
STACK_GROW(L,2);
STACK_GROW(L2,3);
STACK_CHECK(L)
lua_pushcfunction( L, hijacked_tostring );
lua_pushvalue( L, i );
lua_call( L, 1 /*args*/, 1 /*retvals*/ );
//
// [-1]: "function: 0x...."
STACK_END(L,1)
ASSERT_L( lua_type(L,-1) == LUA_TSTRING );
static void push_cached_func( lua_State *L2, uint_t L2_cache_i, lua_State *L, uint_t i )
{
// TBD: Merge this and same code for tables
// L2_cache[id_str]= function
//
STACK_CHECK(L2)
ASSERT_L( L2_cache_i != 0 );
// We don't need to use the from state ('L') in ID since the life span
// is only for the duration of a copy (both states are locked).
//
lua_pushstring( L2, lua_tostring(L,-1) );
lua_pop(L,1); // remove the 'tostring(tbl)' value (in L!)
STACK_GROW(L2,3);
//fprintf( stderr, "<< ID: %s >>\n", lua_tostring(L2,-1) );
// L2_cache[id_str]= function
//
STACK_CHECK(L2)
lua_pushvalue( L2, -1 );
lua_rawget( L2, L2_cache_i );
//
// [-2]: identity string ("function: 0x...")
// [-1]: function|nil|true (true means: we're working on it; recursive)
// We don't need to use the from state ('L') in ID since the life span
// is only for the duration of a copy (both states are locked).
//
lua_pushlightuserdata( L2, (void*)lua_topointer( L, i )); // push a light userdata uniquely representing the function
if (lua_isnil(L2,-1)) {
lua_pop(L2,1);
//fprintf( stderr, "<< ID: %s >>\n", lua_tostring(L2,-1) );
// Set to 'true' for the duration of creation; need to find self-references
// via upvalues
//
lua_pushboolean(L2,TRUE);
lua_setfield( L2, L2_cache_i, lua_tostring(L2,-2) );
lua_pushvalue( L2, -1 );
lua_rawget( L2, L2_cache_i );
//
// [-2]: identity lightuserdata function pointer
// [-1]: function|nil|true (true means: we're working on it; recursive)
inter_copy_func( L2, L2_cache_i, L, i ); // pushes a copy of the func
if (lua_isnil(L2,-1))
{
lua_pop(L2,1);
lua_pushvalue(L2,-1);
lua_insert(L2,-3);
//
// [-3]: function (2nd ref)
// [-2]: identity string
// [-1]: function
// Set to 'true' for the duration of creation; need to find self-references
// via upvalues
//
lua_pushvalue( L2, -1);
lua_pushboolean(L2,TRUE);
lua_rawset( L2, L2_cache_i);
lua_rawset(L2,L2_cache_i);
//
// [-1]: function (tied to 'L2_cache' table')
inter_copy_func( L2, L2_cache_i, L, i ); // pushes a copy of the func
} else if (lua_isboolean(L2,-1)) {
// Loop in preparing upvalues; either direct or via a table
//
// Note: This excludes the case where a function directly addresses
// itself as an upvalue (recursive lane creation).
//
luaL_error( L, "Recursive use of upvalues; cannot copy the function" );
lua_pushvalue(L2,-1);
lua_insert(L2,-3);
//
// [-3]: function (2nd ref)
// [-2]: identity lightuserdata function pointer
// [-1]: function
} else {
lua_remove(L2,-2);
}
STACK_END(L2,1)
//
// L2 [-1]: function
lua_rawset(L2,L2_cache_i);
//
// [-1]: function (tied to 'L2_cache' table')
ASSERT_L( lua_isfunction(L2,-1) );
}
else if (lua_isboolean(L2,-1))
{
// Loop in preparing upvalues; either direct or via a table
//
// Note: This excludes the case where a function directly addresses
// itself as an upvalue (recursive lane creation).
//
STACK_GROW(L,1);
luaL_error( L, "Recursive use of upvalues; cannot copy the function" );
}
else
{
lua_remove(L2,-2);
}
STACK_END(L2,1)
//
// L2 [-1]: function
ASSERT_L( lua_isfunction(L2,-1) );
}
......@@ -1153,29 +1132,6 @@ void luaG_inter_copy( lua_State* L, lua_State *L2, uint_t n )
uint_t top_L2= lua_gettop(L2);
uint_t i;
/* steal Lua library's 'luaB_tostring()' from the first call. Other calls
* don't have to have access to it.
*
* Note: multiple threads won't come here at once; this function will
* be called before there can be multiple threads (no locking needed).
*/
if (!hijacked_tostring) {
STACK_GROW( L,1 );
STACK_CHECK(L)
lua_getglobal( L, "tostring" );
//
// [-1]: function|nil
hijacked_tostring= lua_tocfunction( L, -1 );
lua_pop(L,1);
STACK_END(L,0)
if (!hijacked_tostring) {
luaL_error( L, "Need to see 'tostring()' once" );
}
}
if (n > top_L)
luaL_error( L, "Not enough values: %d < %d", top_L, n );
......@@ -1196,7 +1152,7 @@ void luaG_inter_copy( lua_State* L, lua_State *L2, uint_t n )
}
/*
* Remove the cache table. persistent caching would cause i.e. multiple
* Remove the cache table. Persistant caching would cause i.e. multiple
* messages passed in the same table to use the same table also in receiving
* end.
*/
......
......@@ -22,6 +22,7 @@
#define STACK_END(L,c) /*nothing*/
#define STACK_DUMP(L) /*nothing*/
#define DEBUG() /*nothing*/
#define DEBUGEXEC(_code) {} /*nothing*/
#else
#define _ASSERT_L(lua,c) { if (!(c)) luaL_error( lua, "ASSERT failed: %s:%d '%s'", __FILE__, __LINE__, #c ); }
//
......@@ -32,6 +33,7 @@
#define STACK_DUMP(L) luaG_dump(L);
#define DEBUG() fprintf( stderr, "<<%s %d>>\n", __FILE__, __LINE__ );
#define DEBUGEXEC(_code) {_code;} /*nothing*/
#endif
#define ASSERT_L(c) _ASSERT_L(L,c)
......
......@@ -260,6 +260,7 @@ void on_tick()
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
docall(L, 1, 1);
tickPaused = lua_toboolean(L, -1);
lua_pop(L, 1);
}
/* Gather our frames per second */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment