Well, I would not want to complicate the ScheduledOperation management with additional checks to keep it as cheap as possible. The bahavior, that you desire is already possible through a different approach. Please see this testcase:
public class OpSchedTest extends InputAdapterRenderLoop
{
@Override
public void onKeyPressed( KeyPressedEvent e, Key key )
{
this.end();
}
@Override
protected void prepareNextFrame( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "new frame: " + gameTime );
super.prepareNextFrame( gameTime, frameTime, timingMode );
}
public OpSchedTest() throws Throwable
{
super();
Xith3DEnvironment env = new Xith3DEnvironment( this );
/*
* These schedulers should take the RenderLoop as a parameter
* to the constructor.
* The RenderLoop is a GameTimeHost. The Scheduler uses the given
* GameTimeHost to "synchronize" time.
*/
OperationSchedulerImpl opSchederFirst = new OperationSchedulerImpl( this );
OperationSchedulerImpl opSchederLast = new OperationSchedulerImpl( this );
/*
* This order is important!
*/
this.addUpdatable( opSchederFirst );
this.addUpdatable( opSchederLast );
/*
* We add this operation first to emphesize,
* that is is executed last, no matter where
* and when it is added.
*/
opSchederLast.scheduleOperation( new ScheduledOperationImpl( true )
{
public void update( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "Opearation LAST: " + gameTime );
}
} );
/*
* The following operations will always be executed _before_ the LAST one!
*/
opSchederFirst.scheduleOperation( new ScheduledOperationImpl( true )
{
public void update( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "Opearation 0: " + gameTime );
}
} );
opSchederFirst.scheduleOperation( new ScheduledOperationImpl( true )
{
public void update( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "Opearation 1: " + gameTime );
}
} );
opSchederFirst.scheduleOperation( new ScheduledOperationImpl( true )
{
public void update( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "Opearation 2: " + gameTime );
}
} );
opSchederFirst.scheduleOperation( new ScheduledOperationImpl( true )
{
public void update( long gameTime, long frameTime, TimingMode timingMode )
{
System.out.println( "Opearation 3: " + gameTime );
}
} );
Canvas3D canvas = Canvas3DFactory.createWindowed( OpenGLLayer.LWJGL, 800, 600, "test" );
env.addCanvas( canvas );
InputSystem.getInstance().registerNewKeyboard( canvas.getPeer() );
this.begin();
}
}
You could of course create an implementation of OperationScheduler (or an extension of OperationSchedulerImpl) called PriorizedOperationScheduler and override the appropriate methods to realize this bahavior. Then you would need a new interface called PriorizedScheduledOperation with one additional method
int getPriority()
which would return an integer (lower number -> higher prio).
One way it use this number, would be to read out this number in the schedulerOperation() method and push the operations into different lists. Another way would be to read out this number each frame in the update() method and sort the operations appropriately.
If you like this more than the way in the above testcase, and you want to implement it, I would happily take this for the xith codebase

. But I believe, the above testcase shows the simpler and cheaper way.
Marvin