Merge pull request #420 from changxiangzhong:fix/cp-missing

PiperOrigin-RevId: 537014587
(cherry picked from commit 8166b3590fe7d629f55c1e8af27091f8309d4cb7)
parent f2b8b314
...@@ -97,14 +97,20 @@ public final class ListenerSet<T extends @NonNull Object> { ...@@ -97,14 +97,20 @@ public final class ListenerSet<T extends @NonNull Object> {
* during one {@link Looper} message queue iteration were handled by the listeners. * during one {@link Looper} message queue iteration were handled by the listeners.
*/ */
public ListenerSet(Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) { public ListenerSet(Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) {
this(/* listeners= */ new CopyOnWriteArraySet<>(), looper, clock, iterationFinishedEvent); this(
/* listeners= */ new CopyOnWriteArraySet<>(),
looper,
clock,
iterationFinishedEvent,
/* throwsWhenUsingWrongThread= */ true);
} }
private ListenerSet( private ListenerSet(
CopyOnWriteArraySet<ListenerHolder<T>> listeners, CopyOnWriteArraySet<ListenerHolder<T>> listeners,
Looper looper, Looper looper,
Clock clock, Clock clock,
IterationFinishedEvent<T> iterationFinishedEvent) { IterationFinishedEvent<T> iterationFinishedEvent,
boolean throwsWhenUsingWrongThread) {
this.clock = clock; this.clock = clock;
this.listeners = listeners; this.listeners = listeners;
this.iterationFinishedEvent = iterationFinishedEvent; this.iterationFinishedEvent = iterationFinishedEvent;
...@@ -115,7 +121,7 @@ public final class ListenerSet<T extends @NonNull Object> { ...@@ -115,7 +121,7 @@ public final class ListenerSet<T extends @NonNull Object> {
@SuppressWarnings("nullness:methodref.receiver.bound") @SuppressWarnings("nullness:methodref.receiver.bound")
HandlerWrapper handler = clock.createHandler(looper, this::handleMessage); HandlerWrapper handler = clock.createHandler(looper, this::handleMessage);
this.handler = handler; this.handler = handler;
throwsWhenUsingWrongThread = true; this.throwsWhenUsingWrongThread = throwsWhenUsingWrongThread;
} }
/** /**
...@@ -147,7 +153,8 @@ public final class ListenerSet<T extends @NonNull Object> { ...@@ -147,7 +153,8 @@ public final class ListenerSet<T extends @NonNull Object> {
@CheckResult @CheckResult
public ListenerSet<T> copy( public ListenerSet<T> copy(
Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) { Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) {
return new ListenerSet<>(listeners, looper, clock, iterationFinishedEvent); return new ListenerSet<>(
listeners, looper, clock, iterationFinishedEvent, throwsWhenUsingWrongThread);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment