forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkTimeStamp.cxx
57 lines (49 loc) · 2.16 KB
/
vtkTimeStamp.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTimeStamp.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTimeStamp.h"
#include "vtkObjectFactory.h"
#include "vtkWindows.h"
#include <atomic>
//------------------------------------------------------------------------------
vtkTimeStamp* vtkTimeStamp::New()
{
// If the factory was unable to create the object, then create it here.
return new vtkTimeStamp;
}
//------------------------------------------------------------------------------
void vtkTimeStamp::Modified()
{
// Here because of a static destruction error? You're not the first. After
// discussion of the tradeoffs, the cost of adding a Schwarz counter on this
// static to ensure it gets destructed is unlikely to be worth the cost over
// just leaking it.
//
// Solutions and their tradeoffs:
//
// - Schwarz counter: each VTK class now has a static initializer function
// that increments an integer. This cannot be inlined or optimized away.
// Adds latency to ParaView startup.
// - Separate library for this static. This adds another library to VTK
// which are already legion. It could not be folded into a kit because
// that would bring you back to the same problem you have today.
// - Leak a heap allocation for it. It's 24 bytes, leaked exactly once, and
// is easily suppressed in Valgrind.
//
// The last solution has been decided to have the smallest downside of these.
//
// Good luck!
#if defined(VTK_USE_64BIT_TIMESTAMPS) || (VTK_SIZEOF_VOID_P == 8)
static std::atomic<uint64_t> GlobalTimeStamp(0U);
#else
static std::atomic<uint32_t> GlobalTimeStamp(0U);
#endif
this->ModifiedTime = (vtkMTimeType)++GlobalTimeStamp;
}