Panda3D
configVariableString.cxx
1 // Filename: configVariableString.cxx
2 // Created by: drose (20Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "configVariableString.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: ConfigVariableString::reload_cache
19 // Access: Published
20 // Description: Refreshes the variable's cached value.
21 ////////////////////////////////////////////////////////////////////
22 void ConfigVariableString::
23 reload_cache() {
24  // NB. MSVC doesn't guarantee that this mutex is initialized in a
25  // thread-safe manner. But chances are that the first time this is called
26  // is at static init time, when there is no risk of data races.
27  static MutexImpl lock;
28  lock.acquire();
29 
30  // We check again for cache validity since another thread may have beaten
31  // us to the punch while we were waiting for the lock.
32  if (!is_cache_valid(_local_modified)) {
33  _cache = get_string_value();
34  mark_cache_valid(_local_modified);
35  }
36 
37  lock.release();
38 }
const 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...