from threading import Lock
from typing import Any

from typing_extensions import Self, override

__all__ = ("LamportClock", "timetuple")

class timetuple(tuple[int | None, float, str, Any]):
    __slots__ = ()

    def __new__(
        cls, clock: int | None, timestamp: float, id: str, obj: Any = ...
    ) -> Self: ...
    def __getnewargs__(self) -> tuple[int | None, float, str, Any]: ...
    @override
    def __lt__(self, other: tuple[Any, ...]) -> bool: ...
    @override
    def __gt__(self, other: tuple[Any, ...]) -> bool: ...
    @override
    def __le__(self, other: tuple[Any, ...]) -> bool: ...
    @override
    def __ge__(self, other: tuple[Any, ...]) -> bool: ...
    @property
    def clock(self) -> int | None: ...
    @property
    def timestamp(self) -> float: ...
    @property
    def id(self) -> str: ...
    @property
    def obj(self) -> Any: ...

class LamportClock:
    value: int
    mutex: Lock

    def __init__(self, initial_value: int = ..., Lock: type[Lock] = ...) -> None: ...
    def adjust(self, other: int) -> int: ...
    def forward(self) -> int: ...
    def sort_heap(self, h: list[tuple[int, str]]) -> tuple[int, str]: ...
