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

Unified Diff: third_party/mojo/src/mojo/public/go/bindings/async_waiter.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/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 ebe42cc57aa329ce4f50617c6cb40b234b794e1b..bcd4a7cd3e2223944949d96a114d31237245896c 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
@@ -6,6 +6,7 @@ package bindings
import (
"fmt"
+ "runtime"
"sync"
"sync/atomic"
@@ -86,7 +87,7 @@ type asyncWaiterWorker struct {
isNotified *int32
waitChan <-chan waitRequest // should have a non-empty buffer
cancelChan <-chan AsyncWaitId // should have a non-empty buffer
- ids Counter // is incremented each |AsyncWait()| call
+ ids uint64 // is incremented each |AsyncWait()| call
}
// removeHandle removes handle at provided index without sending response by
@@ -143,7 +144,8 @@ func (w *asyncWaiterWorker) processIncomingRequests() {
w.signals = append(w.signals, request.signals)
w.responses = append(w.responses, request.responseChan)
- id := AsyncWaitId(w.ids.Next())
+ w.ids++
+ id := AsyncWaitId(w.ids)
w.asyncWaitIds = append(w.asyncWaitIds, id)
request.idChan <- id
case AsyncWaitId := <-w.cancelChan:
@@ -211,6 +213,15 @@ type asyncWaiterImpl struct {
cancelChan chan<- AsyncWaitId // should have a non-empty buffer
}
+func finalizeWorker(worker *asyncWaiterWorker) {
+ // Close waking handle on worker side.
+ worker.handles[0].Close()
+}
+
+func finalizeAsyncWaiter(waiter *asyncWaiterImpl) {
+ waiter.wakingHandle.Close()
+}
+
// newAsyncWaiter creates an asyncWaiterImpl and starts its worker goroutine.
func newAsyncWaiter() *asyncWaiterImpl {
result, h0, h1 := system.GetCore().CreateMessagePipe(nil)
@@ -220,7 +231,7 @@ func newAsyncWaiter() *asyncWaiterImpl {
waitChan := make(chan waitRequest, 10)
cancelChan := make(chan AsyncWaitId, 10)
isNotified := new(int32)
- worker := asyncWaiterWorker{
+ worker := &asyncWaiterWorker{
[]system.Handle{h1},
[]system.MojoHandleSignals{system.MOJO_HANDLE_SIGNAL_READABLE},
[]AsyncWaitId{0},
@@ -228,15 +239,18 @@ func newAsyncWaiter() *asyncWaiterImpl {
isNotified,
waitChan,
cancelChan,
- Counter{},
+ 0,
}
+ runtime.SetFinalizer(worker, finalizeWorker)
go worker.runLoop()
- return &asyncWaiterImpl{
+ waiter := &asyncWaiterImpl{
wakingHandle: h0,
isWorkerNotified: isNotified,
waitChan: waitChan,
cancelChan: cancelChan,
}
+ runtime.SetFinalizer(waiter, finalizeAsyncWaiter)
+ return waiter
}
// wakeWorker wakes the worker from |WaitMany()| call. This should be called
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/src/types.dart ('k') | third_party/mojo/src/mojo/public/go/bindings/decoder.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698