From 4b74894536813fbc8f59136a6f77a3d5f9af67eb Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 21 Dec 2015 14:26:09 -0500 Subject: [PATCH] Made QueueMain() immune to collisions. --- main.go | 10 ++++++++-- 1 file 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)) }