Easier threading with RASCAL
Justin Forest <[email protected]> Sun, 15 Feb 2004 17:19:24 +0300
| Newsgroups | gmane.comp.misc.faerion.devel |
|---|---|
| Message-ID | <[email protected]> |
One more thing that most developers will implement in their RASCAL based applications is threading. The original specification required the application to call the rascal_work function periodically, telling it how much time it can spend waiting for events. This would require the developer to organize the main program loop so that the application periodically quits it to serve the network. This can not only be ineficient, but can also be impossible, like when the application spends most time in a third party library call and is unable to requently interrupt it. This could possibly require to rewrite significant parts of the application code, leaving ground for new bugs. The alternative is to spawn a thread dedicated to working with the network, leaving the main program thread (the one with the GUI, for example) alone. The best recommended threading model is a thread per CPU, which is what I'm about to do: spawn this number of dedicated rascal threads from within the library startup code. The only thing that I'm still curious about is a way to synchronize threads. Perhaps the C version will expose internally used structures and functions related to the internally used mutex class, while the C++ version will also expose the class itself. ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click