Access a pointer with safe RAII and not a smart pointer.
A ref will take a pointer that will point to a heap pointer which can access the real memory(pointer this). And important, this is thread-safe if your real memory(poniter this) and yoru ref are involved in multi-thread.
Tip:
- Ref::get() is just used to check valid with a short lock.
- RefTaker::get() is used to normal logic but it will lock longer.
- If you don't need a ref point to real memory any more, just call deref().
- Translate Chinese comment yourself.
- Do not put ref in vector that will cause balabala...you debug yourself.
- Feed me back any bug in Issues.