...
If we do not use smart pointer, we could not sure that there are some unexpected return code or throw unexpected exceptions in the future. And could not prevent memory leak.
1.2 Lock and Unlock
There are many lock and unlock code. Could not make sure that the lock is correctly released. Should use unique lock or lock guard. For example, in following example, the lock is conditionally locked by checking acquire_lock
sign. But if somebody add some code at line 76 or call return before line 86 the lock will not be correctly unlocked.
Could write code like this. Using defer lock to add lock to mutex and will be released during recvr_lock deconstructor.
Use lock_guard xxxxx
2. Not Use Dynamic Arrays for Buffer
...