Module: Wiretap::ThreadWorker

Defined in:
ext/thread_worker.cpp

Class Method Summary collapse

Class Method Details

.run(*args) ⇒ Object

ThreadWorker.run(children_count = 8, &block)

Block receives number of iteration and returns command, required to launch at this iteration.

This function is supposed to work for converting multiple files via convert utility.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'ext/thread_worker.cpp', line 59

static VALUE thread_worker_run(int argc, VALUE* argv, VALUE self) {
	VALUE num_procs;
	rb_scan_args(argc, argv, "01", &num_procs);
	if(num_procs == Qnil) {
		num_procs = INT2FIX(8);
	}
	
	int counter = init_worker(NUM2INT(num_procs));
	while(1) {
		break;
	}
	
	int status;
	pid_t child_pid;
	while((child_pid = wait(&status)) != -1) {
		start_command(counter++);
	}
	return Qtrue;
}