Can't think of a good name for this customized event class [closed]
First, I wrote 开发者_运维技巧a class which wraps a Windows API Event (using Wait
to wrap WaitForSingleObject, Set()
to wrap SetEvent()
, etc). I called it CEvent
and was satisfied.
Now I created a class which extends CEvent, adding the functionality to count how many times the event was set, and expose that value with a getCount()
property. With this, clients can perform as many Wait()
's as Set()
's.
Two questions, actually:
This sounds like some special synchronization construct I recall studying in my Concurrent Programming class, but that was ages ago and I'm not sure. Anybody knows if this is so, and if it is, how is this construct called?
I named my class
CCountedEvent
. Is this a good name?
An old saying is "a class does not do something, it is something". In that context, CEvent might be a good name, but only if an object of the class is an event (which I doubt).
I would suggest using EventHandler and CountingEventHandler.
精彩评论