# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_memory_pool.pyx

import uuid

from cuda.core._memory._buffer import Buffer, MemoryResource
from cuda.core._stream import Stream
from cuda.core.graph import GraphBuilder
from cuda.core.typing import DevicePointerType


class _MemPoolAttributes:
    """Provides access to memory pool attributes."""
    def __init__(self, *args, **kwargs) -> None: ...
    def __repr__(self) -> str: ...
    @property
    def reuse_follow_event_dependencies(self) -> bool:
        """Allow memory to be reused when there are event dependencies between streams."""
    @property
    def reuse_allow_opportunistic(self) -> bool:
        """Allow reuse of completed frees without dependencies."""
    @property
    def reuse_allow_internal_dependencies(self) -> bool:
        """Allow insertion of new stream dependencies for memory reuse."""
    @property
    def release_threshold(self) -> int:
        """Amount of reserved memory to hold before OS release."""
    @property
    def reserved_mem_current(self) -> int:
        """Current amount of backing memory allocated."""
    @property
    def reserved_mem_high(self) -> int:
        """High watermark of backing memory allocated."""
    @property
    def used_mem_current(self) -> int:
        """Current amount of memory in use."""
    @property
    def used_mem_high(self) -> int:
        """High watermark of memory in use."""

class _MemPool(MemoryResource):
    def __init__(self) -> None: ...
    def close(self) -> None:
        """Release this object's reference to the memory pool.

        New allocations and operations requiring this object's pool handle are
        rejected afterward. For owned pools, release of the underlying pool's
        resources is deferred until all outstanding allocations are freed and
        pending free operations complete. :meth:`deallocate` remains available
        after :meth:`close` so existing allocations can still be released.
        """
    @property
    def is_closed(self) -> bool:
        """Whether this memory resource has been closed."""
    def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer:
        """Allocate a buffer of the requested size.

        Parameters
        ----------
        size : int
            The size of the buffer to allocate, in bytes.
        stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
            Keyword-only. The stream on which to perform the allocation
            asynchronously. Must be passed explicitly; pass
            ``device.default_stream`` to use the default stream.

        Returns
        -------
        Buffer
            The allocated buffer object, which is accessible on the device that this memory
            resource was created for.
        """
    def deallocate(self, ptr: DevicePointerType, size: int, *, stream: Stream | GraphBuilder) -> None:
        """Deallocate a buffer previously allocated by this resource.

        Parameters
        ----------
        ptr : :obj:`~_memory.DevicePointerType`
            The pointer or handle to the buffer to deallocate.
        size : int
            The size of the buffer to deallocate, in bytes.
        stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
            Keyword-only. The stream on which to perform the deallocation
            asynchronously. Must be passed explicitly; pass
            ``device.default_stream`` to use the default stream.
        """
    @property
    def attributes(self) -> _MemPoolAttributes:
        """Memory pool attributes."""
    @property
    def handle(self) -> object:
        """Handle to the underlying memory pool."""
    @property
    def is_handle_owned(self) -> bool:
        """Whether the memory resource handle is owned. If False, ``close`` has no effect."""
    @property
    def is_ipc_enabled(self) -> bool:
        """Whether this memory resource has IPC enabled."""
    @property
    def is_mapped(self) -> bool:
        """
        Whether this is a mapping of an IPC-enabled memory resource from
        another process.  If True, allocation is not permitted.
        """
    @property
    def uuid(self) -> uuid.UUID | None:
        """
        A universally unique identifier for this memory resource. Meaningful
        only for IPC-enabled memory resources.
        """
