This repository was archived by the owner on Mar 12, 2021. It is now read-only.
File tree 1 file changed +21
-7
lines changed 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,18 @@ function pool_alloc(bytes, pid=-1)
234
234
end
235
235
end
236
236
237
+ if block === nothing
238
+ @pool_timeit " 0. repopulate" begin
239
+ repopulate ()
240
+ end
241
+
242
+ @lock pool_lock begin
243
+ if pid != - 1 && ! isempty (pools_avail[pid])
244
+ block = pop! (pools_avail[pid])
245
+ end
246
+ end
247
+ end
248
+
237
249
if block === nothing
238
250
@pool_timeit " 1. try alloc" begin
239
251
block = actual_alloc (bytes)
@@ -306,15 +318,17 @@ function pool_alloc(bytes, pid=-1)
306
318
end
307
319
308
320
if block != = nothing && pid != - 1
309
- @inbounds used = pools_used[pid]
310
- @inbounds avail = pools_avail[pid]
321
+ @lock pool_lock begin
322
+ @inbounds used = pools_used[pid]
323
+ @inbounds avail = pools_avail[pid]
311
324
312
- # mark the buffer as used
313
- push! (used, block)
325
+ # mark the buffer as used
326
+ push! (used, block)
314
327
315
- # update pool usage
316
- current_usage = length (used) / (length (avail) + length (used))
317
- pool_usage[pid] = max (pool_usage[pid], current_usage)
328
+ # update pool usage
329
+ current_usage = length (used) / (length (avail) + length (used))
330
+ pool_usage[pid] = max (pool_usage[pid], current_usage)
331
+ end
318
332
end
319
333
320
334
return block
You can’t perform that action at this time.
0 commit comments