12345678910111213141516171819202122232425262728293031323334353637 |
- package pipeline
- type RunToken struct {
- Result any
- Err error
- doneChan chan any
- }
- func NewRunToken() *RunToken {
- return &RunToken{
- Result: nil,
- Err: nil,
- doneChan: make(chan any),
- }
- }
- func (token *RunToken) Wait() {
- if token.doneChan == nil {
- return
- }
- for {
- select {
- case <-token.doneChan:
- return
- }
- }
- }
- func (token *RunToken) Done() {
- if token.doneChan == nil {
- return
- }
- close(token.doneChan)
- token.doneChan = nil
- }
|