Index: ipc/ipc_sync_message.cc |
diff --git a/ipc/ipc_sync_message.cc b/ipc/ipc_sync_message.cc |
index e276263458f3c228d4644647b50274a766646552..162648d8abfe8e97c1a3cf6f3fac06c82ac623be 100644 |
--- a/ipc/ipc_sync_message.cc |
+++ b/ipc/ipc_sync_message.cc |
@@ -10,18 +10,32 @@ |
#include <stack> |
#include "base/atomic_sequence_num.h" |
+#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/synchronization/waitable_event.h" |
#include "ipc/ipc_sync_message.h" |
+namespace { |
+ |
+struct WaitableEventLazyInstanceTraits |
+ : public base::DefaultLazyInstanceTraits<base::WaitableEvent> { |
+ static base::WaitableEvent* New(void* instance) { |
+ // Use placement new to initialize our instance in our preallocated space. |
+ return new (instance) base::WaitableEvent(true, true); |
+ } |
+}; |
+ |
+static base::LazyInstance<base::WaitableEvent, WaitableEventLazyInstanceTraits> |
Nico
2012/02/03 23:02:16
Can you make this ::Lazy? As is, this adds an exit
|
+ dummy_event = LAZY_INSTANCE_INITIALIZER; |
+ |
+} |
+ |
namespace IPC { |
#define kSyncMessageHeaderSize 4 |
static base::AtomicSequenceNumber g_next_id(base::LINKER_INITIALIZED); |
-static base::WaitableEvent* dummy_event = new base::WaitableEvent(true, true); |
- |
SyncMessage::SyncMessage( |
int32 routing_id, |
uint32 type, |
@@ -50,7 +64,7 @@ MessageReplyDeserializer* SyncMessage::GetReplyDeserializer() { |
void SyncMessage::EnableMessagePumping() { |
DCHECK(!pump_messages_event_); |
- set_pump_messages_event(dummy_event); |
+ set_pump_messages_event(dummy_event.Pointer()); |
} |
bool SyncMessage::IsMessageReplyTo(const Message& msg, int request_id) { |