Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/Event.java

Issue 2033573002: [Chromoting] Final SelfRemovableParameterRunnable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import java.util.HashSet; 7 import java.util.HashSet;
8 8
9 /** 9 /**
10 * A thread-safe event queue which provides both {@link #add} and {@link #remove } functions with 10 * A thread-safe event queue which provides both {@link #add} and {@link #remove } functions with
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 private void execute(Object obj, ParamT parameter) { 60 private void execute(Object obj, ParamT parameter) {
61 ParameterRunnable<ParamT> runnable = (ParameterRunnable<ParamT>) obj ; 61 ParameterRunnable<ParamT> runnable = (ParameterRunnable<ParamT>) obj ;
62 runnable.run(parameter); 62 runnable.run(parameter);
63 } 63 }
64 } 64 }
65 65
66 /** 66 /**
67 * A self removable {@link ParameterRunner}, uses a boolean {@link Parameter Callback} to decide 67 * A self removable {@link ParameterRunner}, uses a boolean {@link Parameter Callback} to decide
68 * whether removes self from {@link Event} or not. 68 * whether removes self from {@link Event} or not.
69 */ 69 */
70 private static class SelfRemovableParameterRunnable<ParamT> 70 private static final class SelfRemovableParameterRunnable<ParamT>
71 implements ParameterRunnable<ParamT> { 71 implements ParameterRunnable<ParamT> {
72 private final ParameterCallback<Boolean, ParamT> mCallback; 72 private final ParameterCallback<Boolean, ParamT> mCallback;
73 private final Event<ParamT> mOwner; 73 private final Event<ParamT> mOwner;
74 74
75 // This lock is used to make sure mEvent is correctly set before remove in run function. 75 // This lock is used to make sure mEvent is correctly set before remove in run function.
76 // i.e. mOwner.add and assigment of mEvent need to be atomic. 76 // i.e. mOwner.add and assigment of mEvent need to be atomic.
77 private final Object mLock; 77 private final Object mLock;
78 private final Object mEvent; 78 private final Object mEvent;
79 79
80 private SelfRemovableParameterRunnable(Event<ParamT> owner, 80 private SelfRemovableParameterRunnable(Event<ParamT> owner,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 /** 168 /**
169 * Returns true if there is no runnable attached to current instance. 169 * Returns true if there is no runnable attached to current instance.
170 */ 170 */
171 public boolean isEmpty() { 171 public boolean isEmpty() {
172 synchronized (mSet) { 172 synchronized (mSet) {
173 return mSet.isEmpty(); 173 return mSet.isEmpty();
174 } 174 }
175 } 175 }
176 } 176 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698