Skip to content

Commit fb458b4

Browse files
author
electricessence
committed
Disabled Pocket use for ConcurrentQueueObjectPool.
1 parent 13e813d commit fb458b4

6 files changed

Lines changed: 187 additions & 169 deletions

File tree

benchmarking/BenchmarkResult.csv

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Batch,Pool Type," From Empty (In Parallel)"," To (In Parallel)",d Read/Write (In Parallel),y Pool (.TryTake()),L,
2-
Repeat 200000 for size 4,QueueObjectPool,00:00:01.1287292,00:00:01.0294513,00:00:01.0260755,00:00:00.1590331,00:00:03.3432891,
3-
Repeat 200000 for size 4,ConcurrentQueueObjectPool,00:00:01.1514246,00:00:01.0375667,00:00:01.0105712,00:00:00.1741179,00:00:03.3736804,
4-
Repeat 200000 for size 4,ConcurrentStackObjectPool,00:00:01.0247996,00:00:00.9655175,00:00:00.9336741,00:00:00.1360451,00:00:03.0600363,
5-
Repeat 200000 for size 4,OptimisticArrayObjectPool,00:00:01.0468743,00:00:00.8456746,00:00:00.8382048,00:00:00.1628778,00:00:02.8936315,
6-
Repeat 80000 for size 10,QueueObjectPool,00:00:00.5433300,00:00:00.5461789,00:00:00.4759666,00:00:00.1333091,00:00:01.6987846,
7-
Repeat 80000 for size 10,ConcurrentQueueObjectPool,00:00:00.5099808,00:00:00.4864080,00:00:00.5001707,00:00:00.1520913,00:00:01.6486508,
8-
Repeat 80000 for size 10,ConcurrentStackObjectPool,00:00:00.5763228,00:00:00.5440804,00:00:00.5287139,00:00:00.1281674,00:00:01.7772845,
9-
Repeat 80000 for size 10,OptimisticArrayObjectPool,00:00:00.6038049,00:00:00.5263031,00:00:00.4762357,00:00:00.2268198,00:00:01.8331635,
10-
Repeat 24000 for size 50,QueueObjectPool,00:00:00.2580179,00:00:00.4086527,00:00:00.2688232,00:00:00.1734043,00:00:01.1088981,
11-
Repeat 24000 for size 50,ConcurrentQueueObjectPool,00:00:00.2592864,00:00:00.2647728,00:00:00.2407817,00:00:00.2021228,00:00:00.9669637,
12-
Repeat 24000 for size 50,ConcurrentStackObjectPool,00:00:00.2676966,00:00:00.3135490,00:00:00.2759068,00:00:00.2042573,00:00:01.0614097,
13-
Repeat 24000 for size 50,OptimisticArrayObjectPool,00:00:00.3239524,00:00:00.3545534,00:00:00.2256836,00:00:00.8061559,00:00:01.7103453,
14-
Repeat 16000 for size 100,QueueObjectPool,00:00:00.2503055,00:00:00.4926017,00:00:00.3241812,00:00:00.2220571,00:00:01.2891455,
15-
Repeat 16000 for size 100,ConcurrentQueueObjectPool,00:00:00.2482971,00:00:00.2783954,00:00:00.2356915,00:00:00.2691699,00:00:01.0315539,
16-
Repeat 16000 for size 100,ConcurrentStackObjectPool,00:00:00.2590476,00:00:00.3642821,00:00:00.3237909,00:00:00.3202590,00:00:01.2673796,
17-
Repeat 16000 for size 100,OptimisticArrayObjectPool,00:00:00.3215564,00:00:00.4745108,00:00:00.1784334,00:00:01.5867222,00:00:02.5612228,
18-
Repeat 25600 for size 250,QueueObjectPool,00:00:00.7252826,00:00:01.7557360,00:00:01.1939824,00:00:00.8119776,00:00:04.4869786,
19-
Repeat 25600 for size 250,ConcurrentQueueObjectPool,00:00:00.7722675,00:00:00.9039538,00:00:00.7259809,00:00:01.0339628,00:00:03.4361650,
20-
Repeat 25600 for size 250,ConcurrentStackObjectPool,00:00:00.7369296,00:00:01.5097271,00:00:01.5271033,00:00:01.7198474,00:00:05.4936074,
21-
Repeat 25600 for size 250,OptimisticArrayObjectPool,00:00:01.2872667,00:00:03.1949158,00:00:00.5262142,00:00:11.7748329,00:00:16.7832296,
2+
Repeat 200000 for size 4,QueueObjectPool,00:00:01.0947249,00:00:00.9968247,00:00:00.9656608,00:00:00.1521333,00:00:03.2093437,
3+
Repeat 200000 for size 4,ConcurrentQueueObjectPool,00:00:01.1280539,00:00:01.0784355,00:00:01.0181790,00:00:00.1777503,00:00:03.4024187,
4+
Repeat 200000 for size 4,ConcurrentStackObjectPool,00:00:01.1002830,00:00:01.0578873,00:00:00.9720418,00:00:00.1441359,00:00:03.2743480,
5+
Repeat 200000 for size 4,OptimisticArrayObjectPool,00:00:01.0957806,00:00:00.9225542,00:00:00.8814923,00:00:00.1739174,00:00:03.0737445,
6+
Repeat 80000 for size 10,QueueObjectPool,00:00:00.5346130,00:00:00.5352514,00:00:00.4743420,00:00:00.1366686,00:00:01.6808750,
7+
Repeat 80000 for size 10,ConcurrentQueueObjectPool,00:00:00.5718558,00:00:00.5354731,00:00:00.5125773,00:00:00.1602205,00:00:01.7801267,
8+
Repeat 80000 for size 10,ConcurrentStackObjectPool,00:00:00.5552188,00:00:00.5154776,00:00:00.4801922,00:00:00.1249209,00:00:01.6758095,
9+
Repeat 80000 for size 10,OptimisticArrayObjectPool,00:00:00.5270367,00:00:00.4550340,00:00:00.4407644,00:00:00.2186592,00:00:01.6414943,
10+
Repeat 24000 for size 50,QueueObjectPool,00:00:00.2622830,00:00:00.4367957,00:00:00.2884833,00:00:00.1834193,00:00:01.1709813,
11+
Repeat 24000 for size 50,ConcurrentQueueObjectPool,00:00:00.2719027,00:00:00.2854846,00:00:00.2650888,00:00:00.2203011,00:00:01.0427772,
12+
Repeat 24000 for size 50,ConcurrentStackObjectPool,00:00:00.2640431,00:00:00.3351598,00:00:00.2996782,00:00:00.2149665,00:00:01.1138476,
13+
Repeat 24000 for size 50,OptimisticArrayObjectPool,00:00:00.3047471,00:00:00.3823836,00:00:00.2115898,00:00:00.8433052,00:00:01.7420257,
14+
Repeat 16000 for size 100,QueueObjectPool,00:00:00.2680744,00:00:00.4845459,00:00:00.3117290,00:00:00.2375035,00:00:01.3018528,
15+
Repeat 16000 for size 100,ConcurrentQueueObjectPool,00:00:00.2620082,00:00:00.2949254,00:00:00.2538674,00:00:00.2908684,00:00:01.1016694,
16+
Repeat 16000 for size 100,ConcurrentStackObjectPool,00:00:00.2735071,00:00:00.3903024,00:00:00.3434028,00:00:00.3366711,00:00:01.3438834,
17+
Repeat 16000 for size 100,OptimisticArrayObjectPool,00:00:00.7922812,00:00:00.6641963,00:00:00.2030016,00:00:01.7548815,00:00:03.4143606,
18+
Repeat 25600 for size 250,QueueObjectPool,00:00:00.7668417,00:00:01.8047414,00:00:01.3185354,00:00:00.8664007,00:00:04.7565192,
19+
Repeat 25600 for size 250,ConcurrentQueueObjectPool,00:00:00.8378978,00:00:00.9370109,00:00:00.7695238,00:00:01.0984692,00:00:03.6429017,
20+
Repeat 25600 for size 250,ConcurrentStackObjectPool,00:00:00.7848982,00:00:01.5942377,00:00:01.5995650,00:00:01.7959374,00:00:05.7746383,
21+
Repeat 25600 for size 250,OptimisticArrayObjectPool,00:00:01.2561773,00:00:03.2871367,00:00:00.5424299,00:00:12.0158755,00:00:17.1016194,
2222
Repeat 14400 for size 500,QueueObjectPool,00:00:00.7797824,00:00:01.6503887,00:00:01.3768657,00:00:00.8861150,00:00:04.6931518,
2323
Repeat 14400 for size 500,ConcurrentQueueObjectPool,00:00:00.7994849,00:00:00.9658497,00:00:00.7778244,00:00:01.1149906,00:00:03.6581496,
2424
Repeat 14400 for size 500,ConcurrentStackObjectPool,00:00:00.7487525,00:00:02.3665267,00:00:02.6608263,00:00:03.0226290,00:00:08.7987345,

