Statistics collecting locking for Ruby