Does Phobos also do threadpools? Somehow I liked the idea of an Object like agent smith, just duplicate yourself when the task is too big. ( ^_^ )
> > > Hm... I guess I understand now, you need a task parallelization, right? > > In order to do this, you usually separate the task into several independent > sub-tasks, put into a queue and wait until it is finished. > > For example, we have a list of files to download from remote server. For each > file, we create a new connection and retrieve it independently (and, > possibly, out of order): > > import tango.core.ThreadPool; > > void execute() > { > auto pool = new ThreadPool!(string)(10); // create a thread pool with 10 > threads > string[] fileList = loadFileList(); > foreach (string filePath; fileList) { > pool.append(&download, filePath); // append the task > } > > pool.finish(); // wait until all the tasks complete > } > > void download(string fileName) > { > // ... > } > > In this example, I create a lot of threads (more than hardware runs > concurrently) because the CPU is not a bottleneck. > You may experience different results in different CPU workaload, though. > > Hope that helps. >