Remove: use_async

This commit is contained in:
Coder12a 2019-10-15 11:11:51 -05:00
parent 94b62ac5ab
commit ed7b5996a7
1 changed files with 5 additions and 41 deletions

View File

@ -15,7 +15,6 @@ function colddb.Colddb(dir)
local mem_pool_del = {} local mem_pool_del = {}
local add_to_mem_pool = true local add_to_mem_pool = true
local async = async.Async() local async = async.Async()
local use_async = true
local serializer = minetest.serialize local serializer = minetest.serialize
local deserializer = minetest.deserialize local deserializer = minetest.deserialize
local serializer_type = colddb.serializers.default local serializer_type = colddb.serializers.default
@ -60,10 +59,6 @@ function colddb.Colddb(dir)
return add_to_mem_pool return add_to_mem_pool
end end
self.use_async = function(value)
use_async = value
end
self.get_serializer_type = function() self.get_serializer_type = function()
return serializer_type return serializer_type
end end
@ -152,18 +147,9 @@ function colddb.Colddb(dir)
end end
self.save_mem = function(name) self.save_mem = function(name)
if use_async then if mem_pool[name] ~= nil then
async.queue_task(function() save_table(name, mem_pool[name].mem)
if mem_pool[name] ~= nil then
save_table(name, mem_pool[name].mem)
end
end)
else
if mem_pool[name] ~= nil then
save_table(name, mem_pool[name].mem)
end
end end
mem_pool_del[name] = nil mem_pool_del[name] = nil
end end
@ -173,30 +159,15 @@ function colddb.Colddb(dir)
end end
self.set = function(name, _table) self.set = function(name, _table)
if use_async then save_table(name, _table)
async.queue_task(function()
save_table(name, _table)
end)
else
save_table(name, _table)
end
if add_to_mem_pool then if add_to_mem_pool then
load_into_mem(name, _table) load_into_mem(name, _table)
end end
mem_pool_del[name] = nil mem_pool_del[name] = nil
end end
self.set_key = function(name) self.set_key = function(name)
if use_async then save_key(name)
async.queue_task(function()
save_key(name)
end)
else
save_key(name)
end
if add_to_mem_pool then if add_to_mem_pool then
load_into_mem(name, "") load_into_mem(name, "")
end end
@ -282,14 +253,7 @@ function colddb.Colddb(dir)
self.remove = function(name) self.remove = function(name)
mem_pool[name] = nil mem_pool[name] = nil
mem_pool_del[name] = true mem_pool_del[name] = true
delete_file(name)
if use_async then
async.queue_task(function()
delete_file(name)
end)
else
delete_file(name)
end
end end
self.sub_database = function(path) self.sub_database = function(path)