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

Unified Diff: third_party/mojo/src/mojo/public/go/bindings/util.go

Issue 1019173002: Update mojo sdk to rev 7214b7ec7d27563b2666afad86cf1c5895c56c18 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep permission service alive if embedder drops requests Created 5 years, 9 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
Index: third_party/mojo/src/mojo/public/go/bindings/util.go
diff --git a/third_party/mojo/src/mojo/public/go/bindings/util.go b/third_party/mojo/src/mojo/public/go/bindings/util.go
index 7886fe3d6b281cc66d34071698473e498313be24..abbedb3fe04170c32dcc4aa0441abb431c64bde8 100644
--- a/third_party/mojo/src/mojo/public/go/bindings/util.go
+++ b/third_party/mojo/src/mojo/public/go/bindings/util.go
@@ -37,11 +37,24 @@ func StringPointer(s string) *string {
// Counter is a simple thread-safe lock-free counter that can issue unique
// numbers starting from 1 to callers.
-type Counter struct {
+type Counter interface {
+ // Count returns next unused value, each value is returned only once.
+ Count() uint64
+}
+
+// NewCounter return a new counter that returns numbers starting from 1.
+func NewCounter() Counter {
+ return &counterImpl{}
+}
+
+// counterImpl implements Counter interface.
+// This implementation uses atomic operations on an uint64, it should be always
+// allocated separatelly to be 8-aligned in order to work correctly on ARM.
+// See http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
+type counterImpl struct {
last uint64
}
-// Next returns next unused value, each value is returned only once.
-func (c *Counter) Next() uint64 {
+func (c *counterImpl) Count() uint64 {
return atomic.AddUint64(&c.last, 1)
}
« no previous file with comments | « third_party/mojo/src/mojo/public/go/bindings/stub.go ('k') | third_party/mojo/src/mojo/public/go/system/c_allocators.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698