summaryrefslogtreecommitdiffhomepage
path: root/internal/events/event.go
blob: 4412bbb098acdfd46e71c0b328a18d2503c1d269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}