Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-07-28 03:29:17

Bronek Kozicki wrote:

> Roland wrote:
>> I don't think so. The purpose of TSS variables is to be global to your
>> namespace. Member variables are not. To access them you would need some
>> pointer, possibly declared globally. To access this pointer in turn one
>> again needs to resort to TSS.
> Possibly, but not necessarily. In C++ we tend to replace global
> variables with singletons. In case of thread object we could have class
> having single instace per thread ("thread singleton") and static member
> function returning instance for current thread ("thread accessor"). This
> instance does not need to be stored on thread local storage. It can be
> stored in global table (simplest option would be to use thread IDs as
> table index), thus still available after thread destruction (eg. for
> deterministic destruction and pulling results).

It looks like your global table indexed by thread ID is just reinvention of
TSS, which is guaranteed to be slower.

And, BTW, you can't have simple vector indexed by thread id -- because in
NTPL thread ids do not start with zero. So you'd need std::map, which might
be really slow, or some custom map, which doesn't exist yet.

- Volodya

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