|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jogamp.newt.util.MainThread
public class MainThread
NEWT Utility class MainThread
This class provides a startup singleton main thread,
from which a new thread with the users main class is launched.
Such behavior is necessary for native windowing toolkits,
where the windowing management must happen on the so called
main thread e.g. for Mac OS X !
Utilizing this class as a launchpad, now you are able to
use a NEWT multithreaded application with window handling within the different threads,
even on these restricted platforms.
To support your NEWT Window platform,
you have to pass your main thread actions to invoke(..)
,
have a look at the MacWindow
implementation.
TODO: Some hardcoded dependencies exist in this implementation,
where you have to patch this code or factor it out.
If your platform is not Mac OS X, but you want to test your code without modifying
this class, you have to set the system property newt.MainThread.force
to true
.
The code is compatible with all other platform, which support multithreaded windowing handling.
Since those platforms won't trigger the main thread serialization, the main method
will be simply executed, in case you haven't set newt.MainThread.force
to true
.
Test case on Mac OS X (or any other platform):
java -XstartOnFirstThread com.jogamp.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2Which starts 4 threads, each with a window and OpenGL rendering.
Field Summary | |
---|---|
static boolean |
MAIN_THREAD_CRITERIA
|
Fields inherited from interface com.jogamp.newt.util.EDTUtil |
---|
defaultEDTPollGranularity |
Constructor Summary | |
---|---|
MainThread()
|
Method Summary | |
---|---|
static void |
addPumpMessage(Display dpy,
Runnable pumpMessage)
|
static MainThread |
getSingleton()
|
void |
invoke(boolean wait,
Runnable r)
Append task to the EDT task queue. Wait until execution is finished if wait == true .Shall start the thread if not running. Can be issued from within EDT, ie from within an enqueued task. |
void |
invokeStop(Runnable r)
Append the final task to the EDT task queue, signals EDT to stop and wait until stopped. Due to the nature of this method: All previous queued tasks will be finished. No new tasks are allowed, an Exception is thrown. Can be issued from within EDT, ie from within an enqueued task. EDTUtil.reset() may follow immediately, ie creating a new EDT
|
boolean |
isCurrentThreadEDT()
|
boolean |
isRunning()
|
static void |
main(String[] args)
Your new java application main entry, which pipelines your application |
static Runnable |
removePumpMessage(Display dpy)
|
void |
reset()
Create a new EDT. |
void |
run()
|
void |
start()
Start the EDT |
void |
waitUntilIdle()
Wait until the EDT task queue is empty. The last task may still be in execution when this method returns. |
void |
waitUntilStopped()
Wait until EDT task is stopped. No stop action is performed, EDTUtil.invokeStop(java.lang.Runnable) should be used before. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean MAIN_THREAD_CRITERIA
Constructor Detail |
---|
public MainThread()
Method Detail |
---|
public static void main(String[] args)
public static MainThread getSingleton()
public static Runnable removePumpMessage(Display dpy)
public static void addPumpMessage(Display dpy, Runnable pumpMessage)
public final void reset()
EDTUtil
reset()
invokeStop(..)
in case another start()
or invoke(..)
is expected.
reset
in interface EDTUtil
EDTUtil.start()
,
EDTUtil.invoke(boolean, java.lang.Runnable)
,
EDTUtil.invokeStop(java.lang.Runnable)
public final void start()
EDTUtil
start
in interface EDTUtil
public final boolean isCurrentThreadEDT()
isCurrentThreadEDT
in interface EDTUtil
public final boolean isRunning()
isRunning
in interface EDTUtil
public final void invokeStop(Runnable r)
EDTUtil
EDTUtil.reset()
may follow immediately, ie creating a new EDT
invokeStop
in interface EDTUtil
public final void invoke(boolean wait, Runnable r)
EDTUtil
wait == true
.
invoke
in interface EDTUtil
public final void waitUntilIdle()
EDTUtil
waitUntilIdle
in interface EDTUtil
public final void waitUntilStopped()
EDTUtil
stop
action is performed, EDTUtil.invokeStop(java.lang.Runnable)
should be used before.
waitUntilStopped
in interface EDTUtil
public void run()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |