exec::start_now: request_stop() on the storage does not reach the senders

已關閉
#2,416 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

已經有一個關聯 PR 被合併了。

  • #2417 來自 @Nas01010101 —— 已合併

評估

難度
3/5
預估耗時
1-2 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
cpp
領域
backend

研究方向

Read include/exec/async_scope.hpp around __nest_receiver::get_env and include/exec/start_now.hpp around __storage and __receiver to trace which stop token reaches the sender. Then inspect test/exec/async_scope/test_start_now.cpp and add coverage for calling storage.request_stop(); done means the test observes the sender stop instead of run. Pull request #2417 is already open for this issue.

由索引模型根據 Issue 內容生成。

描述

exec::start_now returns a storage object with request_stop() and get_token(), but a stop request on that object never reaches the started senders. request_stop() returns true and the senders keep running.

Reproducer

#include <stdexec/execution.hpp>
#include <exec/async_scope.hpp>
#include <exec/start_now.hpp>
#include <cstdio>

namespace ex = stdexec;

int main() {
  ex::run_loop loop;
  exec::async_scope scope;
  bool ran = false;
  bool stopped = false;

  auto storage = exec::start_now(
    scope,
    ex::schedule(loop.get_scheduler())
      | ex::then([&]() noexcept { ran = true; })
      | ex::upon_stopped([&]() noexcept { stopped = true; }));

  bool accepted = storage.request_stop();
  loop.finish();
  loop.run();
  ex::sync_wait(scope.on_empty());
  std::printf("request_stop=%d ran=%d stopped=%d\n", accepted, ran, stopped);
}

Expected: request_stop=1 ran=0 stopped=1

Actual: request_stop=1 ran=1 stopped=0

Tested on main at 081ab7fc with clang 21.1.8 and g++ 14. Calling scope.request_stop() instead of storage.request_stop() does stop the sender, so the run loop's scheduler honors stop requests in this program.

Cause

__storage puts its own token in the environment of __receiver, and then wraps each sender with __scope.nest(...). __nest_receiver::get_env in include/exec/async_scope.hpp overrides get_stop_token with the scope's token, so the sender only ever sees the scope's token. The token from __storage::get_token() compares unequal to the one the sender reads.

test/exec/async_scope/test_start_now.cpp has no test that calls request_stop().

主要語言
C++
星號
2.5k
分支
284
平均合併
1 天 21 小時
30 天內合併 PR
92

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NVIDIA/stdexec 的其他 Issue

查看 NVIDIA/stdexec 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。