Perf: Implement RAII for Mutex in RandomCIDFactory
Used RAII to manage the mutex in the RandomCIDFactory class. Replaced manual locking and unlocking with std::lock_guard for automatic locking and unlocking of the mutex within the critical sections of code