benchmarking/BenchmarkResult.txt

Lines changed: 100 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -2,191 +2,159 @@ Repeat 200000 for size 4
22
------------------------------------
33

44
QueueObjectPool.........................................
5-
00:00:01.1287292 Take From Empty (In Parallel)
6-
00:00:01.0294513 Give To (In Parallel)
7-
00:00:01.0260755 Mixed Read/Write (In Parallel)
8-
00:00:00.1590331 Empty Pool (.TryTake())
9-
00:00:03.3432891 TOTAL
5+
00:00:01.0947249 Take From Empty (In Parallel)
6+
00:00:00.9968247 Give To (In Parallel)
7+
00:00:00.9656608 Mixed Read/Write (In Parallel)
8+
00:00:00.1521333 Empty Pool (.TryTake())
9+
00:00:03.2093437 TOTAL
1010

1111
ConcurrentQueueObjectPool...............................
12-
00:00:01.1514246 Take From Empty (In Parallel)
13-
00:00:01.0375667 Give To (In Parallel)
14-
00:00:01.0105712 Mixed Read/Write (In Parallel)
15-
00:00:00.1741179 Empty Pool (.TryTake())
16-
00:00:03.3736804 TOTAL
12+
00:00:01.1280539 Take From Empty (In Parallel)
13+
00:00:01.0784355 Give To (In Parallel)
14+
00:00:01.0181790 Mixed Read/Write (In Parallel)
15+
00:00:00.1777503 Empty Pool (.TryTake())
16+
00:00:03.4024187 TOTAL
1717

