3 ms·
This is probably a stupid question, but is the Canvas's DrawLine function thread-safe? It looks like multiple Nodes could be drawing to the same canvas at the s
by stevenbedrick 13y ago
This is probably a stupid question, but is the Canvas's DrawLine function thread-safe? It looks like multiple Nodes could be drawing to the same canvas at the same time, and I don't see any locks/mutexes/whatevers wrapping that call.
Obviously it can't be too much of a big deal, since the (very nifty) example works just fine, but I'm curious about what's going on here.
- icebraining 13y agoI'm a noob at concurrent programming, but from what I can tell, the only concurrent mutation is when setting the pixels, in image.go: 94 p.Pix[i+0] = c1.R 95 p.Pix[i+1] = c1.G 96 p.Pix[i+2] = c1.B 97 p.Pix[i+3] = c1.A IIRC, copying a single byte is safe, so what could happen is that you could end up with weird pixels, if two nodes were setting the same pixel at the same time.