FastLED
3.9.15
Loading...
Searching...
No Matches
thread_local.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
fl/thread.h
"
4
5
#if FASTLED_MULTITHREADED
6
#warning \
7
"ThreadLocal is not implemented, using the fake version with globally shared data"
8
#endif
9
10
namespace
fl
{
11
12
template
<
typename
T>
class
ThreadLocalFake
;
13
14
template
<
typename
T>
using
ThreadLocal
=
ThreadLocalFake<T>
;
15
17
18
template
<
typename
T>
class
ThreadLocalFake
{
19
public
:
20
// Default: each thread’s object is default-constructed
21
ThreadLocalFake
() :
mValue
() {}
22
23
// With default: each thread’s object is copy-constructed from defaultVal
24
template
<
typename
U>
25
explicit
ThreadLocalFake
(
const
U &defaultVal) :
mValue
(defaultVal) {}
26
27
// Access the thread-local instance
28
T &
access
() {
return
mValue
; }
29
const
T &
access
()
const
{
return
mValue
; }
30
31
// Convenience operators for ThreadLocal<T> = x;”
32
operator
T &() {
return
access
(); }
33
ThreadLocalFake
&
operator=
(
const
T &v) {
34
set(v);
35
return
*
this
;
36
}
37
38
private
:
39
T
mValue
;
40
};
41
42
}
// namespace fl
fl::ThreadLocalFake::ThreadLocalFake
ThreadLocalFake(const U &defaultVal)
Definition
thread_local.h:25
fl::ThreadLocalFake::access
const T & access() const
Definition
thread_local.h:29
fl::ThreadLocalFake::mValue
T mValue
Definition
thread_local.h:39
fl::ThreadLocalFake::ThreadLocalFake
ThreadLocalFake()
Definition
thread_local.h:21
fl::ThreadLocalFake::access
T & access()
Definition
thread_local.h:28
fl::ThreadLocalFake::operator=
ThreadLocalFake & operator=(const T &v)
Definition
thread_local.h:33
fl::ThreadLocalFake
Definition
thread_local.h:18
fl::ThreadLocal
ThreadLocalFake< T > ThreadLocal
Definition
thread_local.h:14
fl
Implements a simple red square effect for 2D LED grids.
Definition
crgb.h:16
thread.h
fl
thread_local.h
Generated on Sat May 24 2025 22:44:23 for FastLED by
1.13.2