- Timestamp:
- 07/06/13 03:51:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/dispatching/JoinableCollection.java
r96 r97 1 1 package com.framsticks.util.dispatching; 2 2 3 import java.util.AbstractCollection; 4 import java.util.Collection; 3 5 import java.util.Collections; 4 6 import java.util.HashSet; … … 42 44 if (this.state.equals(JoinableState.RUNNING)) { 43 45 Dispatching.use(joinable, this); 46 } 47 } 48 49 public synchronized void remove(T joinable) { 50 if (this.state.ordinal() > JoinableState.RUNNING.ordinal()) { 51 throw new FramsticksException().msg("failed to remote joinable - collection is passed running state").arg("joinable", joinable).arg("collection", this); 52 } 53 if (!joinables.contains(joinable)) { 54 throw new FramsticksException().msg("joinable is not observed").arg("joinable", joinable).arg("in", this); 55 } 56 57 joinables.remove(joinable); 58 59 if (this.state.equals(JoinableState.RUNNING)) { 60 Dispatching.drop(joinable, this); 44 61 } 45 62 } … … 140 157 } 141 158 159 public Collection<T> asCollection() { 160 return new AbstractCollection<T>() { 161 162 @Override 163 public Iterator<T> iterator() { 164 return JoinableCollection.this.iterator(); 165 } 166 167 @Override 168 public int size() { 169 return JoinableCollection.this.size(); 170 } 171 172 @Override 173 public boolean add(T joinable) { 174 JoinableCollection.this.add(joinable); 175 return true; 176 } 177 178 @SuppressWarnings("unchecked") 179 @Override 180 public boolean remove(Object joinable) { 181 JoinableCollection.this.remove((T) joinable); 182 return true; 183 } 184 }; 185 } 186 142 187 }
Note: See TracChangeset
for help on using the changeset viewer.