Skip to content

Commit

Permalink
Add "goobie_mysql.Poll" function for more control
Browse files Browse the repository at this point in the history
  • Loading branch information
Srlion committed Oct 8, 2024
1 parent 229258b commit 9b1b45e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/conn/on_gmod_open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ const CONNECT_METHODS: &[LuaReg] = lua_regs![

pub fn init(l: lua::State) {
l.register(GLOBAL_TABLE_NAME_C.as_ptr(), CONNECT_METHODS.as_ptr());
{
l.push_string(crate::VERSION);
l.set_field(-2, c"VERSION");
}
l.pop();

l.new_metatable(super::META_NAME);
Expand Down
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ pub use runtime::{run_async, wait_async};

pub static mut GMOD_CLOSED: bool = false;

const METHODS: &[LuaReg] = lua_regs![
"Poll" => poll,
];

#[inline]
pub fn is_gmod_closed() -> bool {
unsafe { GMOD_CLOSED }
Expand All @@ -23,6 +27,13 @@ fn gmod13_open(l: lua::State) -> i32 {
GMOD_CLOSED = false;
}

l.register(GLOBAL_TABLE_NAME_C.as_ptr(), METHODS.as_ptr());
{
l.push_string(crate::VERSION);
l.set_field(-2, c"VERSION");
}
l.pop();

runtime::load(get_max_worker_threads(l));

conn::on_gmod_open::init(l);
Expand All @@ -41,6 +52,13 @@ fn gmod13_close(l: lua::State) -> i32 {
0
}

#[lua_function]
fn poll(l: lua::State) -> i32 {
task_queue::run_callbacks(l);

0
}

fn get_max_worker_threads(l: lua::State) -> u16 {
let mut max_worker_threads = DEFAULT_WORKER_THREADS;

Expand Down

0 comments on commit 9b1b45e

Please sign in to comment.