Small problem with GameTaskQueueManager?

When I tried to execute some code in the opengl thread, and wait for it to finish in the way suggested in the wiki, I found it never returned… So I put together a small testcase:


import java.util.concurrent.Callable;
import java.util.concurrent.Future;

import com.jme.util.GameTaskQueueManager;
import com.jmex.editors.swing.settings.GameSettingsPanel;
import com.jmex.game.StandardGame;

public class TestTest {

    public static void main(String[] args) throws Exception {
        // Create a new StandardGame, which will run opengl from it's own thread
        StandardGame game = new StandardGame("Gamey");
        // Ask user for settings
        GameSettingsPanel.prompt(game.getSettings());
        // game.getSettings().setFullscreen(false);
        game.start();
        Future<Object> future = GameTaskQueueManager.getManager().update(
                new Callable<Object>() {
                    public Object call() throws Exception {
                        System.out.println("returning");
                        return null;
                    }
                });
        System.out.println("waiting");
        future.get();
        System.out.println("resuming");
    }
}


This should print "waiting", "returning" and "resuming" but it never gets to "resuming". A quick fix is to change "return null" to "return 1" or something, but this might not be very obvious. My guess is that most users would just go ":?"
Is this a bug in GameTaskQueueManager or just a slight mistake in the wiki?

Oh, and I seem to have misplaced my copy of FengStandardGame.java, could anyone send me a new copy? :D

Hmmm…I'll try to get a look at this later, I'm not where I can look at the code at the moment though.



It could be that it's checking for the return to no longer be null and since you're throwing null it never returns.  That would be bad. :o  If that's the case it needs to be fixed…returning null is perfectly valid.

Nope, I have explicitly returned null before and it worked. Look at http://www.jmonkeyengine.com/jmeforum/index.php?topic=5166.msg41313#msg41313



[Edit]

Granted I was using another queue, but then this points to the fact that that queue appears to be the problem. (It never got called)

Yes, but the problem could be in the call to get() that is causing a wait until something other than null exists.  You are not calling get() (which is a blocking call) in your code it doesn't seem duenez.

Right, but the point is that if you take out the get() call, you should still see the "returning" message printed, but it never gets called.

You won't see "returning" unless it is somehow called.  Perhaps doing so with an Executor would solve some of these issues?

Fixed and checked in.