1818
ConcurrentStackObjectPool...............................
19-
00:00:01.0247996 Take From Empty (In Parallel)
20-
00:00:00.9655175 Give To (In Parallel)
21-
00:00:00.9336741 Mixed Read/Write (In Parallel)
22-
00:00:00.1360451 Empty Pool (.TryTake())
23-
00:00:03.0600363 TOTAL
19+
00:00:01.1002830 Take From Empty (In Parallel)
20+
00:00:01.0578873 Give To (In Parallel)
21+
00:00:00.9720418 Mixed Read/Write (In Parallel)
22+
00:00:00.1441359 Empty Pool (.TryTake())
23+
00:00:03.2743480 TOTAL
2424

2525
OptimisticArrayObjectPool...............................
26-
00:00:01.0468743 Take From Empty (In Parallel)
27-
00:00:00.8456746 Give To (In Parallel)
28-
00:00:00.8382048 Mixed Read/Write (In Parallel)
29-
00:00:00.1628778 Empty Pool (.TryTake())
30-
00:00:02.8936315 TOTAL
26+
00:00:01.0957806 Take From Empty (In Parallel)
27+
00:00:00.9225542 Give To (In Parallel)
28+
00:00:00.8814923 Mixed Read/Write (In Parallel)
29+
00:00:00.1739174 Empty Pool (.TryTake())
30+
00:00:03.0737445 TOTAL
3131

3232

3333
Repeat 80000 for size 10
3434
------------------------------------
3535

3636
QueueObjectPool.........................................
37-
00:00:00.5433300 Take From Empty (In Parallel)
38-
00:00:00.5461789 Give To (In Parallel)
39-
00:00:00.4759666 Mixed Read/Write (In Parallel)
40-
00:00:00.1333091 Empty Pool (.TryTake())
41-
00:00:01.6987846 TOTAL
37+
00:00:00.5346130 Take From Empty (In Parallel)
38+
00:00:00.5352514 Give To (In Parallel)
39+
00:00:00.4743420 Mixed Read/Write (In Parallel)
40+
00:00:00.1366686 Empty Pool (.TryTake())
41+
00:00:01.6808750 TOTAL
4242

4343
ConcurrentQueueObjectPool...............................
44-
00:00:00.5099808 Take From Empty (In Parallel)
45-
00:00:00.4864080 Give To (In Parallel)
46-
00:00:00.5001707 Mixed Read/Write (In Parallel)
47-
00:00:00.1520913 Empty Pool (.TryTake())
48-
00:00:01.6486508 TOTAL
44+
00:00:00.5718558 Take From Empty (In Parallel)
45+
00:00:00.5354731 Give To (In Parallel)
46+
00:00:00.5125773 Mixed Read/Write (In Parallel)
47+
00:00:00.1602205 Empty Pool (.TryTake())
48+
00:00:01.7801267 TOTAL
4949

