How Meta Made Debugging Async Code Easier with Coroutines and Senders
… … Stack Traces for Async Code are Unhelpful Threadpool threads: #0 process_file(...) #5 pool.run() #10 __clone … … IO Thread: #0 async_read_some_at(...) #3 ctx Threadpool threads: #0 process_file(...) #5 pool.run() #10 … IO Thread: … #0 async_read_some_at(...) #3 ctx.run() #5 __clone … … Main thread: #0 unifex::sync_wait( … #0 async_read_some_at(...) … #12 unifex::sync_wait(...) #16 main() #19 __libc_start_main() … … Async Stacks are BetterStructured Concurrency Makes Async Stacks Possible0 码力 | 131 页 | 907.41 KB | 5 月前3Deciphering C++ Coroutines
Cheat Sheet - Awaitable 1 struct Awaitable { 2 bool await_ready (); 3 auto await_suspend (std:: coroutine_handle < promise_type >); 4 auto await_resume (); 5 };12/55 Cheat Sheet: Map of Coroutine Land13/55 Task18/55 Threads - A straightforward solution std::futurespawn_task () { return std:: async( outer_function ); }18/55 Threads - A straightforward solution main() spawn task()18/55 Threads auto data = co_await async_io (...); co_return IoResult :: from_io_data(data ); }24/55 Suspending nested coroutines Async inner_function () { auto data = co_await async_io (...); co_return 0 码力 | 156 页 | 1.79 MB | 5 月前3Coroutines and Structured Concurrency in Practice
demonstrated to justify switchingCallbacks vs coroutines // read length auto len = make_unique(); async_read(socket, buffer(len.get(), sizeof(int32_t)), [len = move(len)](auto ec, size_t len1){ && len1 == sizeof(int32_t)) { // read data auto buf = make_unique (*len); async_read(socket, buffer(buf.get(), *len), [buf = move(buf), len = *len] (auto // read length int32_t len; co_await async_read(s, buffer(&len, sizeof(len)), use_awaitable); // read data auto buf = make_unique (len); co_await async_read(s, buffer(buf.get(), len) 0 码力 | 103 页 | 1.98 MB | 5 月前3Comprehensive Rust(Persian ) 202412
. . . . . . . 351 XIV � � � � � � � : � � � 357 63 � � � � � � � � 358 64 � � � � � Async 359 64.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 64.2 Futures . . . . . . . . . . . . . . . . . 362 65 � � � � � � � � Control Flow 363 65.1 � � � � � � � � Async . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 65.2 Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 66.3 � � � � Async . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 66.4 � � � . . . . .0 码力 | 393 页 | 987.97 KB | 10 月前3Comprehensive Rust(Ukrainian) 202412
Одночасність виконання: Полудень 359 62 Ласкаво просимо 360 63 Основи асинхронізації 362 63.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 63.2 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 66 Вправи 378 66.1 Вечеря філософів --- Async . . . . . . . . . . . . . . . . . . . . . . . . . . . 378 66.2 Програма широкомовного чату . . . класичну конкурентність (витіснююча багатозадачність з використанням потоків і м'ютексів), так і async/await конкурентність (кооперативна багатозадачність з використанням futures). 11 За рамками курсу0 码力 | 396 页 | 1.08 MB | 10 月前3Tornado 6.5 Documentation
make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": asyncio.run(main()) components like the IOLoop that use callbacks. Futures are usually transformed into their result with the await or yield keywords. Examples Here is a sample synchronous function: from tornado.httpclient import coroutine: from tornado.httpclient import AsyncHTTPClient async def asynchronous_fetch(url): http_client = AsyncHTTPClient() response = await http_client.fetch(url) return response.body Or for compatibility0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait()if __name__ == "__main__": asyncio.run(main()) components like the IOLoop that use callbacks. Futures are usually transformed into their result with the await or yield keywords. Examples Here is a sample synchronous function: from tornado.httpclient import coroutine: from tornado.httpclient import AsyncHTTPClient async def asynchronous_fetch(url): http_client = AsyncHTTPClient() response = await http_client.fetch(url) return response.body Or for0 码力 | 437 页 | 405.14 KB | 2 月前3Comprehensive Rust(English) 202412
. . . . . . . . . . . . . 343 XIV Concurrency: Afternoon 349 62 Welcome 350 63 Async Basics 351 63.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 63.2 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 64 Channels and Control Flow 355 64.1 Async Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 64.2 Join . . . 65.2 Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 65.3 Async Traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 65.4 Cancellation0 码力 | 382 页 | 1.00 MB | 10 月前3Comprehensive Rust(简体中文) 202412
. . . . . . . . . . . . . . . . . . . . . . . . . . . 320 XIV 并发:下午 326 63 异步 Rust 327 63.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 63.2 Futures . . . 选择 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 65 关于 async/await 的误区 335 65.1 阻塞执行器 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 66 习题 342 66.1 Dining Philosophers — Async . . . . . . . . . . . . . . . . . . . . . . . . . . 342 66.2 广播聊天应用 . . . . . . . . . . . . . .0 码力 | 359 页 | 1.33 MB | 10 月前3Comprehensive Rust(Português do Brasil) 202412
. . . 348 XIV Concorrência: Tarde 354 63 Bem-vindos 355 64 Fundamentos de Async (Assincronicidade) 356 64.1 async/await . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 64 . . . . . . . . . . . . . . . . . . . . . . 369 67 Exercícios 371 67.1 Jantar dos Filósofos --- Async . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 67.2 Apliação de Chat de Transmissão . concorrência clássica (escalonamento preemptivo utilizando threads e mutexes) quanto concorrência async/await (multitarefa cooperativa utilizando futures). 11 Fora do escopo Rust é uma linguagem extensa0 码力 | 389 页 | 1.05 MB | 10 月前3
共 141 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15