Closed GoogleCodeExporter closed 9 years ago
ThreadLocal is supposed to be initialized in the main thread only. Its get()
method
will return a different value for each thread that calls it. The value is
created
on-demand. If you call get() twice in the same thread, you get the same value.
If
you call get() from different threads, you get different values.
We use gtest in many multi-threaded tests where we have a full implementation
of
ThreadLocal, and it works fine.
I'm changing the issue title to reflect the real problem.
Original comment by zhanyong...@gmail.com
on 15 May 2009 at 5:30
Albert Wong wrote:
> It's not a 100% match, but you might look in the chromium code base under
> the "base/" directory for "lock.h" and "thread_local.h" as a starting point.
> I think you'll find analogues for Mutex, MutexLock (called Lock and
> AutoLock), and ThreadLocal. I don't know about GetThreadCount...
Original comment by zhanyong...@gmail.com
on 8 Oct 2009 at 11:55
I've uploaded an implementation for pthreads to review at:
http://codereview.appspot.com/129067/show.
Original comment by FazekasM...@gmail.com
on 11 Oct 2009 at 5:55
Fixed in the trunk for platforms with pthread, by Miklos and Vlad.
Original comment by w...@google.com
on 6 Mar 2010 at 5:56
Original issue reported on code.google.com by
covercl...@diag.com
on 14 May 2009 at 10:21