This commit is contained in:
Light-City
2019-11-05 16:56:07 +08:00
parent 3a495d7fa2
commit 8edbbbc5a2
179 changed files with 428 additions and 26 deletions

View File

@@ -0,0 +1,27 @@
//
// Created by light on 19-11-5.
//
#include <iostream>
#include <thread>
using namespace std;
class X {
public:
void do_length_work() {};
};
void process_big_object(std::unique_ptr<X>);
int main() {
X my_x;
thread t(&X::do_length_work, &my_x); // 1
std::unique_ptr<X> p(new X);
p->do_length_work();
std::thread tt(process_big_object,std::move(p));
//std::thread实例的可移动且不可复制性。不可复制保性证了在同一时间点
// 一个std::thread实例只能关联一个执行线程可移动性使得程序员可以自己决定哪个实例拥有实际执行线程的所有权。
return 0;
}