BehaviorTree.CPP: Task Planning for Robots and Virtual Agents
We need a system Orchestrator to implement the robot behaviorRobot Behaviors This Coordinator or Task Planner is also the highest level of abstraction of our system, where we focus on WHAT the robot0 码力 | 59 页 | 7.97 MB | 5 月前3Rethinking Task Based Concurrency and Parallelism for Low Latency C++
used when we created them.” - Albert EinsteinSo what is there to Rethink?Rethinking: Task Queues Problem #1 - Task Queues Do Not Scale Well: ● Contention: ○ Even the most meticulously designed lock-free problems: ○ Task starvation ○ Load balancing ○ Forfeits strict FIFO behaviour ○ Increases memory footprint (or requires allocations) ○ Terrible task selection “fairness” Task Thread Thread Thread Task Task Task Task Task Task Task Task Back Front Task Queue Execute Task() Thread Thread PoolRethinking: Task Queues Problem #2 - No Inherent Support For Prioritization: ● Priority queues address this but0 码力 | 142 页 | 2.80 MB | 5 月前3Taro: Task graph-based Asynchronous Programming Using C++ Coroutine
in a top-down task graph What is Task Graph-based Programming System (TGPS) Code 4• TGPS encapsulates function calls and their dependencies in a top-down task graph What is Task Graph-based Programming top-down task graph What is Task Graph-based Programming System (TGPS) Code A B C D B A C D 6• TGPS encapsulates function calls and their dependencies in a top-down task graph What is Task Graph-based sched; 2 task_a = sched.emplace([](&){ 3 // Code block A; 4 }); 5 task_b = sched.emplace([](&){ 6 // Code block B; 7 }); 8 task_c = sched.emplace([](&){ 9 // Code block C; 10 }); 11 task_d = sched0 码力 | 84 页 | 8.82 MB | 5 月前3How Meta Made Debugging Async Code Easier with Coroutines and Senders
unifex::static_thread_pool pool; io_uring_context ctx; unifex::tasktask = async_main({argv + 1, argc - 1}, pool, ctx); unifex::sync_wait(std::move(task)); return 0; }int main(int argc, char** argv) { unifex::static_thread_pool pool; io_uring_context ctx; unifex::task task = async_main({argv + 1, argc - 1}, pool, ctx); unifex::sync_wait(std::move(task)); return 0; }int main(int argc, char** argv) { unifex::static_thread_pool pool; io_uring_context ctx; unifex::task task = async_main({argv + 1, argc - 1}, pool, ctx); unifex::sync_wait(std::move(task)); return 0; }int main(int argc, char** argv) { 0 码力 | 131 页 | 907.41 KB | 5 月前3Coroutines and Structured Concurrency in Practice
careA typical async framework class Task { ... } represents a unit of background work Task::join() explicit call to suspend the current task until another task completes, and returns its result propagates uncaught exceptions Task::detach() allows the task to run alongside the rest of the programDetached tasks considered harmful // don’t do this void bad(tcp::socket& s) { std::arrayasio::use_awaitable); }, asio::detached); } No way to figure out task lifetime => no automatic object lifetime managementDetached tasks considered harmful // don’t do 0 码力 | 103 页 | 1.98 MB | 5 月前3Building a Coroutine-Based Job System Without Standard Library
understanding the general behavior only. templatestruct task; task sum(int a, int b) { int result = a + b; co_return result; } task sum4(int a, int b, int c, int d) { int ab = co_await initial_suspend_awaitable_t initial_suspend_awaitable; final_suspend_awaitable_t final_suspend_awaitable; }; }; task sum(int a, int b) { auto frame = make_unique<__sum_frame>(a, b); decltype(auto) returnObject release())); return returnObject; } template struct task; task sum(int a, int b) { int result = a + b; co_return result; } task sum4(int a, int b, int c, int d) { int ab = co_await 0 码力 | 120 页 | 2.20 MB | 5 月前3Back to Basics: Designing Classes (part 2 of 2)
Qualified/Modified Member Data Visibility vs. AccessibilityData Member Initialization 6 Interactive Task: What is the initial value of the three data members i, s, and pi? struct Widget { int i; Default initialization: Calls // the default constructorData Member Initialization 8 Interactive Task: What is the initial value of the three data members i, s, and pi? struct Widget { int i; means of an empty set of braces (value initialization).Data Member Initialization 11 Interactive Task: What is the initial value of the three data members i, s, and pi? struct Widget { Widget()0 码力 | 76 页 | 2.60 MB | 5 月前3Working with Asynchrony Generically: A Tour of C++ Executors
extern unifex::static_thread_pool low_latency; extern unifex::static_thread_pool workers; unifex::taskaccept_and_process_requests() { while (true) { auto request = co_await ex::on(low_latency { ex::set_done((R&&) r_); } };42 SENDERS AND COROUTINES43 // This is a coroutine: unifex::task read_socket_async(socket, span ); int main() { socket s = /*...*/; char buff[1024]; in a coroutine type trivially. // This is a coroutine: unifex::task read_socket_async(socket, span ); unifex::task concurrent_read_async(socket s1, socket s2) { char buff1[1024]; 0 码力 | 121 页 | 7.73 MB | 5 月前3Get off my thread: Techniques for moving k to background threads
prevent blocking on our event-handling threads. void event_handler(){ auto handle=spawn_background_task(); handle.wait(); // no benefit }Aside: Non-Blocking vs Lock-free In lots of cases, short-term blocking short-lived std::mutex locks) is OK. ⇒ for those cases, Non-Blocking means Not waiting for a lengthy task to run.Aside: Non-Blocking vs Lock-free In lots of cases, short-term blocking (e.g. with short-lived Not waiting for a lengthy task to run. In other cases, Non-Blocking means Obstruction Free — If you suspend all but one thread at any point, that one thread will complete its task. ⇒ for those cases, you0 码力 | 90 页 | 6.97 MB | 5 月前3Coroutine Patterns and How to Use Them: Problems and Solutions Using Coroutines in a Modern Codebase
Them - CppCon 2023 8Overview Key concepts • Task • Executor Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon 2023 9Overview – Task • Owns the coroutine state • Lazy • Convertible executor Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon 2023 10Overview – Task - Lazy Task<> foo() { println(“Hello”); co_await sleep(1); } auto t = foo(); println(“world”); co_await Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon 2023 13Overview – Executor Task<> foo() { int a = 42; a -= 10; int bytes = co_await send(a); if (bytes == -1 ) { handle_error();0 码力 | 70 页 | 1.45 MB | 5 月前3
共 121 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
相关搜索词
BehaviorTreeCPPTaskPlanningforRobotsandVirtualAgentsRethinkingBasedConcurrencyParallelismLowLatencyC++TarographbasedAsynchronousProgrammingUsingCoroutineHowMetaMadeDebuggingAsyncCodeEasierwithCoroutinesSendersStructuredinPracticeBuildingJobSystemWithoutStandardLibraryBacktoBasicsDesigningClassespartofWorkingAsynchronyGenericallyTourExecutorsGetoffmythreadTechniquesmovingbackgroundthreadsPatternsUseThemProblemsSolutionsModernCodebase