A proposed new class, currently in 8.1. It allows for resource counting where the decrement is implicit by tieing it to the destruction of a key object that you got when incrementing.
The implementation has already been battle-tested in pgsql in 8.1.
Any suggestions related to functionality, interface and/or naming? As far as I could determine, there does not seem to be any established name for this kind of object. It's related to a semaphore, but it does things markedly different.
Because it allows me to get rid of some convoluted code in pgsql, and because it automatically solves (if any) remaining races related to asynchronous destruction of objects; I'd like to use this class in 8.0 as well (in order to keep the pgsql driver in sync between 8.0 and 8.1).
Any objections if I add this to 8.0?
Sounds good. I first wondered what the relationship is to Thread, but the source code comments mentions that one can block a thread on the counter value so it probably fits that it's placed in that namespace.
I wonder if RefCount would be a more suitable name though? Not a strong opinion either way so we can see if anyone else has any preference.
It basically does not make sense in a non-multithreaded environment, which is why the natural place is in the Thread namespace.
With regard to RefCount as a name: yes that would fit, but might lead to confusion with the internal refcounter on all Pike objects.
pike-devel@lists.lysator.liu.se