4 ms·
A very important gotcha with this approach is that any variable named "i" will be reset to 0 inside of the lock, and modifying "i" inside of the lock can cause
by 8_hours_ago 13y ago
A very important gotcha with this approach is that any variable named "i" will be reset to 0 inside of the lock, and modifying "i" inside of the lock can cause an infinite loop.
This can be mitigated by generating a unique variable name with the C preprocessor: http://stackoverflow.com/questions/1132751/how-can-i-generate-unique-values-in-the-c-preprocessor http://stackoverflow.com/questions/1132751/how-can-i-generat...
That being said, it's much better to use a standard method of scoped locking instead of trying to reinvent the wheel.