diff options
Diffstat (limited to 'src/macros/thread_local.rs')
-rw-r--r-- | src/macros/thread_local.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/macros/thread_local.rs b/src/macros/thread_local.rs index d848947..74be99a 100644 --- a/src/macros/thread_local.rs +++ b/src/macros/thread_local.rs @@ -1,4 +1,32 @@ #[cfg(all(loom, test))] -macro_rules! thread_local { +macro_rules! tokio_thread_local { + ($(#[$attrs:meta])* $vis:vis static $name:ident: $ty:ty = const { $expr:expr } $(;)?) => { + loom::thread_local! { + $(#[$attrs])* + $vis static $name: $ty = $expr; + } + }; + ($($tts:tt)+) => { loom::thread_local!{ $($tts)+ } } } + +#[cfg(not(tokio_no_const_thread_local))] +#[cfg(not(all(loom, test)))] +macro_rules! tokio_thread_local { + ($($tts:tt)+) => { + ::std::thread_local!{ $($tts)+ } + } +} + +#[cfg(tokio_no_const_thread_local)] +#[cfg(not(all(loom, test)))] +macro_rules! tokio_thread_local { + ($(#[$attrs:meta])* $vis:vis static $name:ident: $ty:ty = const { $expr:expr } $(;)?) => { + ::std::thread_local! { + $(#[$attrs])* + $vis static $name: $ty = $expr; + } + }; + + ($($tts:tt)+) => { ::std::thread_local!{ $($tts)+ } } +} |