summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-11-04 20:20:21 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-11-04 20:21:46 +0100
commitcb9f187f80250ed522031ef3efba866a9171e9ce (patch)
tree8c82d19391a563f6a49b1a0fbd9ad23f9b597054 /degesch.c
parent0247c4667a8c63c8f657f4c782fdd4a591c1e1d0 (diff)
downloadxK-cb9f187f80250ed522031ef3efba866a9171e9ce.tar.gz
xK-cb9f187f80250ed522031ef3efba866a9171e9ce.tar.xz
xK-cb9f187f80250ed522031ef3efba866a9171e9ce.zip
degesch: get rid of Lua timer hooks
Since they were the exception and have been replaced with the async API.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/degesch.c b/degesch.c
index 1718402..511fdae 100644
--- a/degesch.c
+++ b/degesch.c
@@ -9073,7 +9073,6 @@ enum lua_hook_type
XLUA_HOOK_IRC, ///< IRC hook
XLUA_HOOK_PROMPT, ///< Prompt hook
XLUA_HOOK_COMPLETION, ///< Autocomplete
- XLUA_HOOK_TIMER, ///< One-shot timer
};
struct lua_hook
@@ -9088,8 +9087,6 @@ struct lua_hook
struct irc_hook irc_hook; ///< IRC hook
struct prompt_hook prompt_hook; ///< IRC hook
struct completion_hook c_hook; ///< Autocomplete hook
-
- struct poller_timer timer; ///< Timer
}
data; ///< Hook data
};
@@ -9113,9 +9110,6 @@ lua_hook_unhook (lua_State *L)
case XLUA_HOOK_COMPLETION:
LIST_UNLINK (hook->plugin->ctx->completion_hooks, &hook->data.hook);
break;
- case XLUA_HOOK_TIMER:
- poller_timer_reset (&hook->data.timer);
- break;
default:
hard_assert (!"invalid hook type");
case XLUA_HOOK_DEFUNCT:
@@ -9302,26 +9296,6 @@ lua_completion_hook_complete (struct completion_hook *self,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-static void
-lua_timer_hook_dispatch (void *user_data)
-{
- struct lua_hook *hook = user_data;
- struct lua_plugin *plugin = hook->plugin;
- lua_State *L = plugin->L;
-
- lua_rawgeti (L, LUA_REGISTRYINDEX, hook->ref_callback);
- lua_rawgetp (L, LUA_REGISTRYINDEX, hook); // 1: hook
-
- struct error *e = NULL;
- if (!lua_plugin_call (plugin, 1, 0, &e))
- lua_plugin_log_error (plugin, "timer hook", e);
-
- // There's no need to keep the hook around once the timer is dispatched
- lua_cache_invalidate (L, hook);
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
static struct lua_hook *
lua_plugin_push_hook (lua_State *L, struct lua_plugin *plugin,
int callback_index, enum lua_hook_type type, int priority)
@@ -9392,27 +9366,6 @@ lua_plugin_hook_completion (lua_State *L)
return 1;
}
-static int
-lua_plugin_hook_timer (lua_State *L)
-{
- struct lua_plugin *plugin = lua_touserdata (L, lua_upvalueindex (1));
- lua_Integer timeout = luaL_checkinteger (L, 2);
-
- if (timeout < 0)
- luaL_argerror (L, 2, "timeout mustn't be negative");
-
- // This doesn't really hook anything but we can reuse the code
- struct lua_hook *hook = lua_plugin_push_hook
- (L, plugin, 1, XLUA_HOOK_TIMER, 0 /* priority doesn't apply */);
-
- struct poller_timer *timer = &hook->data.timer;
- poller_timer_init (timer, &plugin->ctx->poller);
- timer->dispatcher = lua_timer_hook_dispatch;
- timer->user_data = hook;
- poller_timer_set (timer, timeout);
- return 1;
-}
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#define XLUA_SCHEMA_METATABLE "schema" ///< Identifier for the Lua metatable
@@ -10096,7 +10049,6 @@ static luaL_Reg lua_plugin_library[] =
{ "hook_irc", lua_plugin_hook_irc },
{ "hook_prompt", lua_plugin_hook_prompt },
{ "hook_completion", lua_plugin_hook_completion },
- { "hook_timer", lua_plugin_hook_timer },
{ "setup_config", lua_plugin_setup_config },
{ "connect", lua_plugin_connect },