#include <shared_thread_local_data.hh>
|
static
utility::pointer::shared_ptr
< T > | get_instance (std::thread::id) |
|
|
std::thread::id | thread |
|
utility::pointer::shared_ptr< T > | data |
|
template<typename T>
class utility::thread::SharedThreadLocalData< T >
This template class is intended to provide access to instance of T that is unique to your thread Notes:
- underlying object will be create on-demand. You should not try to store it or share it (thats why we expose only reference to object and not SP)
- class itself is not thread-safe!
- you can safely move instance of SharedThreadLocalData between threads, such move will result in creation of underlying object next time it is accessed.
So if your use-pattern involved of constantly moving-between-threads it will create two types of overheads:
- if thread to which you moved your object ALREADY HAVE other instances of SharedThreadLocalData for that type and such instance already hold a valid underlying data (on which
get
was called): overhead will be minimal: one lock + map lookup during the first access and no overhead (except the cost of std::this_thread::get_id()
) on sub-sequential accesses
- if thread to which you moved your object DOES NOT HAVE other instances of SharedThreadLocalData then overhead will be: cost of underlying object creation during first access and no overhead (except the cost of
std::this_thread::get_id()
) on sub-sequential accesses
WARNING WARNING WARNING: In the unlikely event that you actually do need to use this class please make to contact Sergey Lyskov (serge.nosp@m.y.ly.nosp@m.skov@.nosp@m.jhu..nosp@m.edu) or Andrew Leaver-Fay (aleav.nosp@m.erfa.nosp@m.y@gma.nosp@m.il.c.nosp@m.om)
The documentation for this class was generated from the following files: