本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138729514
https://cdrdv2-public.intel.com/772402/onetbb_cookbook_2021.6-772401-772402.pdf
https://cdrdv2-public.intel.com/816904/onetbb_get-started-guide_2021.12-772618-816904.pdf
https://blog.51cto.com/shijianfeng/5152901
// 同构,多进程
https://github.com/microsoft/Microsoft-MPI // 消息传递接口 (MPI)
https://github.com/rabauke/mpl // 同类,Boost.MPI
MPICH | High-Performance Portable MPI
// 同构,多线程任务计算
https://github.com/ClearLove27149/TaskCpp
https://github.com/ddemidov/compute // GPU计算
https://github.com/oneapi-src/oneTBB#stable-releases // tbb
https://github.com/intel/tbb // tbb
// 异构,并行任务计算,支持流程
https://taskflow.github.io/taskflow/index.html
https://github.com/taskflow/taskflow.git
#include <taskflow/taskflow.hpp>
#include
// // Offload Tasks to a GPU
//__global__ void saxpy(int n, float a, float* x, float* y) {
// int i = blockIdx.x * blockDim.x + threadIdx.x;
// if (i < n) {
// y[i] = a * x[i] + y[i];
// }
//}
int test() {
tf::Executor executor;
tf::Taskflow taskflow;
auto [A, B, C, D] = taskflow.emplace( // create four tasks
[]() { std::cout << “TaskA\n”; },
[]() { std::cout << “TaskB\n”; },
[]() { std::cout << “TaskC\n”; },
[]() { std::cout << “TaskD\n”; }
);
tf::Task E = taskflow.emplace([](tf::Subflow& subflow) { // subflow task B
tf::Task B1 = subflow.emplace([]() {}).name(“B1”);
tf::Task B2 = subflow.emplace([]() {}).name(“B2”);
tf::Task B3 = subflow.emplace([]() {}).name(“B3”);
B3.succeed(B1, B2); // B3 runs after B1 and B2
}).name(“B”);
A.precede(B, C); // A runs before B and C
D.succeed(B, C, E); // D runs after B and C
// creates a feedback loop {0: cond, 1: stop}
tf::Task stop = taskflow.emplace([]() {}).name(“stop”);
tf::Task cond = taskflow.emplace([]() { return std::rand() % 2; }).name(“cond”);
cond.precede(cond, stop); // moves on to ‘cond’ on returning 0, or ‘stop’ on 1
//tf::Task cudaflow = taskflow.emplace([&](tf::cudaFlow& cf) {
// tf::cudaTask h2d_x = cf.copy(dx, hx.data(), N).name(“h2d_x”);
// tf::cudaTask h2d_y = cf.copy(dy, hy.data(), N).name(“h2d_y”);
// tf::cudaTask d2h_x = cf.copy(hx.data(), dx, N).name(“d2h_x”);
// tf::cudaTask d2h_y = cf.copy(hy.data(), dy, N).name(“d2h_y”);
// tf::cudaTask saxpy = cf.kernel((N + 255) / 256, 256, 0, saxpy, N, 2.0f, dx, dy)
// .name(“saxpy”); // parameters to the saxpy kernel
// saxpy.succeed(h2d_x, h2d_y)
// .precede(d2h_x, d2h_y);
// }).name(“cudaFlow”);
// Compose Task Graphs
tf::Taskflow f1, f2;
// create taskflow f1 of two tasks
tf::Task f1A = f1.emplace([]() { std::cout << “Task f1A\n”; }).name(“f1A”);
tf::Task f2B = f2.emplace([]() { std::cout << “Task f2B\n”; }).name(“f2B”);
tf::Task f1_module_task = f2.composed_of(f1).name(“module”);
f1_module_task.succeed(f1A, f2B)
.precede(f1A);
// tf::Future
// run_once.get(); // wait on this run to finish
executor.run(taskflow).wait();
// create asynchronous tasks directly from an executor
std::future
std::cout << “async task returns 1\n”;
return 1;
});
executor.silent_async([]() { std::cout << “async task does not return\n”; });
// create asynchronous tasks with dynamic dependencies
tf::AsyncTask AA = executor.silent_dependent_async([]() { printf(“A\n”); });
executor.wait_for_all();
// run the taskflow four times
executor.run_n(taskflow, 4);
// runs the taskflow five times
executor.run_until(taskflow, [ counter = 5]() mutable { return –counter == 0; });
// standard parallel CPU algorithms
//std::vector
//tf::Task task1 = taskflow.for_each( // assign each element to 100 in parallel
// data.begin(), data.end(), [](auto& i) { i = 100; }
//);
//tf::Task task2 = taskflow.reduce( // reduce a range of items in parallel
// data.begin(), data.end(), data.begin(), [](auto a, auto b) { return a + b; }
//);
//tf::Task task3 = taskflow.sort( // sort a range of items in parallel
// data.begin(), data.end(), [](auto a, auto b) { return a < b; }
//);
//// create a pipeline to propagate five tokens through three serial stages
//tf::Pipeline pl(“num_lines”,
// tf::Pipe{ tf::PipeType::SERIAL, [](tf::Pipeflow& pf) {
// if (pf.token() == 5) {
// pf.stop();
// }
// } },
// tf::Pipe{ tf::PipeType::SERIAL, [](tf::Pipeflow& pf) {
// printf(“stage 2: input buffer[%zu] = %d\n”, pf.line(), buffer[pf.line()]);
// } },
// tf::Pipe{ tf::PipeType::SERIAL, [](tf::Pipeflow& pf) {
// printf(“stage 3: input buffer[%zu] = %d\n”, pf.line(), buffer[pf.line()]);
// } }
//);
//taskflow.composed_of(pl)
// executor.run(taskflow).wait();
// dump the graph to a DOT file through std::cout
taskflow.dump(std::cout);
return 0;
}


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138706146
示例代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void f(void)
{
int* x = malloc(10 * sizeof(int));
x[10] = 0; // problem 1: heap block overrun
} // problem 2: memory leak – x not freed
void func() {
printf(“func call”);
func();
}
int main(int, int**) {
f();
//func();
printf(“hello\n”);
char *ptr = malloc(10);
ptr[12] = ‘a’;// 内存越界
memcpy(ptr+1, ptr, 5);// 踩内存
char a[10];
a[12] = ‘i’;// 数组越界
free(ptr);
free(ptr);// 重复释放
char *p1;
*p1 = ‘1’;// 非法指针
}


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138681699
切换场景过程中,增加视口自适应动画,场景完全切换后,视口也自适应到最终效果,最后切换时不会有闪动。

