<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                Context與任務的取消 === 一個任務有起了多個子任務 ![](https://box.kancloud.cn/ebd80a55a0f8ea09ea9213126a392969_1031x306.png) - 根Context: 通過context.Background() 創建 - 子`Context context.WithCancel(父context)`創建 - `ctx, cancel := context.WithCancel(context.Background())` - 當前Context被取消時,基于他的子context都會被取消 - 接受取消通知`<-ctx.Done()` ~~~ func TestService(t *testing.T) { dataCh := make(chan int,10) end := make(chan bool) ctx, cancel := context.WithCancel(context.Background()) go production(dataCh,cancel) go consume(ctx,dataCh,end) <-end } // 生產者 func production(ch chan int,cancelFunc context.CancelFunc) { for i:=0;i<1000;i++{ ch<-i } cancelFunc() } // 消費者 func consume(ctx context.Context,ch chan int,end chan bool) { forloop: for { select { case data := <-ch: fmt.Println(data) case <-ctx.Done(): fmt.Println("end------------------") break forloop } } end<-true } ~~~ 這個例子沒有舉好,大家先知道怎么用
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看