0
RAII for thread pool
Hi Refer code below: https://code.sololearn.com/c544GaxL0ec5 I have basically two questions as below: 1. clsThreadPool is my class following RAII? I was suggested to use smart pointer in place of vector but is it necessary at all? 2. clsThreadPool1 is having shared_pointer of thread[] but I am not able to use make_shared for array like below: pThreads = make_shared<thread>()[max_threads]; Every example I came across for shared pointer of array is using new, but i dont want to do that and would like to use make_shared. how to do so? Thanks in advance...!
3 Antworten
+ 1
Thanks GamerGeil Hd . This is another nice way of having threads in shared pointer.
However, shared_pointer of vector is not an array. It is dynamically allocated on heap where as shared_ptr array will be on stack. This is the performance degradation we will be getting if we use "shared_pointer of vector of thread" compared to "shared pointer of thread array". Correct ?
Also another thing is related to syntax issue i am facing in original code of mine. Thread is also a class in c++ library and hence i thought to have array of thread class as shared_pointer but it has compile error.
Thanks again for your time and help.
0
Np