Home | History | Annotate | Download | only in ch

Lines Matching defs:list

66      * @return  The list of file locks removed
68 public abstract List<FileLock> removeAll();
85 * SharedFileLockTable uses a list of file lock references to avoid keeping the
104 // The map value is a list of file locks represented by FileLockReferences.
105 // All access to the list must be synchronized on the list.
106 private static ConcurrentHashMap<FileKey, List<FileLockReference>> lockMap =
107 new ConcurrentHashMap<FileKey, List<FileLockReference>>();
125 List<FileLockReference> list = lockMap.get(fileKey);
130 if (list == null) {
131 list = new ArrayList<FileLockReference>(2);
132 List<FileLockReference> prev;
133 synchronized (list) {
134 prev = lockMap.putIfAbsent(fileKey, list);
137 list.add(new FileLockReference(fl, queue, fileKey));
142 list = prev;
147 // hasn't changed then we check the list for overlapping locks
148 // and add the new lock to the list.
149 synchronized (list) {
150 List<FileLockReference> current = lockMap.get(fileKey);
151 if (list == current) {
152 checkList(list, fl.position(), fl.size());
153 list.add(new FileLockReference(fl, queue, fileKey));
156 list = current;
165 private void removeKeyIfEmpty(FileKey fk, List<FileLockReference> list) {
166 assert Thread.holdsLock(list);
167 assert lockMap.get(fk) == list;
168 if (list.isEmpty()) {
177 // the lock must exist so the list of locks must be present
178 List<FileLockReference> list = lockMap.get(fileKey);
179 if (list == null) return;
181 synchronized (list) {
183 while (index < list.size()) {
184 FileLockReference ref = list.get(index);
189 list.remove(index);
198 public List<FileLock> removeAll() {
199 List<FileLock> result = new ArrayList<FileLock>();
200 List<FileLockReference> list = lockMap.get(fileKey);
201 if (list != null) {
202 synchronized (list) {
204 while (index < list.size()) {
205 FileLockReference ref = list.get(index);
210 // remove the lock from the list
212 list.remove(index);
221 // once the lock list is empty we remove it from the map
222 removeKeyIfEmpty(fileKey, list);
230 // the lock must exist so there must be a list
231 List<FileLockReference> list = lockMap.get(fileKey);
232 assert list != null;
234 synchronized (list) {
235 for (int index=0; index<list.size(); index++) {
236 FileLockReference ref = list.get(index);
240 list.set(index, new FileLockReference(toLock, queue, fileKey));
248 private void checkList(List<FileLockReference> list, long position, long size)
251 assert Thread.holdsLock(list);
252 for (FileLockReference ref: list) {
264 List<FileLockReference> list = lockMap.get(fk);
265 if (list != null) {
266 synchronized (list) {
267 list.remove(ref);
268 removeKeyIfEmpty(fk, list);