We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey, long time lurker first time poster. I have some questions about an idea I have to implement the java producer consumer model in a processing project. In a nutshell, I would have a Processing object for graphical output, and then a set of threaded objects updating properties like their position, speed etc. These would communicate asynchronously with the Processing object using a shared queue of commands using the following code...
The shared queue of input args that represent user input
Queue inputQ = new LinkedList();
ShapeCoordinator sc = new ShapeCoordinator(inputQ); ProcessingCoordinator pc = new ProcessingCoordinator(inputQ);
The processing object in embedded in a Frame within the ProcessingCoordinator (as per http://processing.org/reference/javadoc/core/processing/core/PApplet.html), which Produces InputQ objects on the shared Queue in response to user input (mousemove/click/presses/mouseX/mouseY etc) on the embedded processing PApplet. ShapeCoordinator is a Thread that consumes these objects on notify() and uses the info to update the status of Shape objects. The ProcessingCoordinator reads the resulting state of the objects on notify(), and updates the PApplet graphics.
I want to do this to decouple Shape objects and the processing object as much as possible, eventually I want the Shape Object algorithms to connect to other non-processing code.
Does anyone think this model is an interesting way to use Processing? One trouble I've come across is that I can't figure out how to pass the shared queue InputQ to the embedded PApplet object so it can update it on user input, I can pass the queue to the applet, but the PApplet seems to nullify or ignore the object when it starts. Has anyone encountered this and resolved it?