@@ -7,6 +7,18 @@ macro_rules! define_handles {
7
7
' owned: $( $oty: ident, ) *
8
8
' interned: $( $ity: ident, ) *
9
9
) => {
10
+ static COUNTERS : HandleCounters = HandleCounters {
11
+ $( $oty: AtomicUsize :: new( 1 ) , ) *
12
+ $( $ity: AtomicUsize :: new( 1 ) , ) *
13
+ } ;
14
+
15
+ #[ repr( C ) ]
16
+ #[ allow( non_snake_case) ]
17
+ struct HandleCounters {
18
+ $( $oty: AtomicUsize , ) *
19
+ $( $ity: AtomicUsize , ) *
20
+ }
21
+
10
22
#[ repr( C ) ]
11
23
#[ allow( non_snake_case) ]
12
24
struct HandleStore <S : Types > {
@@ -15,10 +27,10 @@ macro_rules! define_handles {
15
27
}
16
28
17
29
impl <S : Types > HandleStore <S > {
18
- fn new( handle_counters : & ' static client :: HandleCounters ) -> Self {
30
+ fn new( ) -> Self {
19
31
HandleStore {
20
- $( $oty: handle:: OwnedStore :: new( & handle_counters . $oty) , ) *
21
- $( $ity: handle:: InternedStore :: new( & handle_counters . $ity) , ) *
32
+ $( $oty: handle:: OwnedStore :: new( & COUNTERS . $oty) , ) *
33
+ $( $ity: handle:: InternedStore :: new( & COUNTERS . $ity) , ) *
22
34
}
23
35
}
24
36
}
@@ -330,14 +342,13 @@ fn run_server<
330
342
O : for < ' a , ' s > DecodeMut < ' a , ' s , HandleStore < MarkedTypes < S > > > ,
331
343
> (
332
344
strategy : & impl ExecutionStrategy ,
333
- handle_counters : & ' static client:: HandleCounters ,
334
345
server : S ,
335
346
input : I ,
336
347
run_client : extern "C" fn ( Bridge < ' _ > ) -> Buffer ,
337
348
force_show_panics : bool ,
338
349
) -> Result < O , PanicMessage > {
339
350
let mut dispatcher =
340
- Dispatcher { handle_store : HandleStore :: new ( handle_counters ) , server : MarkedTypes ( server) } ;
351
+ Dispatcher { handle_store : HandleStore :: new ( ) , server : MarkedTypes ( server) } ;
341
352
342
353
let mut buf = Buffer :: new ( ) ;
343
354
input. encode ( & mut buf, & mut dispatcher. handle_store ) ;
@@ -355,10 +366,9 @@ impl client::Client<crate::TokenStream, crate::TokenStream> {
355
366
input : S :: TokenStream ,
356
367
force_show_panics : bool ,
357
368
) -> Result < S :: TokenStream , PanicMessage > {
358
- let client:: Client { get_handle_counters , run, _marker } = * self ;
369
+ let client:: Client { run, _marker } = * self ;
359
370
run_server (
360
371
strategy,
361
- get_handle_counters ( ) ,
362
372
server,
363
373
<MarkedTypes < S > as Types >:: TokenStream :: mark ( input) ,
364
374
run,
@@ -377,10 +387,9 @@ impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream
377
387
input2 : S :: TokenStream ,
378
388
force_show_panics : bool ,
379
389
) -> Result < S :: TokenStream , PanicMessage > {
380
- let client:: Client { get_handle_counters , run, _marker } = * self ;
390
+ let client:: Client { run, _marker } = * self ;
381
391
run_server (
382
392
strategy,
383
- get_handle_counters ( ) ,
384
393
server,
385
394
(
386
395
<MarkedTypes < S > as Types >:: TokenStream :: mark ( input) ,
0 commit comments