5050
ConcurrentStackObjectPool...............................
51-
00:00:00.5763228 Take From Empty (In Parallel)
52-
00:00:00.5440804 Give To (In Parallel)
53-
00:00:00.5287139 Mixed Read/Write (In Parallel)
54-
00:00:00.1281674 Empty Pool (.TryTake())
55-
00:00:01.7772845 TOTAL
51+
00:00:00.5552188 Take From Empty (In Parallel)
52+
00:00:00.5154776 Give To (In Parallel)
53+
00:00:00.4801922 Mixed Read/Write (In Parallel)
54+
00:00:00.1249209 Empty Pool (.TryTake())
55+
00:00:01.6758095 TOTAL
5656

5757
OptimisticArrayObjectPool...............................
58-
00:00:00.6038049 Take From Empty (In Parallel)
59-
00:00:00.5263031 Give To (In Parallel)
60-
00:00:00.4762357 Mixed Read/Write (In Parallel)
61-
00:00:00.2268198 Empty Pool (.TryTake())
62-
00:00:01.8331635 TOTAL
58+
00:00:00.5270367 Take From Empty (In Parallel)
59+
00:00:00.4550340 Give To (In Parallel)
60+
00:00:00.4407644 Mixed Read/Write (In Parallel)
61+
00:00:00.2186592 Empty Pool (.TryTake())
62+
00:00:01.6414943 TOTAL
6363

6464

6565
Repeat 24000 for size 50
6666
------------------------------------
6767

6868
QueueObjectPool.........................................
69-
00:00:00.2580179 Take From Empty (In Parallel)
70-
00:00:00.4086527 Give To (In Parallel)
71-
00:00:00.2688232 Mixed Read/Write (In Parallel)
72-
00:00:00.1734043 Empty Pool (.TryTake())
73-
00:00:01.1088981 TOTAL
69+
00:00:00.2622830 Take From Empty (In Parallel)
70+
00:00:00.4367957 Give To (In Parallel)
71+
00:00:00.2884833 Mixed Read/Write (In Parallel)
72+
00:00:00.1834193 Empty Pool (.TryTake())
73+
00:00:01.1709813 TOTAL
7474

7575
ConcurrentQueueObjectPool...............................
76-
00:00:00.2592864 Take From Empty (In Parallel)
77-
00:00:00.2647728 Give To (In Parallel)
78-
00:00:00.2407817 Mixed Read/Write (In Parallel)
79-
00:00:00.2021228 Empty Pool (.TryTake())
80-
00:00:00.9669637 TOTAL
76+
00:00:00.2719027 Take From Empty (In Parallel)
77+
00:00:00.2854846 Give To (In Parallel)
78+
00:00:00.2650888 Mixed Read/Write (In Parallel)
79+
00:00:00.2203011 Empty Pool (.TryTake())
80+
00:00:01.0427772 TOTAL
8181

8282
ConcurrentStackObjectPool...............................
83-
00:00:00.2676966 Take From Empty (In Parallel)
84-
00:00:00.3135490 Give To (In Parallel)
85-
00:00:00.2759068 Mixed Read/Write (In Parallel)
86-
00:00:00.2042573 Empty Pool (.TryTake())
87-
00:00:01.0614097 TOTAL
83+
00:00:00.2640431 Take From Empty (In Parallel)
84+
00:00:00.3351598 Give To (In Parallel)
85+
00:00:00.2996782 Mixed Read/Write (In Parallel)
86+
00:00:00.2149665 Empty Pool (.TryTake())
87+
00:00:01.1138476 TOTAL
8888

8989
OptimisticArrayObjectPool...............................
90-
00:00:00.3239524 Take From Empty (In Parallel)
91-
00:00:00.3545534 Give To (In Parallel)
92-
00:00:00.2256836 Mixed Read/Write (In Parallel)
93-
00:00:00.8061559 Empty Pool (.TryTake())
94-
00:00:01.7103453 TOTAL
90+
00:00:00.3047471 Take From Empty (In Parallel)
91+
00:00:00.3823836 Give To (In Parallel)
92+
00:00:00.2115898 Mixed Read/Write (In Parallel)
93+
00:00:00.8433052 Empty Pool (.TryTake())
94+
00:00:01.7420257 TOTAL
9595

9696

9797
Repeat 16000 for size 100
9898
------------------------------------
9999

