Added thread-safety: added shared_mutex. Unique lock on connect/disconnect and shared lock for other methods.