Re: Tasks - communication
- Posted by jimcbrown (admin) Oct 21, 2012
- 1685 views
I like the D Programming Language's approach to this, namely that all data is assumed to be shared between tasks unless explicitly said otherwise.
Seconded.
Global broadcasts between tasks ate more cpu clocks than narrowcasting. It increased the msg queue for each task, and the overhead in tracking which msgs got delivered and could be deleted to free memory. Memory use sounds trivial until you consider the size of msgs that could have been sent from http.e, for instance.
Agreed. The shared data should be global, rather than duplicated via messaging. It's faster for two threads to use the same block of memory than to have two processes communicate via IPC to notify each other of updates everytime one of the processes touches the object.
Perhaps I'm simply not thinking far enough ahead though - one day we may very well attempt to run multiple threads across different computers (and perhaps different architectures) on a cloud, for example.
So i provided for broad- and narrow- casting. You choose your best option for the app you are currently coding. Sue me.
I suspect that I'd normally choose narrowcasting most of the time, if I had to choose between those two options.