(C <-chan struct{}, clock ktime.SampledClock, deadline ktime.Time)
| 119 | } |
| 120 | |
| 121 | func (t *Task) blockWithDeadlineFromSampledClock(C <-chan struct{}, clock ktime.SampledClock, deadline ktime.Time) error { |
| 122 | // Start the timeout timer. |
| 123 | t.blockingTimer.SetClock(clock, ktime.Setting{ |
| 124 | Enabled: true, |
| 125 | Next: deadline, |
| 126 | }) |
| 127 | |
| 128 | err := t.block(C, t.blockingTimerChan) |
| 129 | |
| 130 | // Stop the timeout timer and drain the channel. If s.Enabled is true, the |
| 131 | // timer didn't fire yet, so t.blockingTimerChan must be empty. |
| 132 | if _, s := t.blockingTimer.Set(ktime.Setting{}, nil); !s.Enabled { |
| 133 | select { |
| 134 | case <-t.blockingTimerChan: |
| 135 | default: |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | return err |
| 140 | } |
| 141 | |
| 142 | // Block implements context.Context.Block |
| 143 | // |
no test coverage detected