Update tls_pointer.h

This commit is contained in:
木头云 2020-03-20 12:20:28 +08:00 committed by GitHub
parent bbefef4a37
commit e87d516b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,19 +29,17 @@ IPC_EXPORT void* get(key_t key);
/* /*
* <Remarks> * <Remarks>
* *
* 1. In Windows, if you do not compile thread_local_ptr.cpp, * You need to set the ipc::tls::pointer's storage manually:
* use thread_local_ptr will cause memory leaks. * ```
* * tls::pointer<int> p;
* 2. You need to set the thread_local_ptr's storage manually: * if (!p) p = new int(123);
* ``` * ```
* tls::pointer<int> p; * It would be like an ordinary pointer.
* if (!p) p = new int(123); * Or you could just call create to 'new' this pointer automatically.
* ``` * ```
* Just like an ordinary pointer. Or you could just call create: * tls::pointer<int> p;
* ``` * p.create(123);
* tls::pointer<int> p; * ```
* p.create(123);
* ```
*/ */
template <typename T> template <typename T>