Skip to content

Commit

Permalink
world/entity.go: Completed documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Dec 24, 2024
1 parent 21950f3 commit 01fc167
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/world/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ func (e *EntityHandle) UUID() uuid.UUID {
}

// Close closes the EntityHandle. Any subsequent call to ExecWorld will return
// immediately without the transaction function being called.
// immediately without the transaction function being called. Close always
// returns nil.
func (e *EntityHandle) Close() error {
e.setAndUnlockWorld(closeWorld)
return nil
Expand All @@ -153,8 +154,9 @@ func (e *EntityHandle) ExecWorld(f func(tx *Tx, e Entity)) (run bool) {
}

// execWorld uses a sync.Cond to synchronise access to the handler's world. We
// are dealing with a rather complicated synchronisation pattern here.
// The summary is as follows: The goal for ExecWorld is to block
// are dealing with a rather complicated synchronisation pattern here. The goal
// for ExecWorld is to block until e.w becomes accessible. Meanwhile, World.Exec
// may also affect e.w, which execWorld needs to deal with.
func (e *EntityHandle) execWorld(f func(tx *Tx, e Entity), weak bool) bool {
e.cond.L.Lock()
for e.w == nil || (!weak && e.weakTxActive) {
Expand Down

0 comments on commit 01fc167

Please sign in to comment.