Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Image Added

Could write code like this. Using defer lock to add lock to mutex and will be released during recvr_lock deconstructor.

Image AddedUse lock_guard xxxxx

2. Not Use Dynamic Arrays for Buffer

...