Beaver. MLIR. ThreadPool
(beaver v0.4.8)
Copy Markdown
Owns an LLVM thread pool that can be shared by multiple MLIR contexts.
The application starts one pool under default_name/0. MLIR.Context.create/1
checks out a lease from it by default and returns the lease when the context is
destroyed. Calling close/1 while contexts are attached defers native pool
destruction until the final lease is returned.
If an owner is forcibly terminated while leases remain, the native pool is
deliberately retained so attached MLIR contexts never hold a dangling pool
pointer. Use close/1 for deterministic reclamation.
An explicit owner can be selected with thread_pool: owner, or a raw
Beaver.MLIR.LLVMThreadPool can be supplied when its lifetime is managed by
the caller.
Summary
Functions
Returns a specification to start this module under a supervisor.
Closes the owner. Returns :deferred if attached contexts still hold leases.
Create a caller-owned native pool for use with MLIR.Context.create/1.
Destroy a caller-owned native pool after all attached contexts are gone.
Functions
@spec checkin(GenServer.server(), reference()) :: :ok
@spec checkout(GenServer.server()) :: {Beaver.MLIR.LLVMThreadPool.t(), reference()} | {:error, :closing}
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close(GenServer.server()) :: :ok | :deferred
Closes the owner. Returns :deferred if attached contexts still hold leases.
@spec create() :: Beaver.MLIR.LLVMThreadPool.t()
Create a caller-owned native pool for use with MLIR.Context.create/1.
@spec default_name() :: module()
@spec destroy(Beaver.MLIR.LLVMThreadPool.t()) :: :ok
Destroy a caller-owned native pool after all attached contexts are gone.
@spec max_concurrency(GenServer.server() | Beaver.MLIR.LLVMThreadPool.t()) :: non_neg_integer()
@spec pool(GenServer.server()) :: Beaver.MLIR.LLVMThreadPool.t()
@spec start_link(keyword()) :: GenServer.on_start()