Squashed commit of the following: commit39b438aa4bAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 16:40:11 2017 +0100 add release notes commitca4ea90d35Author: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 16:32:06 2017 +0100 update distmeta commit4e35b904b0Author: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 16:30:22 2017 +0100 rename files from Daemon to Backend commit86a605ba68Author: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 16:26:43 2017 +0100 rename daemon to backend in code commitffe8fc180fAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 16:15:57 2017 +0100 add daemon files which exec to backend equivalents commit53e041594eAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat May 6 15:32:49 2017 +0100 rename netdisco-daemon to netdisco-backend
		
			
				
	
	
		
			39 lines
		
	
	
		
			646 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			646 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
| package App::Netdisco::Util::Backend;
 | |
| 
 | |
| use strict;
 | |
| use warnings;
 | |
| 
 | |
| use MCE::Util ();
 | |
| 
 | |
| # make sure this is already done elsewhere
 | |
| use if $^O eq 'linux', 'Sys::Proctitle';
 | |
| 
 | |
| use base 'Exporter';
 | |
| our @EXPORT = qw/prctl parse_max_workers/;
 | |
| 
 | |
| sub prctl {
 | |
|   if ($^O eq 'linux') {
 | |
|       Sys::Proctitle::setproctitle(shift);
 | |
|   }
 | |
|   else {
 | |
|       $0 = shift;
 | |
|   }
 | |
| }
 | |
| 
 | |
| sub parse_max_workers {
 | |
|   my $max = shift;
 | |
|   return 0 if !defined $max;
 | |
| 
 | |
|   if ($max =~ /^auto(?:$|\s*([\-\+\/\*])\s*(.+)$)/i) {
 | |
|       my $ncpu = MCE::Util::get_ncpu() || 0;
 | |
| 
 | |
|       if ($1 and $2) {
 | |
|           local $@; $max = eval "int($ncpu $1 $2 + 0.5)";
 | |
|       }
 | |
|   }
 | |
| 
 | |
|   return $max || 0;
 | |
| }
 | |
| 
 | |
| 1;
 |