public abstract class Connection extends Object implements Closeable
Closeable.Set, Closeable.Util
Constructor and Description |
---|
Connection() |
Modifier and Type | Method and Description |
---|---|
abstract Connection |
atPrio(int priority)
Changes the priority of this connection to the specified value.
|
abstract void |
close()
Disconnects this registration.
|
void |
disconnect()
Deprecated.
Call
close() instead. |
abstract Connection |
holdWeakly()
Changes this connection to one held by a weak reference.
|
static Connection |
join(Connection... conns)
Returns a single connection which aggregates all of the supplied connections.
|
abstract Connection |
once()
Converts this connection into a one-shot connection.
|
public static Connection join(Connection... conns)
public abstract void close()
close
in interface AutoCloseable
close
in interface Closeable
@Deprecated public void disconnect()
close()
instead.public abstract Connection once()
NOTE: if you are dispatching signals in a multithreaded environment, it is possible for your connected listener to be notified before this call has a chance to mark it as one-shot. Thus you could receive multiple notifications. If you require this to be avoided, you must synchronize on the signal/value/etc. on which you are adding a listener:
Signal<Foo> signal = ...;
Connection conn;
synchronized (signal) {
conn = signal.connect(slot).once();
}
public abstract Connection atPrio(int priority)
This should generally be done simultaneously with creating a connection. For example:
Signal<Foo> signal = ...;
Connection conn = signal.connect(new Slot<Foo>() { ... }).atPrio(5);
NOTE: if you are dispatching signals in a multithreaded environment, it is possible for your connected listener to be notified at priority zero before this call has a chance to update its priority. If you require this to be avoided, you must synchronize on the signal/value/etc. on which you are adding a listener:
Signal<Foo> signal = ...;
Connection conn;
synchronized (signal) {
conn = signal.connect(slot).atPrio(5);
}
public abstract Connection holdWeakly()
NOTE: weak references are not supported in JavaScript. When using this library in GWT, the reference remains strong.
Copyright © 2017. All rights reserved.