Boost logo

Boost :

Subject: [boost] [thread_local] emulation !?
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-04-13 08:00:56


I have been using a mechanism to emulate [thread_local] storage for some
time now. However, I am aware of boost.thread has thread local heap. The
difference is with thread_local emulator we have similar c++0x syntax
working seemlessly. for example:

thread_local <int> tlocal_integer(-1);

// assign the global thread_local value
void foo(int i) {
  *tlocal_integer = i;
  std::cout << this_thread::get_id() << " : " << *tlocal_integer << endl;

int main()
  boost::thread_group tg;
  for(int i=1;i<500;i++) tg.create_thread(bind(&::foo, i));

  *tlocal_integer = 0;
  std::cout << "main : " << *tlocal_integer << endl;


  return 0;

Wondering if anyone is interested into porting this to boost???


Boost list run by bdawes at, gregod at, cpdaniel at, john at