Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use const thread_local for reduced init overhead #15

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading