aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/once.cc
diff options
context:
space:
mode:
authorGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-18 08:21:00 +0000
committerGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-18 08:21:00 +0000
commitbdbb863099c7ef3e1ecdeefa732798e095b85fb8 (patch)
tree221b358332016ecb81d2da4f7529be0cdaef1e1f /src/google/protobuf/stubs/once.cc
parent91218afc67773ebf85e37d91c80cb3a7d423b0ba (diff)
Ensure that 'once' objects are declared using the macro. This is either the third or fourth time I've screwed this up when down-integrating, because our internal code does not require the macro (it's not portable) and on Linux a pthread_once_t that is zero-initialized just happens to work. So, I only discover the problem when I test on Mac, then kick myself for making the same mistake yet again. No more! This time, I have renamed GoogleOnceType to ProtobufOnceType, thus making the type name differ from our internal code. As a result, if you don't update the decls to use the macros, they won't compile. Hah! Take that, future self!
Diffstat (limited to 'src/google/protobuf/stubs/once.cc')
-rw-r--r--src/google/protobuf/stubs/once.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/google/protobuf/stubs/once.cc b/src/google/protobuf/stubs/once.cc
index 3c53bcd7..5b7af9ce 100644
--- a/src/google/protobuf/stubs/once.cc
+++ b/src/google/protobuf/stubs/once.cc
@@ -46,33 +46,33 @@ namespace protobuf {
#ifdef _WIN32
-struct GoogleOnceInternal {
- GoogleOnceInternal() {
+struct ProtobufOnceInternal {
+ ProtobufOnceInternal() {
InitializeCriticalSection(&critical_section);
}
- ~GoogleOnceInternal() {
+ ~ProtobufOnceInternal() {
DeleteCriticalSection(&critical_section);
}
CRITICAL_SECTION critical_section;
};
-GoogleOnceType::~GoogleOnceType()
+ProtobufOnceType::~ProtobufOnceType()
{
delete internal_;
internal_ = NULL;
}
-GoogleOnceType::GoogleOnceType() {
+ProtobufOnceType::ProtobufOnceType() {
// internal_ may be non-NULL if Init() was already called.
- if (internal_ == NULL) internal_ = new GoogleOnceInternal;
+ if (internal_ == NULL) internal_ = new ProtobufOnceInternal;
}
-void GoogleOnceType::Init(void (*init_func)()) {
+void ProtobufOnceType::Init(void (*init_func)()) {
// internal_ may be NULL if we're still in dynamic initialization and the
// constructor has not been called yet. As mentioned in once.h, we assume
// that the program is still single-threaded at this time, and therefore it
// should be safe to initialize internal_ like so.
- if (internal_ == NULL) internal_ = new GoogleOnceInternal;
+ if (internal_ == NULL) internal_ = new ProtobufOnceInternal;
EnterCriticalSection(&internal_->critical_section);
if (!initialized_) {