@@ -6,7 +6,7 @@ use ntex::http::header::{CONTENT_TYPE, SERVER};
6
6
use ntex:: http:: { HttpService , KeepAlive , Request , Response , StatusCode } ;
7
7
use ntex:: service:: { Service , ServiceCtx , ServiceFactory } ;
8
8
use ntex:: web:: { Error , HttpResponse } ;
9
- use ntex:: { time:: Seconds , util:: PoolId , util :: Ready } ;
9
+ use ntex:: { time:: Seconds , util:: PoolId } ;
10
10
11
11
mod db;
12
12
mod utils;
@@ -82,12 +82,9 @@ impl ServiceFactory<Request> for AppFactory {
82
82
async fn main ( ) -> std:: io:: Result < ( ) > {
83
83
println ! ( "Starting http server: 127.0.0.1:8080" ) ;
84
84
85
- let cores = core_affinity:: get_core_ids ( ) . unwrap ( ) ;
86
- let total_cores = cores. len ( ) ;
87
- let cores = std:: sync:: Arc :: new ( std:: sync:: Mutex :: new ( cores) ) ;
88
-
89
85
ntex:: server:: build ( )
90
86
. backlog ( 1024 )
87
+ . enable_affinity ( )
91
88
. bind ( "techempower" , "0.0.0.0:8080" , |cfg| {
92
89
cfg. memory_pool ( PoolId :: P1 ) ;
93
90
PoolId :: P1 . set_read_params ( 65535 , 2048 ) ;
@@ -100,17 +97,6 @@ async fn main() -> std::io::Result<()> {
100
97
. payload_read_rate ( Seconds :: ZERO , Seconds :: ZERO , 0 )
101
98
. h1 ( AppFactory )
102
99
} ) ?
103
- . configure ( move |cfg| {
104
- let cores = cores. clone ( ) ;
105
- cfg. on_worker_start ( move |_| {
106
- if let Some ( core) = cores. lock ( ) . unwrap ( ) . pop ( ) {
107
- core_affinity:: set_for_current ( core) ;
108
- }
109
- Ready :: < _ , & str > :: Ok ( ( ) )
110
- } ) ;
111
- Ok ( ( ) )
112
- } ) ?
113
- . workers ( total_cores)
114
100
. run ( )
115
101
. await
116
102
}
0 commit comments