Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace redundant explicit move-ctors&move-op= by default #10

Closed
wants to merge 1 commit into from
Closed

Replace redundant explicit move-ctors&move-op= by default #10

wants to merge 1 commit into from

Conversation

RussianBruteForce
Copy link

Why not just allow compiler do its job?

@vittorioromeo
Copy link
Collaborator

std::atomic is not copyable or movable. Have you built this successfully?

@RussianBruteForce
Copy link
Author

Yup.

viktor@pc:~/d/t/build|master✓                                                                                                                                             
➤ git show | grep default
    Replace redundant explicit move-ctors&move-op= by default
+            Cell(Cell&&) = default;
+            Cell& operator=(Cell&&) = default;
+        MPMCBoundedQueue(MPMCBoundedQueue&&) = default;
+        MPMCBoundedQueue& operator=(MPMCBoundedQueue&&) = default;
+        ThreadPool(ThreadPool&&) = default;
+        ThreadPool& operator=(ThreadPool&&) = default;
+        Worker(Worker&&) = default;
+        Worker& operator=(Worker&&) = default;
viktor@pc:~/d/t/build|master✓                                                                                                                                             
➤ make clean ; make
Scanning dependencies of target HEADER_ONLY_TARGET
[ 12%] Linking CXX static library libHEADER_ONLY_TARGET.a
[ 12%] Built target HEADER_ONLY_TARGET
[ 25%] Building CXX object tests/CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o
[ 37%] Linking CXX executable fixed_function_test
*** Testing FixedFunction ***
 - for type size 8
    function size is 24
    overhead is 200%
 - for type size 16
    function size is 32
    overhead is 100%
 - for type size 32
    function size is 48
    overhead is 50%
 - for type size 64
    function size is 80
    overhead is 25%
 - for type size 128
    function size is 144
    overhead is 12.5%
 - test ( alloc/dealloc => succeed )
 - test ( free func => succeed )
 - test ( free func template => succeed )
 - test ( void func => succeed )
 - test ( class method void => succeed )
 - test ( class method 1 => succeed )
 - test ( class method 2 => succeed )
 - test ( lambda => succeed )
[ 37%] Built target fixed_function_test
[ 50%] Building CXX object tests/CMakeFiles/thread_pool_test.dir/thread_pool.t.cpp.o
[ 62%] Building CXX object tests/CMakeFiles/thread_pool_test.dir/thread_pool2.t.cpp.o
[ 75%] Linking CXX executable thread_pool_test
*** Testing TP ***
 - test ( post job => succeed )
[ 75%] Built target thread_pool_test
[ 87%] Building CXX object benchmark/CMakeFiles/benchmark.dir/benchmark.cpp.o
[100%] Linking CXX executable benchmark
[100%] Built target benchmark
viktor@pc:~/d/t/build|master✓                                                                                                                                             
➤ ./tests/fixed_function_test
*** Testing FixedFunction ***
 - for type size 8
    function size is 24
    overhead is 200%
 - for type size 16
    function size is 32
    overhead is 100%
 - for type size 32
    function size is 48
    overhead is 50%
 - for type size 64
    function size is 80
    overhead is 25%
 - for type size 128
    function size is 144
    overhead is 12.5%
 - test ( alloc/dealloc => succeed )
 - test ( free func => succeed )
 - test ( free func template => succeed )
 - test ( void func => succeed )
 - test ( class method void => succeed )
 - test ( class method 1 => succeed )
 - test ( class method 2 => succeed )
 - test ( lambda => succeed )
viktor@pc:~/d/t/build|master✓                                                                                                                                             
➤ ./tests/thread_pool_test 
*** Testing TP ***
 - test ( post job => succeed )
viktor@pc:~/d/t/build|master✓                                                                                                                                             
➤ ./benchmark/benchmark
Benchmark job reposting
***thread pool cpp***
reposted 1000001 in 326.825 ms
reposted 1000001 in 326.917 ms
reposted 1000001 in 326.93 ms
reposted 1000001 in 326.941 ms
reposted 1000001 in 327.907 ms
reposted 1000001 in 328.6 ms
reposted 1000001 in reposted 1000001 in 328.945 ms
328.943 ms
reposted 1000001 in 329.994 ms
reposted 1000001 in 330.661 ms
reposted 1000001 in 330.985 ms
reposted 1000001 in 330.991 ms
reposted 1000001 in 331.382 ms
reposted 1000001 in 331.648 ms
reposted 1000001 in 331.799 ms
reposted 1000001 in 331.814 ms
***asio thread pool***
reposted 1000001 in 7704.77 ms
reposted 1000001 in 7707.09 ms
reposted 1000001 in 7710.09 ms
reposted 1000001 in 7713.3 ms
reposted 1000001 in 7714.2 ms
reposted 1000001 in 7714.54 ms
reposted 1000001 in 7719.97 ms
reposted 1000001 in 7722.57 ms
reposted 1000001 in 7723.58 ms
reposted 1000001 in 7727.21 ms
reposted 1000001 in 7727.41 ms
reposted 1000001 in 7727.56 ms
reposted 1000001 in 7728.78 ms
reposted 1000001 in 7729.22 ms
reposted 1000001 in 7729.29 ms
reposted 1000001 in 7731.99 ms

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

@vittorioromeo
Copy link
Collaborator

vittorioromeo commented May 16, 2017

It's true that all the current tests pass, but the truth is that move is not being tested. Apologies for that. As an example, the following test produces a compilation error with your changes:

doTest("ctor0", []
    {
        ThreadPoolStd pool;
        auto pool2 = std::move(pool);
    });

@inkooboo
Copy link
Owner

As per above

@inkooboo inkooboo closed this May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants