File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ pub struct AllocatorPool {
1010}
1111
1212impl AllocatorPool {
13- /// Creates a new [`AllocatorPool`] pre-filled with the given number of default [`Allocator`] instances .
14- pub fn new ( size : usize ) -> AllocatorPool {
15- let allocators = iter:: repeat_with ( Allocator :: new) . take ( size ) . collect ( ) ;
13+ /// Creates a new [`AllocatorPool`] for use across the specified number of threads .
14+ pub fn new ( thread_count : usize ) -> AllocatorPool {
15+ let allocators = iter:: repeat_with ( Allocator :: new) . take ( thread_count ) . collect ( ) ;
1616 AllocatorPool { allocators : Mutex :: new ( allocators) }
1717 }
1818
Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ pub struct AllocatorPool {
3030}
3131
3232impl AllocatorPool {
33- /// Creates a new [`AllocatorPool`] with capacity for the given number of `FixedSizeAllocator` instances.
34- pub fn new ( size : usize ) -> AllocatorPool {
35- // Each allocator consumes a large block of memory, so create them on demand instead of upfront
36- let allocators = Vec :: with_capacity ( size) ;
33+ /// Creates a new [`AllocatorPool`] for use across the specified number of threads.
34+ pub fn new ( thread_count : usize ) -> AllocatorPool {
35+ // Each allocator consumes a large block of memory, so create them on demand instead of upfront,
36+ // in case not all threads end up being used (e.g. language server without `import` plugin)
37+ let allocators = Vec :: with_capacity ( thread_count) ;
3738 AllocatorPool { allocators : Mutex :: new ( allocators) , next_id : AtomicU32 :: new ( 0 ) }
3839 }
3940
You can’t perform that action at this time.
0 commit comments