100100
QueueObjectPool.........................................
101-
00:00:00.2503055 Take From Empty (In Parallel)
102-
00:00:00.4926017 Give To (In Parallel)
103-
00:00:00.3241812 Mixed Read/Write (In Parallel)
104-
00:00:00.2220571 Empty Pool (.TryTake())
105-
00:00:01.2891455 TOTAL
101+
00:00:00.2680744 Take From Empty (In Parallel)
102+
00:00:00.4845459 Give To (In Parallel)
103+
00:00:00.3117290 Mixed Read/Write (In Parallel)
104+
00:00:00.2375035 Empty Pool (.TryTake())
105+
00:00:01.3018528 TOTAL
106106

107107
ConcurrentQueueObjectPool...............................
108-
00:00:00.2482971 Take From Empty (In Parallel)
109-
00:00:00.2783954 Give To (In Parallel)
110-
00:00:00.2356915 Mixed Read/Write (In Parallel)
111-
00:00:00.2691699 Empty Pool (.TryTake())
112-
00:00:01.0315539 TOTAL
108+
00:00:00.2620082 Take From Empty (In Parallel)
109+
00:00:00.2949254 Give To (In Parallel)
110+
00:00:00.2538674 Mixed Read/Write (In Parallel)
111+
00:00:00.2908684 Empty Pool (.TryTake())
112+
00:00:01.1016694 TOTAL
113113

114114
ConcurrentStackObjectPool...............................
115-
00:00:00.2590476 Take From Empty (In Parallel)
116-
00:00:00.3642821 Give To (In Parallel)
117-
00:00:00.3237909 Mixed Read/Write (In Parallel)
118-
00:00:00.3202590 Empty Pool (.TryTake())
119-
00:00:01.2673796 TOTAL
115+
00:00:00.2735071 Take From Empty (In Parallel)
116+
00:00:00.3903024 Give To (In Parallel)
117+
00:00:00.3434028 Mixed Read/Write (In Parallel)
118+
00:00:00.3366711 Empty Pool (.TryTake())
119+
00:00:01.3438834 TOTAL
120120

121121
OptimisticArrayObjectPool...............................
122-
00:00:00.3215564 Take From Empty (In Parallel)
123-
00:00:00.4745108 Give To (In Parallel)
124-
00:00:00.1784334 Mixed Read/Write (In Parallel)
125-
00:00:01.5867222 Empty Pool (.TryTake())
126-
00:00:02.5612228 TOTAL
122+
00:00:00.7922812 Take From Empty (In Parallel)
123+
00:00:00.6641963 Give To (In Parallel)
124+
00:00:00.2030016 Mixed Read/Write (In Parallel)
125+
00:00:01.7548815 Empty Pool (.TryTake())
126+
00:00:03.4143606 TOTAL
127127

128128

129129
Repeat 25600 for size 250
130130
------------------------------------
131131

132132
QueueObjectPool.........................................
133-
00:00:00.7252826 Take From Empty (In Parallel)
134-
00:00:01.7557360 Give To (In Parallel)
135-
00:00:01.1939824 Mixed Read/Write (In Parallel)
136-
00:00:00.8119776 Empty Pool (.TryTake())
137-
00:00:04.4869786 TOTAL
133+
00:00:00.7668417 Take From Empty (In Parallel)
134+
00:00:01.8047414 Give To (In Parallel)
135+
00:00:01.3185354 Mixed Read/Write (In Parallel)
136+
00:00:00.8664007 Empty Pool (.TryTake())
137+
00:00:04.7565192 TOTAL
138138

139139
ConcurrentQueueObjectPool...............................
140-
00:00:00.7722675 Take From Empty (In Parallel)
141-
00:00:00.9039538 Give To (In Parallel)
142-
00:00:00.7259809 Mixed Read/Write (In Parallel)
143-
00:00:01.0339628 Empty Pool (.TryTake())
144-
00:00:03.4361650 TOTAL
140+
00:00:00.8378978 Take From Empty (In Parallel)
141+
00:00:00.9370109 Give To (In Parallel)
142+
00:00:00.7695238 Mixed Read/Write (In Parallel)
143+
00:00:01.0984692 Empty Pool (.TryTake())
144+
00:00:03.6429017 TOTAL
145145

