Re: Experimental "peer to peer" modular programming concept
- Posted by Spock May 07, 2015
- 1756 views
This is a situation where a global variable of the struct-type will solve your problems.
By sending the result of any code producing results or part of them
to that struct and any code needing part of that result to retrieve it from.
I thought about using this method. In fact, i do use it on Propeller micro-controllers. But it requires each part of the program to actively monitor the global variables for changes. The subscribe/publish method is automatic. Publishing data causes all subscribers' handler routines to be called immediately. Of course, i have to be careful not to do anything that can block or take a long time to process (treat them the same way as GUI event handlers, basically.) If necessary, a handler routine could store the message data in a local variable, which can then be processed by a separate task.
Is the resulting published message the same format as standard message passing in the GUI? (I guess I could've checked the code myself.. just lazy.. ). If it were the same would it be possible/desirable to merge the functionality? ie, inject the messages into the usual message stream. Just a thought.
Spock