Refactor the target function to make preparation of fixing the issue
of ahead-of-time device memory deallocation. This patch has following changes:
- Replaced all mutex lock/unlock with std::lock_guard;
- Renamed all variables to conform with LLVM code standard;
- Took data process out of the target function.
clang-tidy: warning: invalid case style for variable 'rc' [readability-identifier-naming]
not useful