This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
“sync" | |
) | |
type Player struct { | |
sync.Mutex | |
Health int | |
} | |
func (p *Player) DecreaseHealthPoint(damageTaken int) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
“sync" | |
) | |
// TokenRevocationRecord represents the token revocation list record | |
type TokenRevocationRecord struct {} | |
// TokenRevocationListCache | |
type TokenRevocationListCache struct { | |
TokenRevocationList map[string]TokenRevocationRecord | |
sync.Mutex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MatchMaker {} | |
func (m *MatchMaker) CreateMatch(game *Game, party *Party) bool { | |
var serverStatusChan chan bool | |
gameSessionStatusChan := m.RequestGameSession(game, party) // gameSessionStatusChan returns a channel for signaling the status request. | |
fmt.Println(“Trying to request game session . . .”) | |
return <- serverStatusChan // It returns whatever the result asynchronous result operation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StreamProcessor struct {} | |
func (sp *StreamProcessor) Consume(fn func(r *Record) error) { | |
for { | |
records, _ := sp.GetRecords() // error is not handled for simplicity purpose | |
for _, r := range records { | |
go handleRecord(fn, r) // distributing task across goroutines. the output channel is not included for simplicity purpose | |
} | |
} | |
} |