Working with Asynchrony Generically: A Tour of C++ Executorswith a function. upon_[error|done](sender, fn) → sender … transforms the error and done signals with a function. let_[value|…](sender, fn) → sender … passes the result of input sender to function, which std::move(work) ).value(); }50 SENDER/RECEIVER AND COROUTINES By returning a sender, an async function puts the choice of whether to use coroutines or not in the hands of the caller.51 COMING UP treated like a black box. goto is an unstructured control flow construct conditional loop function call goto59 FIRE-AND-FORGET TASK MODELS ARE UNSTRUCTURED Fire-and-forget work is like goto.0 码力 | 121 页 | 7.73 MB | 6 月前3
C++20: An (Almost) Complete OverviewTristan Brindle Thursday, September 17 • 12:00coroutines15 Coroutines What’s a coroutine? A function, with one of the following: co_await: suspends coroutine while waiting for another computation typename V::value_type; T x { }; T::static_function(); // ... }; With C++20: [](const vector & vec) { T x { }; T::static_function(); // ... };29 Templated Lambda Expressions Supports cooperative cancellation Destructor automatically Asks thread to cancel Calls join()38 Joining & Cancellable Threads Cancelling threads std::stop_token Supports actively 0 码力 | 85 页 | 512.18 KB | 6 月前3
Bringing Existing Code to CUDA Using constexpr and std::pmrspecifier declares a function as being a kernel. Such a function is: • Executed on the device, • Callable from the host. The __device__ execution space specifier declares a function that is: • Executed nvidia.com/cuda/cuda-c-programming-guide/ index.html#function-declaration-specifiers 36 |The __host__ execution space specifier declares a function that is: • Executed on the host, • Callable from the declare a function with only the __host__ execution space specifier or to declare it without any of the __host__, __device__, or __global__ execution space specifier; in either case the function is compiled0 码力 | 51 页 | 3.68 MB | 6 月前3
Secure your microservices with istio step by stepservice mesh ● Reviews-v1 ○ doesn’t call the ratings service. ● Reviews-v2 ○ calls ratings, black stars ● Reviews-v3 ○ calls ratings, red stars Initializing services 1) Deploy bookinfo services with0 码力 | 34 页 | 67.93 MB | 1 年前3
hazard pointer synchronous reclamationlinks. A is automatically retired. • User removes all objects with dependence on resource X. • User calls hazard_pointer_clean_up. • A is reclaimed. B is automatically retired (as a result of calling ha0 码力 | 31 页 | 856.38 KB | 6 月前3
C++23: An Overview of Almost All New and Updated FeaturesLibrary Changes to Ranges Library Changes to Views Library std::expected std::move_only_function<> std::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous Library Changes to Ranges Library Changes to Views Library std::expected std::move_only_function<> std::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous Library Changes to Ranges Library Changes to Views Library std::expected std::move_only_function<> std::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous0 码力 | 105 页 | 759.96 KB | 6 月前3
应用 waPC (rust) 做软件测试工具wapc::register_function("ping", ping); } fn ping(msg: &[u8]) -> wapc::CallResult { …. Ok(msg.to_vec()) } waPC Guest Rust waPC • Use wapc_init to register function • Register_function can only be be used inside WAPC_init • Register_function cannot be called inside ping • _start is meant to support tinygo’s wasm • waPC host will still run both "wapc_init" and "_start" during intialization intialization waPC Guest Rust waPC • Use wapc_init to register function • _start also can • Util Lib uses wapc_init, users build on top of ”_start” extern crate wapc_guest as guest; extern crate Regex;0 码力 | 30 页 | 2.50 MB | 1 年前3
Making Libraries Consumable for Non-C++ DevelopersRun down of some approaches Just be like C? – post-1972 Common Object Model (COM) – 1993 Foreign function interface (libffi) – 1996 Simplified Wrapper and Interface Generator (SWIG) – 1996 JVM – Java Native dev- >get_data_from(); return d.a + d.b; The get_data_from() function returns the struct in registers, but the get_data_from() member function returns in caller provided memory. This is often unexpected int b; }; /* Get data from device ‘dev’. */ data_t get_data_from(size_t dev); How does this function fail? C++ exceptions have no universal binary contract. Meaning the consumer may not be prepared0 码力 | 29 页 | 1.21 MB | 6 月前3
Performance Lets dive into Performance issueslayouts with one GridLayout. Loops • Beware of function and memory allocations inside of loops. You see this as a standard pattern. function loopFunction () { var val = 0; for (var i=0;i<100000;i++) i=0;i<100000;i++) { doSomething( () => { val++; } ); } } Loops • Proper way function loops() { var val = 0, fun = function() { val++; }; for (var i=0;i<100000;i++) { doSomething(fun);0 码力 | 15 页 | 1.71 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 03 现代 C++ 进阶:模板元编程为了灵活性,可以用 std::function 容器。 • 只需在后面尖括号里写函数的返回类型和 参数列表即可,比如: • std::function; 如何避免用模板参数 2 :无捕获的 lambda 可以传为函数指针 • 另外,如果你的 lambda 没有捕获任何局 部变量,也就是 [] ,那么不需要用 std::function 作为参数:用 template 然后 Func const & 做类型。 2. lambda 作为返回值:用 auto 做类型。 3. 牺牲性能但存储方便: std::function 容器。 4. lambda 作为参数:通常用 [&] 存储引用。 5. lambda 作为返回值:总是用 [=] 存储值。 • 其实 lambda 还有更多语法,比如 mutable , 0 码力 | 82 页 | 12.15 MB | 1 年前3
共 22 条
- 1
- 2
- 3
相关搜索词