146146
ConcurrentStackObjectPool...............................
147-
00:00:00.7369296 Take From Empty (In Parallel)
148-
00:00:01.5097271 Give To (In Parallel)
149-
00:00:01.5271033 Mixed Read/Write (In Parallel)
150-
00:00:01.7198474 Empty Pool (.TryTake())
151-
00:00:05.4936074 TOTAL
147+
00:00:00.7848982 Take From Empty (In Parallel)
148+
00:00:01.5942377 Give To (In Parallel)
149+
00:00:01.5995650 Mixed Read/Write (In Parallel)
150+
00:00:01.7959374 Empty Pool (.TryTake())
151+
00:00:05.7746383 TOTAL
152152

153153
OptimisticArrayObjectPool...............................
154-
00:00:01.2872667 Take From Empty (In Parallel)
155-
00:00:03.1949158 Give To (In Parallel)
156-
00:00:00.5262142 Mixed Read/Write (In Parallel)
157-
00:00:11.7748329 Empty Pool (.TryTake())
158-
00:00:16.7832296 TOTAL
159-
160-
161-
Repeat 14400 for size 500
162-
------------------------------------
163-
164-
QueueObjectPool.........................................
165-
00:00:00.7797824 Take From Empty (In Parallel)
166-
00:00:01.6503887 Give To (In Parallel)
167-
00:00:01.3768657 Mixed Read/Write (In Parallel)
168-
00:00:00.8861150 Empty Pool (.TryTake())
169-
00:00:04.6931518 TOTAL
170-
171-
ConcurrentQueueObjectPool...............................
172-
00:00:00.7994849 Take From Empty (In Parallel)
173-
00:00:00.9658497 Give To (In Parallel)
174-
00:00:00.7778244 Mixed Read/Write (In Parallel)
175-
00:00:01.1149906 Empty Pool (.TryTake())
176-
00:00:03.6581496 TOTAL
177-
178-
ConcurrentStackObjectPool...............................
179-
00:00:00.7487525 Take From Empty (In Parallel)
180-
00:00:02.3665267 Give To (In Parallel)
181-
00:00:02.6608263 Mixed Read/Write (In Parallel)
182-
00:00:03.0226290 Empty Pool (.TryTake())
183-
00:00:08.7987345 TOTAL
184-
185-
OptimisticArrayObjectPool...............................
186-
00:00:01.0892049 Take From Empty (In Parallel)
187-
00:00:05.8599218 Give To (In Parallel)
188-
00:00:00.5797098 Mixed Read/Write (In Parallel)
189-
00:00:22.9215261 Empty Pool (.TryTake())
190-
00:00:30.4503626 TOTAL
154+
00:00:01.2561773 Take From Empty (In Parallel)
155+
00:00:03.2871367 Give To (In Parallel)
156+
00:00:00.5424299 Mixed Read/Write (In Parallel)
157+
00:00:12.0158755 Empty Pool (.TryTake())
158+
00:00:17.1016194 TOTAL
191159

192160

source/Array/OptimisticArrayObjectPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public OptimisticArrayObjectPool(Func<T> factory, int capacity = DEFAULT_CAPACIT
2222
{ }
2323

2424
// As suggested by Roslyn's implementation, don't worry about interlocking here. It's okay if a few get loose.
25-
protected override bool GiveToPocket(T item)
25+
protected override bool SaveToPocket(T item)
2626
{
2727
return Pocket.SetIfNull(item);
2828
}

source/Collection/ConcurrentQueueObjectPool.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using System;
22
using System.Collections.Concurrent;
3-
using System.Collections.Generic;
4-
using System.Text;
53

64
namespace Open.Disposable
75
{
8-
public sealed class ConcurrentQueueObjectPool<T> : TrimmableObjectPoolBase<T>
6+
public sealed class ConcurrentQueueObjectPool<T> : TrimmableObjectPoolBase<T>
97
where T : class
108
{
119

@@ -24,8 +22,19 @@ public ConcurrentQueueObjectPool(Func<T> factory, int capacity = DEFAULT_CAPACIT
2422
ConcurrentQueue<T> Pool;
2523

2624
public override int Count => Pool?.Count ?? 0;
27-
28-
protected override bool Receive(T item)
25+
26+
// For ConcurrentQueue disable using the Pocket. It's fast enough as it is...
27+
protected override bool SaveToPocket(T item)
28+
{
29+
return false;
30+
}
31+
32+
protected override T TakeFromPocket()
33+
{
34+
return null;
35+
}
36+
37+
protected override bool Receive(T item)
2938
{
3039
var p = Pool;
3140
if (p == null) return false;

0 commit comments

Comments
 (0)