diff --git a/binding/lua_thread.cpp b/binding/lua_thread.cpp index fb92840b..d9e3ed66 100644 --- a/binding/lua_thread.cpp +++ b/binding/lua_thread.cpp @@ -116,11 +116,6 @@ namespace bee::lua_thread { spinlock mutex; }; - struct rpc { - atomic_semaphore sem = atomic_semaphore(0); - void* data = nullptr; - }; - static channelmgr g_channel; static std::atomic g_thread_id = -1; static int THREADID; @@ -301,28 +296,6 @@ namespace bee::lua_thread { return 0; } - static void rpc_metatable(lua_State* L) {} - - static int lrpc_create(lua_State* L) { - auto& r = lua::newudata(L); - lua_pushlightuserdata(L, &r); - lua_rotate(L, 1, 1); - return 2; - } - - static int lrpc_wait(lua_State* L) { - auto r = lua::checklightud(L, 1); - r->sem.acquire(); - return seri_unpackptr(L, r->data); - } - - static int lrpc_return(lua_State* L) { - auto r = lua::checklightud(L, 1); - r->data = seri_pack(L, 1, NULL); - r->sem.release(); - return 0; - } - static void init_threadid(lua_State* L) { if (lua_rawgetp(L, LUA_REGISTRYINDEX, &THREADID) != LUA_TNIL) { return; @@ -343,9 +316,6 @@ namespace bee::lua_thread { { "reset", lreset }, { "wait", lwait }, { "setname", lsetname }, - { "rpc_create", lrpc_create }, - { "rpc_wait", lrpc_wait }, - { "rpc_return", lrpc_return }, { "preload_module", lua::preload_module }, { "id", NULL }, { NULL, NULL }, @@ -366,9 +336,4 @@ namespace bee::lua { static inline auto name = "bee::channel"; static inline auto metatable = bee::lua_thread::channel_metatable; }; - template <> - struct udata { - static inline auto name = "bee::rpc"; - static inline auto metatable = bee::lua_thread::rpc_metatable; - }; } diff --git a/test/test_thread.lua b/test/test_thread.lua index bb5ccd8e..eac137f0 100644 --- a/test/test_thread.lua +++ b/test/test_thread.lua @@ -293,41 +293,6 @@ function test_thread:test_thread_pop() assertNotThreadError() end -function test_thread:test_rpc() - thread.reset() - thread.newchannel "test" - local thd = createThread [[ - local thread = require "bee.thread" - local c = thread.channel "test" - local quit - local cmd = {} - function cmd.add(a, b) - return a + b - end - function cmd.exit() - quit = true - return "ok" - end - local function dispatch(context, what, ...) - thread.rpc_return(context, cmd[what](...)) - return not quit - end - while dispatch(c:bpop()) do - end - ]] - local c = thread.channel "test" - local function call(...) - local r, _ = thread.rpc_create() - c:push(r, ...) - return thread.rpc_wait(r) - end - lt.assertEquals(call("add", 1, 2), 3) - lt.assertEquals(call("exit"), "ok") - thread.wait(thd) - assertNotThreadError() - thread.reset() -end - function test_thread:test_sleep() local t1 = time.monotonic() thread.sleep(1)