| 771 | | # TODO: Fix this. |
|---|
| 772 | | my $foo = async { |
|---|
| 773 | | threads->detach(); |
|---|
| 774 | | |
|---|
| 775 | | # Create the cloned VMs. |
|---|
| 776 | | for (my $counter = 0; $counter < getVar(name => "num_simultaneous_clones"); $counter++) { |
|---|
| 777 | | my $thread = threads->create(\&_worker, \%args); |
|---|
| 778 | | if (!defined($thread)) { |
|---|
| 779 | | $LOG->error("Unable to create worker thread! Shutting down."); |
|---|
| 780 | | Carp::croak "Unable to create worker thread! Shutting down."; |
|---|
| 781 | | } |
|---|
| 782 | | |
|---|
| 783 | | # Push thread onto thread pool. |
|---|
| 784 | | push(@THREAD_POOL, $thread); |
|---|
| 785 | | |
|---|
| 786 | | # TODO: Fix this. |
|---|
| 787 | | sleep(300); |
|---|
| 788 | | } |
|---|
| 789 | | |
|---|
| 790 | | # TODO: Fix this. |
|---|
| 791 | | }; |
|---|
| | 771 | # Start up workers slowly, in order to not overwhelm the host system. |
|---|
| | 772 | my $startup_thread = async { |
|---|
| | 773 | threads->detach(); |
|---|
| | 774 | |
|---|
| | 775 | # Create the cloned VMs. |
|---|
| | 776 | for (my $counter = 0; $counter < getVar(name => "num_simultaneous_clones"); $counter++) { |
|---|
| | 777 | my $thread = threads->create(\&_worker, \%args); |
|---|
| | 778 | if (!defined($thread)) { |
|---|
| | 779 | $LOG->error("Unable to create worker thread! Shutting down."); |
|---|
| | 780 | Carp::croak "Unable to create worker thread! Shutting down."; |
|---|
| | 781 | } |
|---|
| | 782 | |
|---|
| | 783 | # Push thread onto thread pool. |
|---|
| | 784 | push(@THREAD_POOL, $thread); |
|---|
| | 785 | |
|---|
| | 786 | # Sleep for a fixed amount of time, before starting up another worker. |
|---|
| | 787 | sleep(getVar(name => "worker_startup_delay")); |
|---|
| | 788 | } |
|---|
| | 789 | }; |
|---|