Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: ipc/ipc_sync_message.cc

Issue 9297009: Remove static initializer in dummy_event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stupid copy-and-paste error Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698