Panda3D
configVariableBool.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 configVariableBool.cxx
10  * @author drose
11  * @date 2004-10-20
12  */
13 
14 #include "configVariableBool.h"
15 #include "mutexImpl.h"
16 
17 /**
18  * Refreshes the cached value.
19  */
20 void ConfigVariableBool::
21 reload_value() const {
22  // NB. MSVC doesn't guarantee that this mutex is initialized in a
23  // thread-safe manner. But chances are that the first time this is called
24  // is at static init time, when there is no risk of data races.
25 
26  // This needs to be a recursive mutex, because get_bool_word() may end up
27  // indirectly querying another bool config variable.
28  static ReMutexImpl lock;
29  lock.lock();
30 
31  // We check again for cache validity since another thread may have beaten
32  // us to the punch while we were waiting for the lock.
33  if (!is_cache_valid(_local_modified)) {
34  _cache = get_bool_word(0);
35  mark_cache_valid(_local_modified);
36  }
37 
38  lock.unlock();
39 }
A fake mutex implementation for single-threaded applications that don't need any synchronization cont...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.