@startuml
hide empty description

state Dequeue {
  left to right direction
  [*] --> wait_d
  wait_d --> dequeueing: ?dequeue
  dequeueing --> wait_d: [cap > 0] / pop item
}

state DequeueTimer {
  left to right direction
  [*] --> timer
  timer --> raise: after dd s [cap > 0]
  raise --> timer: always / !dequeue
}

state Enqueue {
  left to right direction
  [*] --> wait_e
  wait_e --> enqueueing: ?enqueue
  enqueueing --> wait_e: [cap < K] / append item
  enqueueing --> enqueueing: [cap >= K] / !overflow
}
@enduml
