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

Unified Diff: Source/core/dom/LockManager.h

Issue 148283013: Blink JavaScript shared memory prototype. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaks Created 6 years, 6 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 | « Source/core/core.gypi ('k') | Source/core/dom/LockManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/LockManager.h
diff --git a/Source/core/dom/MessageChannel.h b/Source/core/dom/LockManager.h
similarity index 57%
copy from Source/core/dom/MessageChannel.h
copy to Source/core/dom/LockManager.h
index 5b1dc49a04fac99bcb7d28eca14def9f13cbb13a..b4ec53fa55d5a6eebe6a29389db4fa56ae25c018 100644
--- a/Source/core/dom/MessageChannel.h
+++ b/Source/core/dom/LockManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2014 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,34 +24,69 @@
*
*/
-#ifndef MessageChannel_h
-#define MessageChannel_h
+#ifndef LockManager_h
+#define LockManager_h
#include "bindings/v8/ScriptWrappable.h"
+#include "wtf/HashMap.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
+#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/ThreadingPrimitives.h"
namespace WebCore {
-class MessagePort;
class ExecutionContext;
-class MessageChannel : public RefCounted<MessageChannel>, public ScriptWrappable {
+class LockInfo;
+
+typedef WTF::HashMap<uint32_t, LockInfo*> LockHashMap;
+
+class LockShard {
public:
- static PassRefPtr<MessageChannel> create(ExecutionContext* context) { return adoptRef(new MessageChannel(context)); }
- ~MessageChannel();
+ ~LockShard();
+
+ LockInfo* get(uint32_t uid);
+
+ Mutex mutex;
+private:
+ LockHashMap locks;
+};
+
+#define SHARD_BITS 5
+#define NUM_SHARDS (1 << SHARD_BITS)
+#define SHARD_MASK (NUM_SHARDS-1)
+
+class LockManagerImpl FINAL : public ThreadSafeRefCounted<LockManagerImpl> {
+public:
+ void lock(uint32_t uid);
+ void unlock(uint32_t uid);
+
+private:
+ LockShard shards[NUM_SHARDS];
+};
+
+class LockManager FINAL : public RefCounted<LockManager>
+ , public ScriptWrappable {
+public:
+ static PassRefPtr<LockManager> create(ExecutionContext* context)
+ {
+ return adoptRef(new LockManager(context));
+ }
+
+ void lock(unsigned long uid);
+ void unlock(unsigned long uid);
- MessagePort* port1() const { return m_port1.get(); }
- MessagePort* port2() const { return m_port2.get(); }
+ // HACK for performance testing.
+ void nop();
private:
- explicit MessageChannel(ExecutionContext*);
+ explicit LockManager(ExecutionContext*);
- RefPtr<MessagePort> m_port1;
- RefPtr<MessagePort> m_port2;
+ RefPtr<LockManagerImpl> impl;
};
} // namespace WebCore
-#endif // MessageChannel_h
+#endif // LockManager_h
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/dom/LockManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698