Collection loading and deletion support (in a thread).

This commit is contained in:
emb
2015-11-21 10:49:38 -06:00
parent 34e59adb1d
commit 45ffcb148c
7 changed files with 51 additions and 10 deletions

View File

@@ -16,14 +16,24 @@ void LuaCollection::initialize(Configuration *c, CollectionInfoBuilder *b, LuaE
int LuaCollection::load(lua_State *l)
{
std::string collection = luaL_checkstring(l, 1);
cib->buildCollection(collection, loadCallback, (void *)l);
return 0;
}
void LuaCollection::loadCallback(void *context)
int LuaCollection::destroy(lua_State *l)
{
CollectionInfo *i = (CollectionInfo *)luaL_checkinteger(l, 1);
cib->destroyCollection(i);
return 0;
}
void LuaCollection::loadCallback(void *context, CollectionInfo *info)
{
lua_State *l = (lua_State *)context;
events->trigger(l, "onCollectionLoaded");
events->trigger(l, "onCollectionLoaded", (void *)info);
}