update:
totalZoom = m_targetViewZoom - m_sourceViewZoom;
curZoom = totalZoom * m_t; // m_t【0 - 1】 动画延迟归一化进度
sourceOpacity = opacity * m_t;
viewOffset = m_cameraOffset * m_t;
updateRender();


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138630208
1 | class Int{ |
operator类型名(): // C++11
explicit ( 表达式 ) operator 转换类型标识 // C++20
1 | Int i; |
其它示例:
class A
{
public:
operator char*() const // 隐式转换
{
return data;//当从其他类型转换到char*时自动调用
}
private:
char* data;
};


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138619023
1 | void reference(int& v) { |
1 | int& fn(){...} //返回类型为左值引用 |
左值引用是用于常规对象的引用和修改
右值引用是为了优化资源管理,特别是临时对象的生命周期终结时能将其拥有的资源高效地转移给新的所有者。
常见用法1:
std::vector::emplace_back(T &&val)
常见用法2:
class A;
A oldVal;
A newVal = std::move(oldVal);
常见用法3:
class A {
public:
A(int&& oldV) : v(oldV) {}
A(const A& b){…} //copy construct
A(A&& b){…} //move construct
int v;
}
int&& v = 0;
int oldV = 0;
A oldVal(oldV);
A newVal(oldVal);
常见用法4:
template<typename… Args>
void h(Args&&… args)
{
reference(std::forward
}
常见用法5:
1 | class A final |
1 | auto &&delayA = func(); // 延长临时对象生命周期 |
常见用法6:
std::string a = “…..”;
std::string_view refRightA = a;


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138583985

1.不同预览模式
2.计算出缩放比
3.固定滚动偏移
关键代码:
overview:
ratioW = getChildRect().width / getParentRect().width
ratioH = getChildRect().height / getParentRect().height
maxRatio = max(ratioW, ratioH)
if(maxRatio < 1)
return 1
else
return 1/maxRatio
oldViewCenter = viewCenterOffset
real:
if(bInit) { // 重置
if(childOutline.height < parentOutline.height)
oldViewCenter.fY = viewCenterOffset.fY;
else
oldViewCenter.fY = viewCenterOffset.fY + (childOutline.height - parentOutline.height) / 2; //顶部对齐
} else { // 滚动后拉伸
if(refParentOutline.top >= refChildOutline.top) //上次就无溢出
oldViewCenter.fY = viewCenterOffset.fY + (childOutline.height - parentOutline.height) / 2; //顶部对齐
else {
overflowLen = refParentOutline.top - refChildOutline.top //溢出长度
if(childOutline.height - overflowLen <= parentOutline.height) //溢出后下面留白
oldViewCenter.fY = parentOutline.bottom - childOutline.bottom // 底部对齐
else
oldViewCenter.fY = parentOutline.top - overflowLen - childOutline.top // 顶部溢出对齐
}
}


本文作者原创,首发在本博客;CSDN 上的同名文章已标注为转载并回链到本页:https://blog.csdn.net/qq_30220519/article/details/138580908

关键代码:
inputMarginBox = refChildOutline - refParentOutline
if(HSC_RIGHT)
outputMarginBox.right = inputMarginBox.right;
outputMarginBox.left = parentOutline.width - outputMarginBox.right - refChildOutline.width * uniformScale
if(HSC_CENTER)
parentOutline.centerX - parentOutline.left - getRefBaseParentCenterXToChildLeft() * uniformScale


tag:
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true