Skip to content

Pre-allocation of producers #420

Description

@frankist

As far as I understood, the constructor:

	ConcurrentQueue(size_t minCapacity, size_t maxExplicitProducers, size_t maxImplicitProducers)

uses the maxExplicitProducers and maxImplicitProducers to set the initial number of blocks. However, it does not preallocate producers (via add_producer). This means that try_enqueue can still malloc a producer when it is called.

Could the constructor mentioned above also include the following snippet in its body to minimise the chance of malloc when using try_enqueue?

for(size_t i = 0; i != maxImplicitProducers; ++i) {
  auto* p = add_producer(create<ImplicitProducer>(this));
  p->inactive.store(true, std::memory_order_relaxed);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions