Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn xtra_productivity(_attribute: TokenStream, item: TokenStream) -> TokenStr
ReturnType::Type(_, ref t) => quote! { #t }
};

let attrs = method.attrs;
let mut attrs = method.attrs;

#[cfg(feature = "instrumentation")]
let instrument = if !attrs.iter().any(|attr| attr.path.segments.last().unwrap().ident == "instrument") {
Expand All @@ -80,6 +80,13 @@ pub fn xtra_productivity(_attribute: TokenStream, item: TokenStream) -> TokenStr
#[cfg(not(feature = "instrumentation"))]
let instrument = quote!();

let method_block = if let Some(idx) = attrs.iter().position(|attr| attr.path.is_ident("blocking_handler")) {
let _ = attrs.swap_remove(idx);
quote!({ ::tokio::task::block_in_place(move || #method_block ) })
} else {
quote!(#method_block)
};

quote! {
#[async_trait::async_trait]
impl<#generic_params> xtra::Handler<#message_type> for #actor
Expand Down