public interface ThreadsActivationListener
ThreadsListener
, therefore
the implementation of the threads activation listener needs to be designed for compilation. Care
needs to be taken to not unnecessarily slow down thread activation.
The event notification starts immediately after the listener is registered. It is therefore
possible that ThreadsActivationListener.onLeaveThread(TruffleContext)
is called without
ThreadsActivationListener.onEnterThread(TruffleContext)
ever being invoked, if the listener is attached in
parallel. When any of the listener methods are executed then the
ThreadsActivationListener
is guaranteed to be a
partial evaluation constant
. The
provided TruffleContext
may be a PE constant, but it is not guaranteed.
Common use-cases for threads activation include capturing the time the context is active, changing thread priorities or measuring thread allocated bytes of a context.
to register a
listener
Modifier and Type | Method and Description |
---|---|
void |
onEnterThread(TruffleContext context)
Notified when a context is entered on the
current thread . |
void |
onLeaveThread(TruffleContext context)
Notified when a context is entered on the
current thread . |
void onEnterThread(TruffleContext context)
current thread
.
Entering a thread indicates that the context is currently active. A context maybe entered
multiple times per thread. This method is executed frequently and must be designed for
compilation. If this method throws an
AbstractTruffleException
the exception interop
messages may be executed without a context being entered.context
- the context being entered on the current threadvoid onLeaveThread(TruffleContext context)
current thread
.
Leaving a thread indicates that the context is no longer active on that thread. A context
maybe left multiple times per thread. This method is executed frequently and must be designed
for compilation.context
- the context being left on the current thread