threads.t 841 B

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