Is there an execution cost using std :: move vs using a thread pointer?

I assume that std :: move () has a bit more performance cost in the context of something like:

std::thread thrd(&func, this);
someArrOfThreads[0] = std::move(thrd);

against

std::thread *thrd = new std::thread(&func, this);
someArrOfThreadPointers[0] = thrd;

It's true? And if so, does this question std::move()change the boundaries of the thread's memory or something else?

I understand that there is a difference in the fact that in the first I actually assign the value of the array to the stream, and the other - a pointer to the stream, the stream remains at its address (s) in the second.

+4
source share
3 answers

, std::move, - lval rvalue. rvalue . noop.

rvalue, , , , .

+4

, . , , , .

std::move, , - . , .

, std::thread GCC Linux, , -, - unsigned long int, <pthreads>.

someArrOfThreads[0] = std::move(thrd);, .

, , , .

, std::move, , .

, , (, , ) , .

+3

new , . std::thread , , , .

, new , - , . , .

C, , . .

+1

Source: https://habr.com/ru/post/1658041/


All Articles