Panda3D
configVariableString.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file configVariableString.cxx
10  * @author drose
11  * @date 2004-10-20
12  */
13 
14 #include "configVariableString.h"
15 
16 /**
17  * Refreshes the variable's cached value.
18  */
19 void ConfigVariableString::
20 reload_cache() {
21  // NB. MSVC doesn't guarantee that this mutex is initialized in a
22  // thread-safe manner. But chances are that the first time this is called
23  // is at static init time, when there is no risk of data races.
24  static MutexImpl lock;
25  lock.lock();
26 
27  // We check again for cache validity since another thread may have beaten
28  // us to the punch while we were waiting for the lock.
29  if (!is_cache_valid(_local_modified)) {
30  _cache = get_string_value();
31  mark_cache_valid(_local_modified);
32  }
33 
34  lock.unlock();
35 }
const std::string & get_string_value() const
Returns the toplevel value of the variable, formatted as a string.
A fake mutex implementation for single-threaded applications that don't need any synchronization cont...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.