Panda3D
 All Classes Functions Variables Enumerations
configFlags.I
1 // Filename: configFlags.I
2 // Created by: drose (21Oct04)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ConfigFlags::is_cache_valid
18 // Access: Protected, Static
19 // Description: Returns true if the local object's cache is still
20 // valid (based on a comparison of the supplied
21 // local_modified value with the global_modified value).
22 ////////////////////////////////////////////////////////////////////
23 INLINE bool ConfigFlags::
24 is_cache_valid(AtomicAdjust::Integer local_modified) {
25  return local_modified == _global_modified;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: ConfigFlags::mark_cache_valid
30 // Access: Protected, Static
31 // Description: Updates the indicated local_modified value so that
32 // the cache will appear to be valid, until someone next
33 // calls invalidate_cache().
34 ////////////////////////////////////////////////////////////////////
35 INLINE void ConfigFlags::
36 mark_cache_valid(AtomicAdjust::Integer &local_modified) {
37  local_modified = _global_modified;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: ConfigFlags::initial_invalid_cache
42 // Access: Protected, Static
43 // Description: Returns a value that will be appropriate for
44 // initializing a local_modified value. This value will
45 // indicate an invalid cache in the next call to
46 // is_cache_valid().
47 ////////////////////////////////////////////////////////////////////
48 INLINE AtomicAdjust::Integer ConfigFlags::
49 initial_invalid_cache() {
50  return _global_modified - 1;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: ConfigFlags::invalidate_cache
55 // Access: Protected, Static
56 // Description: Invalidates all of the global ConfigVariable caches
57 // in the world at once, by incrementing the
58 // global_modified counter.
59 ////////////////////////////////////////////////////////////////////
60 INLINE void ConfigFlags::
61 invalidate_cache() {
62  AtomicAdjust::inc(_global_modified);
63 }
static void inc(Integer &var)
Atomically increments the indicated variable.