Lines Matching full:mutex
41 * serializable if the backing collection and the mutex are serializable.
43 * <p>If a {@code null} is passed as the {@code mutex} parameter to any of this
45 * uses itself as the synchronization mutex.
59 protected final Object mutex;
61 public SynchronizedObject(Object delegate, @Nullable Object mutex) {
63 this.mutex = (mutex == null) ? this : mutex;
73 synchronized (mutex) {
84 synchronized (mutex) {
94 * collection using the specified mutex. In order to guarantee serial access,
99 * mutex when iterating over the returned collection: <pre> {@code
102 * new HashSet<E>(), mutex);
104 * synchronized (mutex) {
117 Collection<E> collection, @Nullable Object mutex) {
118 return new SynchronizedCollection<E>(collection, mutex);
125 Collection<E> delegate, @Nullable Object mutex) {
126 super(delegate, mutex);
135 synchronized (mutex) {
141 synchronized (mutex) {
147 synchronized (mutex) {
153 synchronized (mutex) {
159 synchronized (mutex) {
165 synchronized (mutex) {
175 synchronized (mutex) {
181 synchronized (mutex) {
187 synchronized (mutex) {
193 synchronized (mutex) {
199 synchronized (mutex) {
205 synchronized (mutex) {
215 * the specified mutex. In order to guarantee serial access, it is critical
220 * mutex when iterating over the returned set: <pre> {@code
222 * Set<E> s = Synchronized.set(new HashSet<E>(), mutex);
224 * synchronized (mutex) {
236 public static <E> Set<E> set(Set<E> set, @Nullable Object mutex) {
237 return new SynchronizedSet<E>(set, mutex);
243 public SynchronizedSet(Set<E> delegate, @Nullable Object mutex) {
244 super(delegate, mutex);
255 synchronized (mutex) {
261 synchronized (mutex) {
271 * sorted set using the specified mutex. In order to guarantee serial access,
276 * mutex when iterating over the returned sorted set: <pre> {@code
279 * new TreeSet<E>(), mutex);
281 * synchronized (mutex) {
293 static <E> SortedSet<E> sortedSet(SortedSet<E> set, @Nullable Object mutex) {
294 return new SynchronizedSortedSet<E>(set, mutex);
301 SortedSet<E> delegate, @Nullable Object mutex) {
302 super(delegate, mutex);
310 synchronized (mutex) {
316 synchronized (mutex) {
317 return sortedSet(delegate().subSet(fromElement, toElement), mutex);
322 synchronized (mutex) {
323 return sortedSet(delegate().headSet(toElement), mutex);
328 synchronized (mutex) {
329 return sortedSet(delegate().tailSet(fromElement), mutex);
334 synchronized (mutex) {
340 synchronized (mutex) {
350 * using the specified mutex. In order to guarantee serial access, it is
355 * mutex when iterating over the returned list: <pre> {@code
357 * List<E> l = Synchronized.list(new ArrayList<E>(), mutex);
359 * synchronized (mutex) {
374 static <E> List<E> list(List<E> list, @Nullable Object mutex) {
376 ? new SynchronizedRandomAccessList<E>(list, mutex)
377 : new SynchronizedList<E>(list, mutex);
383 public SynchronizedList(List<E> delegate, @Nullable Object mutex) {
384 super(delegate, mutex);
392 synchronized (mutex) {
398 synchronized (mutex) {
404 synchronized (mutex) {
410 synchronized (mutex) {
416 synchronized (mutex) {
430 synchronized (mutex) {
436 synchronized (mutex) {
443 synchronized (mutex) {
444 return list(Platform.subList(delegate(), fromIndex, toIndex), mutex);
452 synchronized (mutex) {
458 synchronized (mutex) {
469 public SynchronizedRandomAccessList(List<E> list, @Nullable Object mutex) {
470 super(list, mutex);
477 * multiset using the specified mutex. In order to guarantee serial access, it
482 * mutex when iterating over the returned multiset: <pre> {@code
485 * HashMultiset.<E>create(), mutex);
487 * synchronized (mutex) {
500 Multiset<E> multiset, @Nullable Object mutex) {
501 return new SynchronizedMultiset<E>(multiset, mutex);
510 public SynchronizedMultiset(Multiset<E> delegate, @Nullable Object mutex) {
511 super(delegate, mutex);
519 synchronized (mutex) {
525 synchronized (mutex) {
531 synchronized (mutex) {
537 synchronized (mutex) {
543 synchronized (mutex) {
549 synchronized (mutex) {
551 elementSet = typePreservingSet(delegate().elementSet(), mutex);
558 synchronized (mutex) {
560 entrySet = typePreservingSet(delegate().entrySet(), mutex);
570 synchronized (mutex) {
576 mutex) {
586 * multimap using the specified mutex. In order to guarantee serial access, it
591 * mutex when accessing any of the return multimap's collection views:
595 * HashMultimap.create(), mutex);
599 * synchronized (mutex) {
612 Multimap<K, V> multimap, @Nullable Object mutex) {
613 return new SynchronizedMultimap<K, V>(multimap, mutex);
630 SynchronizedMultimap(Multimap<K, V> delegate, @Nullable Object mutex) {
631 super(delegate, mutex);
635 synchronized (mutex) {
641 synchronized (mutex) {
647 synchronized (mutex) {
653 synchronized (mutex) {
659 synchronized (mutex) {
665 synchronized (mutex) {
666 return typePreservingCollection(delegate().get(key), mutex);
671 synchronized (mutex) {
677 synchronized (mutex) {
683 synchronized (mutex) {
689 synchronized (mutex) {
695 synchronized (mutex) {
701 synchronized (mutex) {
707 synchronized (mutex) {
713 synchronized (mutex) {
715 keySet = typePreservingSet(delegate().keySet(), mutex);
722 synchronized (mutex) {
724 valuesCollection = collection(delegate().values(), mutex);
731 synchronized (mutex) {
733 entries = typePreservingCollection(delegate().entries(), mutex);
740 synchronized (mutex) {
742 asMap = new SynchronizedAsMap<K, V>(delegate().asMap(), mutex);
749 synchronized (mutex) {
751 keys = multiset(delegate().keys(), mutex);
761 synchronized (mutex) {
767 synchronized (mutex) {
777 * multimap using the specified mutex.
785 ListMultimap<K, V> multimap, @Nullable Object mutex) {
786 return new SynchronizedListMultimap<K, V>(multimap, mutex);
793 ListMultimap<K, V> delegate, @Nullable Object mutex) {
794 super(delegate, mutex);
800 synchronized (mutex) {
801 return list(delegate().get(key), mutex);
805 synchronized (mutex) {
811 synchronized (mutex) {
820 * multimap using the specified mutex.
828 SetMultimap<K, V> multimap, @Nullable Object mutex) {
829 return new SynchronizedSetMultimap<K, V>(multimap, mutex);
837 SetMultimap<K, V> delegate, @Nullable Object mutex) {
838 super(delegate, mutex);
844 synchronized (mutex) {
845 return set(delegate().get(key), mutex);
849 synchronized (mutex) {
855 synchronized (mutex) {
860 synchronized (mutex) {
862 entrySet = set(delegate().entries(), mutex);
872 * specified multimap using the specified mutex.
880 SortedSetMultimap<K, V> multimap, @Nullable Object mutex) {
881 return new SynchronizedSortedSetMultimap<K, V>(multimap, mutex);
888 SortedSetMultimap<K, V> delegate, @Nullable Object mutex) {
889 super(delegate, mutex);
895 synchronized (mutex) {
896 return sortedSet(delegate().get(key), mutex);
900 synchronized (mutex) {
906 synchronized (mutex) {
911 synchronized (mutex) {
920 * collection using the specified mutex. In order to guarantee serial access,
925 * mutex when iterating over the returned collection: <pre> {@code
928 * new HashSet<E>(), mutex);
930 * synchronized (mutex) {
947 Collection<E> collection, @Nullable Object mutex) {
949 return sortedSet((SortedSet<E>) collection, mutex);
951 return set((Set<E>) collection, mutex);
953 return list((List<E>) collection, mutex);
955 return collection(collection, mutex);
961 * the specified mutex. In order to guarantee serial access, it is critical
966 * mutex when iterating over the returned collection: <pre> {@code
969 * new HashSet<E>(), mutex);
971 * synchronized (mutex) {
987 Set<E> set, @Nullable Object mutex) {
989 return sortedSet((SortedSet<E>) set, mutex);
991 return set(set, mutex);
999 Set<Map.Entry<K, Collection<V>>> delegate, @Nullable Object mutex) {
1000 super(delegate, mutex);
1018 return typePreservingCollection(entry.getValue(), mutex);
1028 synchronized (mutex) {
1033 synchronized (mutex) {
1038 synchronized (mutex) {
1043 synchronized (mutex) {
1051 synchronized (mutex) {
1056 synchronized (mutex) {
1061 synchronized (mutex) {
1066 synchronized (mutex) {
1076 * the specified mutex. In order to guarantee serial access, it is critical
1081 * mutex when accessing any of the return map's collection views:
1085 * new HashMap<K, V>(), mutex);
1089 * synchronized (mutex) {
1101 public static <K, V> Map<K, V> map(Map<K, V> map, @Nullable Object mutex) {
1102 return new SynchronizedMap<K, V>(map, mutex);
1112 public SynchronizedMap(Map<K, V> delegate, @Nullable Object mutex) {
1113 super(delegate, mutex);
1122 synchronized (mutex) {
1128 synchronized (mutex) {
1134 synchronized (mutex) {
1140 synchronized (mutex) {
1142 entrySet = set(delegate().entrySet(), mutex);
1149 synchronized (mutex) {
1155 synchronized (mutex) {
1161 synchronized (mutex) {
1163 keySet = set(delegate().keySet(), mutex);
1170 synchronized (mutex) {
1176 synchronized (mutex) {
1182 synchronized (mutex) {
1188 synchronized (mutex) {
1194 synchronized (mutex) {
1196 values = collection(delegate().values(), mutex);
1206 synchronized (mutex) {
1212 synchronized (mutex) {
1222 * using the specified mutex. In order to guarantee serial access, it is
1227 * mutex when accessing any of the return bimap's collection views:
1231 * HashBiMap.<K, V>create(), mutex);
1235 * synchronized (mutex) {
1248 BiMap<K, V> bimap, @Nullable Object mutex) {
1249 return new SynchronizedBiMap<K, V>(bimap, mutex, null);
1259 BiMap<K, V> delegate, @Nullable Object mutex,
1261 super(delegate, mutex);
1270 synchronized (mutex) {
1272 valueSet = set(delegate().values(), mutex);
1279 synchronized (mutex) {
1285 synchronized (mutex) {
1288 = new SynchronizedBiMap<V, K>(delegate().inverse(), mutex, this);
1304 Map<K, Collection<V>> delegate, @Nullable Object mutex) {
1305 super(delegate, mutex);
1309 synchronized (mutex) {
1312 : typePreservingCollection(collection, mutex);
1317 synchronized (mutex) {
1320 delegate().entrySet(), mutex);
1327 synchronized (mutex) {
1330 = new SynchronizedAsMapValues<V>(delegate().values(), mutex);
1348 Collection<Collection<V>> delegate, @Nullable Object mutex) {
1349 super(delegate, mutex);
1360 return typePreservingCollection(iterator.next(), mutex);