Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my @make_obj = qw(
- obj1.o
- obj2.o
- obj3.o
- ...
- );
- my $fm = $pm = new Parallel::ForkManager(6);
- foreach my $obj (@make_obj) {
- $fm->start and next;
- system("make -f Makefile $make_obj");
- $fm->finish();
- }
- use threads;
- my $max_threads = 5;
- my @targets = qw(obj1.o obj2.o obj3.o ...);
- while(@targets) {
- my $num_threads = threads->list(threads::running);
- if( $num_threads < $max_threads ) {
- my $target = shift @targets;
- threads->create(sub { return system "make $target" });
- }
- }
- make -f Makefile obj1.o &
- make -f Makefile obj2.o &
- ...
- make -f Makefile objn.o &
Add Comment
Please, Sign In to add comment