Class AppContextInfo
- java.lang.Object
-
- com.jogamp.nativewindow.awt.AppContextInfo
-
public class AppContextInfo extends Object
Instance of this class holds information about aThreadGroup
associatedAppContext
.Non intrusive workaround for Bug 983 and Bug 1004, see
getCachedThreadGroup()
.
-
-
Constructor Summary
Constructors Constructor Description AppContextInfo(String info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadGroup
getCachedThreadGroup()
RunnableTask
invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
boolean
isValid()
Returnstrue
if this instance has validAppContext
information, i.e.boolean
update(String info)
UpdateAppContext
information for the current ThreadGroup if uninitialized orAppContext
changed.
-
-
-
Constructor Detail
-
AppContextInfo
public AppContextInfo(String info)
-
-
Method Detail
-
isValid
public final boolean isValid()
Returnstrue
if this instance has validAppContext
information, i.e.getCachedThreadGroup()
returns notnull
.
-
getCachedThreadGroup
public final ThreadGroup getCachedThreadGroup()
Returns theThreadGroup
belonging to the last knownAppContext
as queried viaupdate(String)
.Returns
null
if noAppContext
has been queried.The returned
ThreadGroup
allows users to create a custom thread belonging to it and hence mitigating Bug 983 and Bug 1004.update(String)
should be called from a thread belonging to the desiredAppContext
, i.e. early from within the special threaded application.E.g.
JAWTWindow
issuesupdate(String)
in it's constructor.
-
invokeOnAppContextThread
public RunnableTask invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
Invokesrunnable
on aThread
belonging to theAppContext
ThreadGroup
, seegetCachedThreadGroup()
.update(String)
is issued first, which returnstrue
if the current thread belongs to an AppContextThreadGroup
. In this case therunnable
is invoked on the current thread, otherwise a newThread
will be started.If a new
Thread
is required, the AppContextThreadGroup
is being used ifavailable
, otherwise the default systemThreadGroup
.- Parameters:
waitUntilDone
- iftrue
, waits untilrunnable
execution is completed, otherwise returns immediately.runnable
- theRunnable
to be executed. IfwaitUntilDone
istrue
, the runnable must exist, i.e. not loop forever.threadBaseName
- the base name for the new thread if required. The resulting thread name will have either '-OnAppContextTG' or '-OnSystemTG' appended- Returns:
- the
Thread
used to invoke therunnable
, which may be the currentThread
or a newly created one, see above.
-
update
public final boolean update(String info)
UpdateAppContext
information for the current ThreadGroup if uninitialized orAppContext
changed.See
getCachedThreadGroup()
for usage.- Parameters:
info
- informal string for logging purposes- Returns:
true
if the current ThreadGroup is mapped to anAppContext
and the information is good, otherwise false.
-
-