Should be goroutine/threadsafe Only reads from world channel
(shutdown chan bool, wg *sync.WaitGroup)
| 464 | // Should be goroutine/threadsafe |
| 465 | // Only reads from world channel |
| 466 | func (w *World) InputWorker(shutdown chan bool, wg *sync.WaitGroup) { |
| 467 | wg.Add(1) |
| 468 | |
| 469 | mudlog.Info("InputWorker", "state", "Started") |
| 470 | defer func() { |
| 471 | mudlog.Warn("InputWorker", "state", "Stopped") |
| 472 | wg.Done() |
| 473 | }() |
| 474 | |
| 475 | loop: |
| 476 | for { |
| 477 | select { |
| 478 | case <-shutdown: |
| 479 | mudlog.Warn(`InputWorker`, `action`, `shutdown received`) |
| 480 | break loop |
| 481 | case wi := <-w.worldInput: |
| 482 | |
| 483 | events.AddToQueue(events.Input{ |
| 484 | UserId: wi.FromId, |
| 485 | InputText: wi.InputText, |
| 486 | ReadyTurn: util.GetTurnCount(), |
| 487 | }) |
| 488 | |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | func (w *World) processInput(userId int, inputText string, flags events.EventFlag) { |
| 494 |
no test coverage detected