File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,14 @@ pin_project_lite::pin_project! {
2222impl < F > MonitoredFuture < F > {
2323 /// Wraps a future with the [`MonitoredFuture`].
2424 pub fn wrap ( inner : F ) -> Self {
25+ Self :: wrap_with_metrics ( inner, Arc :: new ( RawMetrics :: default ( ) ) )
26+ }
27+
28+ /// Wraps a future with the [`MonitoredFuture`].
29+ pub fn wrap_with_metrics ( inner : F , metrics : Arc < RawMetrics > ) -> Self {
2530 Self {
2631 inner,
27- metrics : Arc :: new ( RawMetrics :: default ( ) ) ,
32+ metrics,
2833 // The last time the utilization was updated.
2934 last_utilization_update : Instant :: now ( ) ,
3035 // The poll duration that was accumulated across zero or more polls since the last
Original file line number Diff line number Diff line change @@ -106,6 +106,6 @@ impl AsyncPoolMetrics<'_> {
106106 . map ( |m| m. active_tasks . load ( Ordering :: Relaxed ) )
107107 . sum ( ) ;
108108
109- ( total_polled_futures as f32 / self . max_tasks as f32 ) . clamp ( 0.0 , 1.0 ) as u8 * 100
109+ ( ( total_polled_futures as f32 / self . max_tasks as f32 ) . clamp ( 0.0 , 1.0 ) * 100.0 ) as u8
110110 }
111111}
Original file line number Diff line number Diff line change @@ -67,13 +67,16 @@ where
6767
6868 let thread_name: Option < String > = builder. thread_name . as_mut ( ) . map ( |f| f ( thread_id) ) ;
6969 let metrics = Arc :: new ( ThreadMetrics :: default ( ) ) ;
70- let task = MonitoredFuture :: wrap ( Multiplexed :: new (
71- pool_name,
72- builder. max_concurrency ,
73- rx. into_stream ( ) ,
74- builder. task_panic_handler . clone ( ) ,
75- metrics. clone ( ) ,
76- ) ) ;
70+ let task = MonitoredFuture :: wrap_with_metrics (
71+ Multiplexed :: new (
72+ pool_name,
73+ builder. max_concurrency ,
74+ rx. into_stream ( ) ,
75+ builder. task_panic_handler . clone ( ) ,
76+ metrics. clone ( ) ,
77+ ) ,
78+ metrics. raw_metrics . clone ( ) ,
79+ ) ;
7780
7881 let thread = Thread {
7982 id : thread_id,
You can’t perform that action at this time.
0 commit comments