diff options
Diffstat (limited to 'internal/events/event.go')
-rw-r--r-- | internal/events/event.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/events/event.go b/internal/events/event.go new file mode 100644 index 0000000..4412bbb --- /dev/null +++ b/internal/events/event.go @@ -0,0 +1,36 @@ +package events + +import ( + "sync" +) + +type Event interface { + Contains(int) bool + Processed() + WaitForProcessed() +} + +type EventStruct struct { + code int + lock sync.Mutex +} + +func (event EventStruct) Contains(code int) bool { + return event.code&code != 0 +} + +func (event *EventStruct) WaitForProcessed() { + event.lock.Lock() +} + +func (event *EventStruct) Processed() { + event.lock.Unlock() +} + +func NewEvent(code int) Event { + event := &EventStruct{ + code: code, + } + event.lock.Lock() + return event +} |