summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.go b/main.go
index 5f8f624..de7b1ca 100644
--- a/main.go
+++ b/main.go
@@ -83,8 +83,14 @@ func QueueMain(f func()) {
qmlock.Lock()
defer qmlock.Unlock()
- n := qmcurrent
- qmcurrent++
+ n := uintptr(0)
+ for {
+ n = qmcurrent
+ qmcurrent++
+ if qmmap[n] == nil {
+ break
+ }
+ }
qmmap[n] = f
C.realQueueMain(unsafe.Pointer(n))
}