For OGE, as we require high performance (it is for games), ive worked a fair bit on creating some atomic operations classes and a lock free queue as locks/mutexs are very expensive.
Looking through POCOs code, mutexs are used alot.
I have an AtomicOp template class which takes a type and inherits from AtomicOpBase. This takes a type and a size. each of the specialisations are for a given size (8, 16, 32 bits) and each use x86 assembly for the atomic code (operations like compare and swap, add, exchange and add, etc etc). The AtomicOp class automatically selects the correct base class dependant on the types size.
I also have an Atomic template class which allows you to store/modify etc a value inside it atomically. This is especially usefull for lock free, thread safe reference counting.
Lastly, i have an AtomicQueue, which is based on a various sources from the net (game programming gems code, and various other sites). ive tested this quite a bit, and had 100 threads pushing values onto it whilst another 100 threads were reading from it. at the end, no values were found to be corrupted or duplicated and no segfaults occurred etc. so i think it works fine.
Anyway, as OGE is now using POCO, we have discussed contributing our code so that POCO can benefit if you accept it. I havent looked at all of POCOs code, but a few places that might benefit is the SharedPtr class for reference counting (no mutexs/locks), and possibly the RWLock code. I might be wrong about this last one, but from a brief thought about it, could it be done using 1 mutex (only for write locking) and an Atomic< Int32 >? such as 0 is no locks, positive is read locks, negative 1 is a write lock (and then you lock the mutex).
The code is missing some parts that you would need. i havent developed this for GCC/MingW (sorry if i got this wrong, i only use VC), this requires a different way of writing the assembly? The code also needs to be formatted into the same style as POCO.
would you accept this contribution? and what do i need to do, such as should i (try to) format the code etc i would try to do as much as i can, although i do lack time.





