diff --git a/lua_macros/src/mark_as_ci_command.rs b/lua_macros/src/mark_as_ci_command.rs index f8185dc..69d7511 100644 --- a/lua_macros/src/mark_as_ci_command.rs +++ b/lua_macros/src/mark_as_ci_command.rs @@ -88,7 +88,7 @@ fn append_tx_send_code(input: &mut syn::ItemFn) -> &mut syn::ItemFn { .expect("This is valid."); return_type_as_return_type } else { - // There is only rlua + // There is only mlua::Error left ReturnType::Default } } @@ -108,23 +108,22 @@ fn append_tx_send_code(input: &mut syn::ItemFn) -> &mut syn::ItemFn { ReturnType::Type(_, _) => { quote! { { - Event::CommandEvent(Command::#function_name_pascal(input_str)) + Event::CommandEvent(Command::#function_name_pascal(input_str.clone())) } } } }; quote! { { - let tx: std::sync::Arc>> = + let tx: + core::cell::Ref< + tokio::sync::mpsc::Sender + > = lua - .named_registry_value("sender_for_ci_commands") + .app_data_ref() .expect("This exists, it was set before"); - tx - // FIXME: This is sync code, it needs to be run in a blocking allowed - // executor - .lock() - .expect("This should work, as only one function is executed. It wil however fail, when concurrency is added"); + (*tx) .send(#send_data) .await .expect("This should work, as the reciever is not dropped"); diff --git a/lua_macros/src/struct_to_ci_enum.rs b/lua_macros/src/struct_to_ci_enum.rs index 76b3fd1..7f7ee65 100644 --- a/lua_macros/src/struct_to_ci_enum.rs +++ b/lua_macros/src/struct_to_ci_enum.rs @@ -44,7 +44,7 @@ pub fn generate_generate_ci_function(input: &syn::DeriveInput) -> TokenStream2 { lua: &mut mlua::Lua, tx: tokio::sync::mpsc::Sender) { - lua.set_named_registry_value("sender_for_ci_commands", std::sync::Arc::new(std::sync::Mutex::new(tx))).expect("This should always work, as the value is added before all else"); + lua.set_app_data(tx); let globals = lua.globals(); #input_tokens }