# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_context.pyx

from __future__ import annotations

from collections.abc import Sequence
from dataclasses import dataclass

import cuda.bindings.driver
from cuda.core._device_resources import (DeviceResources, SMResource,
                                         WorkqueueResource)
from cuda.core._stream import Stream


class Context:
    """CUDA context wrapper.

    Context objects represent CUDA contexts and cannot be instantiated directly.
    Use Device or Stream APIs to obtain context objects.
    """

    def close(self):
        """Release this context wrapper's underlying CUDA handles."""

    def __init__(self, *args, **kwargs) -> None:
        ...

    @property
    def handle(self) -> cuda.bindings.driver.CUcontext | None:
        """Return the underlying CUcontext handle."""

    @property
    def _handle(self) -> cuda.bindings.driver.CUcontext | None:
        ...

    @property
    def is_green(self) -> bool:
        """True if this context was created from device resources."""

    @property
    def resources(self) -> DeviceResources:
        """Query the hardware resources provisioned for this context.

        For green contexts, returns the resources this context was created
        with (SM partition, workqueue config). For primary contexts, returns
        the full device resources.

        Raises :class:`RuntimeError` if the context has been closed.
        """

    def create_stream(self, options: object=None) -> Stream:
        """Create a new stream bound to this green context.

        This method is only available on green contexts. For primary
        contexts, use :meth:`Device.create_stream` instead.

        Parameters
        ----------
        options : :obj:`~_stream.StreamOptions`, optional
            Customizable dataclass for stream creation options.

        Returns
        -------
        :obj:`~_stream.Stream`
            Newly created stream object.
        """

    def __eq__(self, other: object) -> bool:
        ...

    def __hash__(self) -> int:
        ...

    def __repr__(self) -> str:
        ...

@dataclass
class ContextOptions:
    """Options for context creation.

    Attributes
    ----------
    resources : :obj:`~cuda.core.typing.DeviceResourcesType`
        Device resources used to create a green context.
    """
    resources: DeviceResourcesType
__all__ = ['Context', 'ContextOptions']
DeviceResourcesType = Sequence[SMResource | WorkqueueResource]