ACE_Service_Repository * ACE_Service_Repository::instance (size_t size) { ACE_TRACE ("ACE_Service_Repository::instance"); if (ACE_Service_Repository::svc_rep_ == 0) { // Perform Double-Checked Locking Optimization. ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, *ACE_Static_Object_Lock::instance (), 0)); if (ACE_Service_Repository::svc_rep_ == 0) { if (ACE_Object_Manager::starting_up () || !ACE_Object_Manager::shutting_down ()) { ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_, ACE_Service_Repository (size), 0); ACE_Service_Repository::delete_svc_rep_ = true; } } } return ACE_Service_Repository::svc_rep_; }
/// Performs the common initialization tasks for a new or previously /// closed instance. Must not be virtual, as it is also called from /// the constructor. int ACE_Service_Gestalt::init_i (void) { // Only initialize the repo_ if (a) we are being constructed, or; // (b) we're being open()-ed, perhaps after previously having been // close()-ed. In both cases: repo_ == 0 and we need a repository. if (this->repo_ == 0) { if (this->svc_repo_is_owned_) { ACE_NEW_RETURN (this->repo_, ACE_Service_Repository (this->svc_repo_size_), -1); } else { this->repo_ = ACE_Service_Repository::instance (this->svc_repo_size_); } } if (init_svc_conf_file_queue () == -1) return -1; return 0; }
/// Performs the common initialization tasks for a new or previously /// closed instance. Must not be virtual, as it is also called from /// the constructor. int ACE_Service_Gestalt::init_i (void) { // Only initialize the repo_ if (a) we are being constructed, or; // (b) we're being open()-ed, perhaps after previously having been // close()-ed. In both cases: repo_ == 0 and we need a repository. if (this->repo_ == 0) { if (this->svc_repo_is_owned_) { ACE_NEW_RETURN (this->repo_, ACE_Service_Repository (this->svc_repo_size_), -1); } else { this->repo_ = ACE_Service_Repository::instance (this->svc_repo_size_); } } if (init_svc_conf_file_queue () == -1) return -1; if ( svc_conf_file_queue_->is_empty ()) { // Check if the default file exists before attempting to queue it // for processing FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, ACE_TEXT ("r")); bool skip_static_svcs = (fp == 0); if (fp != 0) ACE_OS::fclose (fp); if (!skip_static_svcs) { // Load the default "svc.conf" entry here if there weren't // overriding -f arguments in <parse_args>. if (svc_conf_file_queue_->enqueue_tail (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("enqueuing ") ACE_DEFAULT_SVC_CONF ACE_TEXT(" file")), -1); } } } return 0; }