File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -20,5 +20,6 @@ namespace ccf::threading
20
20
static constexpr ThreadID MAIN_THREAD_ID = 0 ;
21
21
22
22
uint16_t get_current_thread_id ();
23
+ void set_current_thread_id (ThreadID to);
23
24
void reset_thread_id_generator (ThreadID to = MAIN_THREAD_ID);
24
25
}
Original file line number Diff line number Diff line change @@ -6,12 +6,22 @@ namespace ccf::threading
6
6
{
7
7
static std::atomic<ThreadID> next_thread_id = MAIN_THREAD_ID;
8
8
9
- uint16_t get_current_thread_id ()
9
+ uint16_t & current_thread_id ()
10
10
{
11
11
thread_local ThreadID this_thread_id = next_thread_id.fetch_add (1 );
12
12
return this_thread_id;
13
13
}
14
14
15
+ uint16_t get_current_thread_id ()
16
+ {
17
+ return current_thread_id ();
18
+ }
19
+
20
+ void set_current_thread_id (ThreadID to)
21
+ {
22
+ current_thread_id () = to;
23
+ }
24
+
15
25
void reset_thread_id_generator (ThreadID to)
16
26
{
17
27
next_thread_id.store (to);
Original file line number Diff line number Diff line change @@ -975,7 +975,8 @@ namespace ccf
975
975
config.command .service_certificate_file );
976
976
}
977
977
978
- auto enclave_thread_start = [&]() {
978
+ auto enclave_thread_start = [&](threading::ThreadID thread_id) {
979
+ threading::set_current_thread_id (thread_id);
979
980
try
980
981
{
981
982
bool ret = enclave_run ();
@@ -1003,7 +1004,7 @@ namespace ccf
1003
1004
std::vector<std::thread> threads;
1004
1005
for (uint32_t i = 0 ; i < (config.worker_threads + 1 ); ++i)
1005
1006
{
1006
- threads.emplace_back (enclave_thread_start);
1007
+ threads.emplace_back (enclave_thread_start, i );
1007
1008
}
1008
1009
1009
1010
LOG_INFO_FMT (" Entering event loop" );
You can’t perform that action at this time.
0 commit comments