I have class A providing bitmaps to other classes B, C, etc.
Class A now holds its bitmaps in a ring queue, so after a while it will lose the link to the bitmap.
While it is still in the queue, one bitmap can be checked by several classes, so, say, B and C can contain a link to the same bitmap. But it can also happen that only one of them checks the bitmap or even none of them.
I would like to get rid of the bitmap when it is no longer needed by either A, B, or C.
I believe that I should make B and C responsible for somehow signaling when they finished using it, but I'm not sure about the general logic.
If this is a call to call DisposeIfNowOrphan (), which will be called three times in this example:
1 - when the bitmap is unloaded from the queue in class A
2 - when B is finished with it
3 - when C finished with him
If this is the best strategy, how can I assess the condition of orphans?
Any advice would be appreciated.
source share