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

Unified Diff: third_party/mojo/src/mojo/public/go/bindings/async_waiter.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/async_waiter.go
diff --git a/third_party/mojo/src/mojo/public/go/bindings/async_waiter.go b/third_party/mojo/src/mojo/public/go/bindings/async_waiter.go
index 15fd82278c01ade60dd13ece79c5655ccbcdc62e..ebe42cc57aa329ce4f50617c6cb40b234b794e1b 100644
--- a/third_party/mojo/src/mojo/public/go/bindings/async_waiter.go
+++ b/third_party/mojo/src/mojo/public/go/bindings/async_waiter.go
@@ -12,15 +12,15 @@ import (
"mojo/public/go/system"
)
-var waiter *asyncWaiterImpl
+var defaultWaiter *asyncWaiterImpl
var once sync.Once
// GetAsyncWaiter returns a default implementation of |AsyncWaiter| interface.
func GetAsyncWaiter() AsyncWaiter {
once.Do(func() {
- waiter = newAsyncWaiter()
+ defaultWaiter = newAsyncWaiter()
})
- return waiter
+ return defaultWaiter
}
// AsyncWaitId is an id returned by |AsyncWait()| used to cancel it.
@@ -86,7 +86,7 @@ type asyncWaiterWorker struct {
isNotified *int32
waitChan <-chan waitRequest // should have a non-empty buffer
cancelChan <-chan AsyncWaitId // should have a non-empty buffer
- lastUsedId AsyncWaitId // is incremented each |AsyncWait()| call
+ ids Counter // is incremented each |AsyncWait()| call
}
// removeHandle removes handle at provided index without sending response by
@@ -143,8 +143,7 @@ func (w *asyncWaiterWorker) processIncomingRequests() {
w.signals = append(w.signals, request.signals)
w.responses = append(w.responses, request.responseChan)
- w.lastUsedId++
- id := w.lastUsedId
+ id := AsyncWaitId(w.ids.Next())
w.asyncWaitIds = append(w.asyncWaitIds, id)
request.idChan <- id
case AsyncWaitId := <-w.cancelChan:
@@ -229,7 +228,7 @@ func newAsyncWaiter() *asyncWaiterImpl {
isNotified,
waitChan,
cancelChan,
- 0,
+ Counter{},
}
go worker.runLoop()
return &asyncWaiterImpl{
@@ -244,7 +243,10 @@ func newAsyncWaiter() *asyncWaiterImpl {
// after sending a message to |waitChan| or |cancelChan| to avoid deadlock.
func (w *asyncWaiterImpl) wakeWorker() {
if atomic.CompareAndSwapInt32(w.isWorkerNotified, 0, 1) {
- w.wakingHandle.WriteMessage([]byte{0}, nil, system.MOJO_WRITE_MESSAGE_FLAG_NONE)
+ result := w.wakingHandle.WriteMessage([]byte{0}, nil, system.MOJO_WRITE_MESSAGE_FLAG_NONE)
+ if result != system.MOJO_RESULT_OK {
+ panic("can't write to a message pipe")
+ }
}
}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/src/stub.dart ('k') | third_party/mojo/src/mojo/public/go/bindings/connector.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698