1use crate::perf;
2use std::future::Future;
3
4pub fn dispatch_query<R>(label: &'static str, f: impl FnOnce() -> R) -> R {
6 perf::enter_endpoint();
7 let result = f();
8 perf::exit_endpoint(label);
9 result
10}
11
12pub async fn dispatch_query_async<R, F>(label: &'static str, f: impl FnOnce() -> F) -> R
14where
15 F: Future<Output = R>,
16{
17 perf::enter_endpoint();
18 let result = f().await;
19 perf::exit_endpoint(label);
20 result
21}
22
23pub fn dispatch_update<R>(label: &'static str, f: impl FnOnce() -> R) -> R {
25 perf::enter_endpoint();
26 let result = f();
27 perf::exit_endpoint(label);
28 result
29}
30
31pub async fn dispatch_update_async<R, F>(label: &'static str, f: impl FnOnce() -> F) -> R
33where
34 F: Future<Output = R>,
35{
36 perf::enter_endpoint();
37 let result = f().await;
38 perf::exit_endpoint(label);
39 result
40}