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

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

Issue 975973002: Update mojo sdk to rev f68e697e389943cd9bf9652397312280e96b127a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shake fist at msvc Created 5 years, 10 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 8d51ddb721cabec0606d38096ba7b2893ef3c28c..7886fe3d6b281cc66d34071698473e498313be24 100644
--- a/third_party/mojo/src/mojo/public/go/bindings/util.go
+++ b/third_party/mojo/src/mojo/public/go/bindings/util.go
@@ -4,6 +4,13 @@
package bindings
+import (
+ "fmt"
+ "sync/atomic"
+
+ "mojo/public/go/system"
+)
+
func align(size, alignment int) int {
return ((size - 1) | (alignment - 1)) + 1
}
@@ -14,7 +21,27 @@ func bytesForBits(bits uint64) int {
return int((bits + 7) / 8)
}
+// WriteMessage writes a message to a message pipe.
+func WriteMessage(handle system.MessagePipeHandle, message *Message) error {
+ result := handle.WriteMessage(message.Bytes, message.Handles, system.MOJO_WRITE_MESSAGE_FLAG_NONE)
+ if result != system.MOJO_RESULT_OK {
+ return fmt.Errorf("error writing message: %v", result)
+ }
+ return nil
+}
+
// StringPointer converts provided string to *string.
func StringPointer(s string) *string {
return &s
}
+
+// Counter is a simple thread-safe lock-free counter that can issue unique
+// numbers starting from 1 to callers.
+type Counter struct {
+ last uint64
+}
+
+// Next returns next unused value, each value is returned only once.
+func (c *Counter) Next() 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/mojo_types.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698