summaryrefslogtreecommitdiff
path: root/scripts/context/stubs
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-10-22 01:00:14 +0300
committerMarius <mariausol@gmail.com>2010-10-22 01:00:14 +0300
commit7dda6d27d5c9957a51dbad4fca7c01b9261ec4d2 (patch)
tree7a25708509d339bed177b78359de842fa2e16908 /scripts/context/stubs
parent22239196756b1e1afff74003befd86150ab8013b (diff)
downloadcontext-7dda6d27d5c9957a51dbad4fca7c01b9261ec4d2.tar.gz
beta 2010.10.21 23:27
Diffstat (limited to 'scripts/context/stubs')
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua21
-rw-r--r--scripts/context/stubs/unix/mtxrun21
2 files changed, 38 insertions, 4 deletions
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index c678597e1..60a44bd2a 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -1110,8 +1110,14 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify)
else
handle("t={")
end
- if root and next(root) then
- do_serialize(root,name,"",0)
+ if root then
+ -- The dummy access will initialize a table that has a delayed initialization
+ -- using a metatable.
+ local dummy = root.whatever
+ -- Let's forget about empty tables.
+ if next(root) then
+ do_serialize(root,name,"",0)
+ end
end
handle("}")
end
@@ -4062,6 +4068,16 @@ function getmetatablekey(t,key,value)
end
+function storage.setinitializer(data,initialize)
+ local m = getmetatable(data) or { }
+ m.__index = function(data,k)
+ m.__index = nil -- so that we can access the entries during initializing
+ initialize()
+ return data[k]
+ end
+ setmetatable(data, m)
+end
+
end -- of closure
@@ -4190,6 +4206,7 @@ function statistics.show(reporter)
local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0
return format("direct: %s, indirect: %s, total: %s", total-indirect, indirect, total)
end)
+ collectgarbage("collect")
register("current memory usage", statistics.memused)
register("runtime",statistics.runtime)
for i=1,#statusinfo do
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index c678597e1..60a44bd2a 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -1110,8 +1110,14 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify)
else
handle("t={")
end
- if root and next(root) then
- do_serialize(root,name,"",0)
+ if root then
+ -- The dummy access will initialize a table that has a delayed initialization
+ -- using a metatable.
+ local dummy = root.whatever
+ -- Let's forget about empty tables.
+ if next(root) then
+ do_serialize(root,name,"",0)
+ end
end
handle("}")
end
@@ -4062,6 +4068,16 @@ function getmetatablekey(t,key,value)
end
+function storage.setinitializer(data,initialize)
+ local m = getmetatable(data) or { }
+ m.__index = function(data,k)
+ m.__index = nil -- so that we can access the entries during initializing
+ initialize()
+ return data[k]
+ end
+ setmetatable(data, m)
+end
+
end -- of closure
@@ -4190,6 +4206,7 @@ function statistics.show(reporter)
local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0
return format("direct: %s, indirect: %s, total: %s", total-indirect, indirect, total)
end)
+ collectgarbage("collect")
register("current memory usage", statistics.memused)
register("runtime",statistics.runtime)
for i=1,#statusinfo do