Skip to content

Commit

Permalink
Use const thread_local for reduced init overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
Robo210 committed Nov 21, 2024
1 parent 45f4fc6 commit 1f524ed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/native/common_schema/etw_cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracelogging::*;
use tracelogging_dynamic::EventBuilder;
use tracing_subscriber::registry::{LookupSpan, SpanRef};

thread_local! {static EBW: std::cell::RefCell<EventBuilder> = RefCell::new(EventBuilder::new());}
thread_local! {static EBW: RefCell<EventBuilder> = const { RefCell::new(EventBuilder::new());} }

pub(crate) struct CommonSchemaPartCBuilder<'a> {
pub(crate) eb: &'a mut EventBuilder,
Expand Down
2 changes: 1 addition & 1 deletion src/native/common_schema/user_events_cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
};
use tracing_subscriber::registry::{LookupSpan, SpanRef};

thread_local! {static EBW: std::cell::RefCell<EventBuilder> = RefCell::new(EventBuilder::new());}
thread_local! {static EBW: RefCell<EventBuilder> = const { RefCell::new(EventBuilder::new());} }

pub(crate) struct CommonSchemaPartCBuilder<'a> {
pub(crate) eb: &'a mut EventBuilder,
Expand Down
2 changes: 1 addition & 1 deletion src/native/etw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) static mut _start__etw_kw: usize = usize::from_ne_bytes(*b"RSETW000")
#[link_section = ".rsdata$zRSETW9"]
pub(crate) static mut _stop__etw_kw: usize = usize::from_ne_bytes(*b"RSETW999");

thread_local! {static EBW: std::cell::RefCell<EventBuilder> = RefCell::new(EventBuilder::new());}
thread_local! {static EBW: RefCell<EventBuilder> = const { RefCell::new(EventBuilder::new());} }

struct Win32SystemTime {
st: [u16; 8],
Expand Down
2 changes: 1 addition & 1 deletion src/native/user_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern "C" {
#[used]
static mut ETW_META_PTR: *const crate::_details::EventMetadata = core::ptr::null();

thread_local! {static EBW: std::cell::RefCell<EventBuilder> = RefCell::new(EventBuilder::new());}
thread_local! {static EBW: RefCell<EventBuilder> = const { RefCell::new(EventBuilder::new());} }

impl<T> AddFieldAndValue<T> for &'_ mut eventheader_dynamic::EventBuilder {
fn add_field_value(&mut self, fv: &FieldAndValue) {
Expand Down

0 comments on commit 1f524ed

Please sign in to comment.