diff options
| author | Pietro Gagliardi <[email protected]> | 2015-12-21 14:26:09 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-12-21 14:26:09 -0500 |
| commit | 4b74894536813fbc8f59136a6f77a3d5f9af67eb (patch) | |
| tree | dedfa6110d88e9c439adfff5cd47656e325bfae3 | |
| parent | 01893daaf19c3617b65820a7e1febdfa02beb389 (diff) | |
Made QueueMain() immune to collisions.
| -rw-r--r-- | main.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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)) } |
