threads.t 906 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. use Test::More;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. }
  8. use List::Util qw(first);
  9. use Slic3r;
  10. use Slic3r::Test;
  11. if (!$Slic3r::have_threads) {
  12. plan skip_all => "this perl is not compiled with threads";
  13. }
  14. plan tests => 2;
  15. {
  16. my $print = Slic3r::Test::init_print('20mm_cube');
  17. {
  18. my $thread = threads->create(sub { Slic3r::thread_cleanup(); return 1; });
  19. ok $thread->join, "print survives thread spawning";
  20. }
  21. }
  22. {
  23. my $thread = threads->create(sub {
  24. # $print can't be inizialized outside the thread because Object->slice will
  25. # modify it by removing meshes and popping layers
  26. my $print = Slic3r::Test::init_print('20mm_cube');
  27. Slic3r::Test::gcode($print);
  28. Slic3r::thread_cleanup();
  29. return 1;
  30. });
  31. ok $thread->join, "process print in a separate thread";
  32. }
  33. __END__