Skip to content

Commit

Permalink
Fix Windows Engine Bot
Browse files Browse the repository at this point in the history
Follow-up to flutter#6833
  • Loading branch information
goderbauer committed Nov 13, 2018
1 parent 889f41f commit 196b255
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
31 changes: 31 additions & 0 deletions fml/thread_local.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace fml {

#if FML_THREAD_LOCAL_PTHREADS

ThreadLocal::ThreadLocal() : ThreadLocal(nullptr) {}

ThreadLocal::ThreadLocal(ThreadLocalDestroyCallback destroy)
Expand Down Expand Up @@ -33,4 +35,33 @@ ThreadLocal::Box::Box(ThreadLocalDestroyCallback destroy, intptr_t value)

ThreadLocal::Box::~Box() = default;

#else // FML_THREAD_LOCAL_PTHREADS

ThreadLocal::ThreadLocal() : ThreadLocal(nullptr) {}

ThreadLocal::ThreadLocal(ThreadLocalDestroyCallback destroy)
: destroy_(destroy), value_(0) {}

void ThreadLocal::Set(intptr_t value) {
if (value_ == value) {
return;
}

if (value_ != 0 && destroy_) {
destroy_(value_);
}

value_ = value;
}

intptr_t ThreadLocal::Get() { return value_; }

ThreadLocal::~ThreadLocal() {
if (value_ != 0 && destroy_) {
destroy_(value_);
}
}

#endif // FML_THREAD_LOCAL_PTHREADS

} // namespace fml
25 changes: 5 additions & 20 deletions fml/thread_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,15 @@ class ThreadLocal {

class ThreadLocal {
public:
ThreadLocal() : ThreadLocal(nullptr) {}

ThreadLocal(ThreadLocalDestroyCallback destroy)
: destroy_(destroy), value_(0) {}

void Set(intptr_t value) {
if (value_ == value) {
return;
}
ThreadLocal();

if (value_ != 0 && destroy_) {
destroy_(value_);
}
ThreadLocal(ThreadLocalDestroyCallback destroy);

value_ = value;
}
void Set(intptr_t value);

intptr_t Get() { return value_; }
intptr_t Get();

~ThreadLocal() {
if (value_ != 0 && destroy_) {
destroy_(value_);
}
}
~ThreadLocal();

private:
ThreadLocalDestroyCallback destroy_;
Expand Down

0 comments on commit 196b255

Please sign in to comment.