Skip to content

Commit

Permalink
make reading a map
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 17, 2024
1 parent 897c043 commit b97c690
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type task struct {
id int
f func() error
// reading are the tasks that this task is using non-exclusively.
reading []*task
reading map[int]*task

l sync.Mutex
executed bool
Expand Down Expand Up @@ -147,7 +147,7 @@ func (e *Executor) Run(keys state.Keys, f func() error) {
t := &task{
id: id,
f: f,
reading: []*task{},
reading: make(map[int]*task),

blocked: make(map[int]*task),
readers: make(map[int]*task),
Expand All @@ -170,7 +170,9 @@ func (e *Executor) Run(keys state.Keys, f func() error) {
if v == state.Read {
// If we don't need exclusive access to a key, just mark
// that we are reading it and that we are a reader of it.
t.reading = append(t.reading, lt)
// TODO: currently a no-op when we add ourself multiple times
// but find a better way of handling [reading]
t.reading[lt.id] = lt
lt.readers[id] = t
} else {
// If we do need exclusive access to a key, we need to
Expand Down

0 comments on commit b97c690

Please sign in to comment.