Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Compile N files at once

<< < (3/5) > >>

thomas:

--- Quote from: takeshimiya on August 11, 2005, 06:42:31 am ---Right now, it's currently multithreaded the compilation in C::B??

--- End quote ---
Code::Blocks calls the compiler asynchronously with a PipedProcess object (derived from wxProcess). The compiler runs in its own thread and the application is not blocking.
PipedProcess reads stdin and stderr from the compiler regularly (using a 100 ms timer) and is notified of compiler termination by wx via OnTerminate(). All compiler output and termination notification is passed to the application via a number of wxCommandEvents (or cbEvents? don't remember, but does not matter much anyway).

The fact that compilation *still* runs "synchronously" is artificial because the next job is started only after the event telling that the last job has finished is being processed. So basically, it would be a snap to run any number of compiles in parallel, all you really have to think about thoroughly is how to synchronize with the linker and how to prevent an awful mess on the output screen.

grv575:
Have a main compile thread which blocks till all the OnTerminate() calls complete.  Then have the main thread call the linker (no need to paralleliize just the link step).  Output is still debatable -- should only the error messages from the first thread to generate errors be shown?  Kill all compile threads when this happens?  Need to make the output polling use a thread id then as a tag?

thomas:
One efficient solution for output would be to skip sending stdout and stderr events. Instead, concat everything to one string, and send that through OnTerminate(). If the exit code is error, then empty the job queue. The remaining processes will terminate normally (killing them is not a good idea), and the queue will end.

Having a main thread is no good idea in my opinion, as everything should be handled the same way, exceptions are always bad. One could for example have static counter = queue.GetCount(); when compilation starts, and decrement counter in OnTerminate(). If counter reaches zero, post a "start linking now" message to the message queue. This way, all jobs are equal, no special cases, no exceptions.

rickg22:
Why not just use makefiles and make a CB patch to specify additional parameters for make?

grv575:
makefile -j parameter doesn't even work on DOS.  It only invokes additional jobs on unix.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version