public interface Caller
Any time a stage needs to invoke user-specified code the call is wrapped in
execute(Runnable)
. This allows the user to implement policies and safe guard for how
these interactions should happen by providing their own caller implementation.
The implementation of these methods will be invoked from the calling thread that interacts with the stage.
The core of the framework provides some base classes for easily accomplishing this, most
notable is DirectCaller
.
Modifier and Type | Method and Description |
---|---|
void |
execute(Runnable runnable)
Execute the given action.
|
void |
referenceLeaked(Object reference,
StackTraceElement[] stack)
Indicate that a Managed reference has been leaked.
|
void referenceLeaked(Object reference, StackTraceElement[] stack)
This is usually called by end-user code that never releases a managed reference, like this:
public static class Example {
private final Async async;
private final Managed<Database> database;
public Example(final Async async, final Managed<Database> database) {
this.async = async;
this.database = database;
}
public Stage<Void> doSomething() {
return database.doto(database -> {
Completable<Void> stage = async.completable();
return stage;
});
}
}
This leaves the managed database in an open state since its reference count will never go back to zero. When the stage and the corresponding borrowed is garbage collected, it will be reported here.
reference
- the reference that was leakedstack
- the stacktrace for where it was leaked, can be null
if the information is
unavailablevoid execute(Runnable runnable)
runnable
- action to executeCopyright © 2017. All rights reserved.