3 funky strategies to make youp NativeSeript apps smarter!
3 funky strategies to make youp NativeSeript apps smarter!0 码力 | 47 页 | 12.61 MB | 1 年前3C++高性能并行编程与优化 - 课件 - 01 学 C++ 从 CMake 学起
• 文件越来越多时,一个个调用 g++ 编译链接会变得很麻烦。 • 于是,发明了 make 这个程序,你只需写出不同文件之间的依赖关系,和生成各文件的规则。 • > make a.out • 敲下这个命令,就可以构建出 a.out 这个可执行文件了。 • 和直接用一个脚本写出完整的构建过程相比, make 指明依赖关系的好处: 1. 当更新了 hello.cpp 时只会重新编译 hello main.cpp 的编译,加快编译速度( make -j )。 3. 用通配符批量生成构建规则,避免针对每个 .cpp 和 .o 重复写 g++ 命令( %.o: %.cpp )。 • 但坏处也很明显: 1. make 在 Unix 类系统上是通用的,但在 Windows 则不然。 2. 需要准确地指明每个项目之间的依赖关系,有头文件时特别头疼。 3. make 的语法非常简单,不像 shell 可以做很多判断等。 4. 不同的编译器有不同的 flag 规则,为 g++ 准备的参数可能对 MSVC 不适用。 构建系统的构建系统( CMake ) • 为了解决 make 的以上问题,跨平台的 CMake 应运而生! • make 在 Unix 类系统上是通用的,但在 Windows 则不然。 • 只需要写一份 CMakeLists.txt ,他就能够在调用时生成当前系统所支持的构建系统。0 码力 | 32 页 | 11.40 MB | 1 年前3FlexClass
Breno Guimarães brenorg@gmail.com Twitter @brenorg https://github.com/brenoguim/flexclassstd::make_shared(n) std::shared_ptr (block) Control Block T T T T T …my::shared_ptr Control Block my::shared_ptr (block)I will write it myself ™ Control Block T T T T T T … template auto my::make_shared(int n) { // Allocate sizeof(controlBlock) + n*sizeof(T) bytes // Cast return fc::make_tuple(&data); } int size; int ref_cnt; fc::AdjacentArray data; }; template auto my::make_shared(int n) { Block * block = fc::make >(n) 0 码力 | 8 页 | 957.56 KB | 5 月前3C++高性能并行编程与优化 - 课件 - 11 现代 CMake 进阶指南
build • cd build • cmake .. • make -j4 • sudo make install • cd .. • 需要先创建 build 目录 • 切换到 build 目录 • 在 build 目录运行 cmake < 源码目录 > 生成 Makefile • 执行本地的构建系统 make 真正开始构建( 4 进程并 行) • 让本地的构建系统执行安装步骤 统一了不同平台( Linux 上会调用 make , Windows 上调用 devenv.exe ) • 结论:从现在开始,如果在命令行操作 cmake ,请使用更方便的 -B 和 --build 命令。 // 在源码目录用 -B 直接创建 build 目录并生成 build/Makefile // 自动调用本地的构建系统在 build 里构建,即: make -C build -j4 Linux 的 make , Windows 的 MSBuild ),从而让构建规则可以只写一份,跨平 台使用。 • 过去的软件(例如 TBB )要跨平台,只好 Makefile 的构建规则写一份, MSBuild 也写一份 。 • 现在只需要写一次 CMakeLists.txt ,他会视不同的操作系统,生成不同构建系统的规则文件。 • 那个和操作系统绑定的构建系统( make 、 MSBuild0 码力 | 166 页 | 6.54 MB | 1 年前3Making Libraries Consumable for Non-C++ Developers
the .go source file – 2009 Swift – share a runtime and be like C – 2014There is no one approach. Make it suck less by recognizing assumptions.What assumptions are being made? /* Opens the device with Cygwin compile of gcc, sizeof(long) == sizeof(size_t) MSYS2 compile of gcc, sizeof(long) == 4You can make interop suck less by… Explicitly state/document argument content. • Instead of long or int, use Correct signature and usage. ((void(*)(id,SEL,int,float))objc_msgSend)(_id, _op, 10, 1.f);You can make interop suck less by… Explicitly state/document argument content. • Instead of long or int, use0 码力 | 29 页 | 1.21 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 16 现代 CMake 模块化项目管理指南
--with-some-options # 生成 Makefile (这个 configure 脚本由 Autoconf 生 成) • make -j 8 # 8 核心编译,生成 libtest.so • sudo make install # 安装,拷贝到 /usr/lib/libtest.so • CMake 构建系统: • cmake -B build https://semver.org 总结 • 安装 TBB : • cd tbb • ./configure --prefix=/opt/tbbinstalldir • make -j 8 • sudo make install • 在你的项目里使用 TBB : • cd yourapp • cmake -B build -DTBB_DIR=/opt/tbbinstalldir/lib/cmake/TBB0 码力 | 56 页 | 6.87 MB | 1 年前3hazard pointer synchronous reclamation
hazard_pointer { templateT* protect(const std::atomic & src) noexcept; }; hazard_pointer make_hazard_pointer(); Hazard Pointer Synchronous Reclamation Beyond Concurrency TS2 – Maged Michael See read_and_use(std::atomic & src, Func fn) { // Called frequently folly::hazard_pointer h = folly::make_hazard_pointer(); Foo* ptr = h.protect(src); return fn(ptr); // ptr is protected } Void update(std::atomic & reset_protection(nullptr_t = nullptr) noexcept; void swap(hazard_pointer&) noexcept; }; hazard_pointer make_hazard_pointer(); // Nonempty void swap(hazard_pointer&, hazard_pointer&) noexcept; Cohort Interface 0 码力 | 31 页 | 856.38 KB | 5 月前3Lock-Free Atomic Shared Pointers Without a Split Reference Count? It Can Be Done!
shared_ptrnext; }; atomic > head; void push_front(T t) { auto p = make_shared (std::move(t), head.load()); while (!head.compare_exchange_weak(p->next, p)) {} atomic ref_count = 1; … T atomic > a Thread 1 auto s = a.load(); Thread 2 a.store(make_shared ( …)); ++ -- If this happens first…23 The fundamental problem: The race to zero Thread shared_ptr next; }; atomic > head; void push_front(T t) { auto p = make_shared (std::move(t), head.load()); while (!head.compare_exchange_weak(p->next, p)) {} 0 码力 | 45 页 | 5.12 MB | 5 月前3C++23: An Overview of Almost All New and Updated Features
Heterogeneous Erasure Removed Features Garbage Collection Support37 std::print() and println() make std::format() easier Example: std::string name { "CppCon" }; // Old-style cout/format() pattern std::print("{}", Process([] { return 21; })); // 42 But this fails: std::cout << Process([p = std::make_unique(42)] { return *p; }); “Attempting to reference a deleted function” The copy ctor Process([] { return 21; })); // 42 std::print("{}", Process([p = std::make_unique (42)] { return *p; })); // 8494 Agenda C++23 Core Language Explicit Object Parameters 0 码力 | 105 页 | 759.96 KB | 5 月前3Bazel
cache/bazel -it opencurvedocker/curve-base:build-debian11 # 容器内 cd /curve/curvefs make build os=debian11 # 容器外 # curvefs sudo make image os=debian11 tag=harbor.cloud.netease.com/curve/curvefs:chengyi01-debian1130 码力 | 6 页 | 4.69 MB | 5 月前3
共 23 条
- 1
- 2
- 3