@@ -12,6 +12,7 @@ use graph::runtime::gas::Gas;
12
12
use parity_wasm:: elements:: ExportEntry ;
13
13
use std:: collections:: BTreeMap ;
14
14
use std:: panic:: AssertUnwindSafe ;
15
+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
15
16
use std:: sync:: Arc ;
16
17
use std:: { panic, thread} ;
17
18
@@ -28,6 +29,8 @@ pub fn spawn_module<C: Blockchain>(
28
29
where
29
30
<C as Blockchain >:: MappingTrigger : ToAscPtr ,
30
31
{
32
+ static THREAD_COUNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
33
+
31
34
let valid_module = Arc :: new ( ValidModule :: new ( & logger, raw_module, timeout) ?) ;
32
35
33
36
// Create channel for event handling requests
39
42
// In case of failure, this thread may panic or simply terminate,
40
43
// dropping the `mapping_request_receiver` which ultimately causes the
41
44
// subgraph to fail the next time it tries to handle an event.
42
- let conf =
43
- thread:: Builder :: new ( ) . name ( format ! ( "mapping-{}-{}" , & subgraph_id, uuid :: Uuid :: new_v4 ( ) ) ) ;
45
+ let next_id = THREAD_COUNT . fetch_add ( 1 , Ordering :: SeqCst ) ;
46
+ let conf = thread:: Builder :: new ( ) . name ( format ! ( "mapping-{}-{:0>4 }" , & subgraph_id, next_id ) ) ;
44
47
conf. spawn ( move || {
45
48
let _runtime_guard = runtime. enter ( ) ;
46
49
0 commit comments