File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,9 @@ func (pq *PriorityQueue) Put(items ...Item) error {
120120 }
121121
122122 pq .lock .Lock ()
123+ defer pq .lock .Unlock ()
124+
123125 if pq .disposed {
124- pq .lock .Unlock ()
125126 return ErrDisposed
126127 }
127128
@@ -146,7 +147,6 @@ func (pq *PriorityQueue) Put(items ...Item) error {
146147 }
147148 }
148149
149- pq .lock .Unlock ()
150150 return nil
151151}
152152
@@ -180,12 +180,10 @@ func (pq *PriorityQueue) Get(number int) ([]Item, error) {
180180 pq .lock .Unlock ()
181181
182182 <- sema .ready
183- pq .disposeLock .Lock ()
184- if pq .disposed {
185- pq .disposeLock .Unlock ()
183+
184+ if pq .Disposed () {
186185 return nil , ErrDisposed
187186 }
188- pq .disposeLock .Unlock ()
189187
190188 items = pq .items .get (number )
191189 deleteItems (items )
@@ -228,8 +226,8 @@ func (pq *PriorityQueue) Len() int {
228226
229227// Disposed returns a bool indicating if this queue has been disposed.
230228func (pq * PriorityQueue ) Disposed () bool {
231- pq .lock .Lock ()
232- defer pq .lock .Unlock ()
229+ pq .disposeLock .Lock ()
230+ defer pq .disposeLock .Unlock ()
233231
234232 return pq .disposed
235233}
You can’t perform that action at this time.
0 commit comments