It's easy to do when the arch provides atomic_inc_return().
Attach a file by drag & drop or click to upload