2 from collections.abc import Callable, Iterable, Sequence
3 from ctypes import _CData, _SimpleCData, c_char
4 from multiprocessing.context import BaseContext
5 from multiprocessing.synchronize import _LockLike
6 from typing import Any, Generic, Protocol, Type, TypeVar, overload
7 from typing_extensions import Literal
10 _CT = TypeVar("_CT", bound=_CData)
13 def RawValue(typecode_or_type: Type[_CT], *args: Any) -> _CT: ...
15 def RawValue(typecode_or_type: str, *args: Any) -> Any: ...
17 def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ...
19 def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ...
21 def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ...
24 typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ...
25 ) -> SynchronizedBase[_CT]: ...
28 typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ...
29 ) -> SynchronizedBase[Any]: ...
32 typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ...
36 typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ...
40 typecode_or_type: Type[_CT],
41 size_or_initializer: int | Sequence[Any],
43 lock: Literal[True] | _LockLike,
44 ctx: BaseContext | None = ...,
45 ) -> SynchronizedArray[_CT]: ...
48 typecode_or_type: str,
49 size_or_initializer: int | Sequence[Any],
51 lock: Literal[True] | _LockLike,
52 ctx: BaseContext | None = ...,
53 ) -> SynchronizedArray[Any]: ...
56 typecode_or_type: str | Type[_CData],
57 size_or_initializer: int | Sequence[Any],
59 lock: bool | _LockLike = ...,
60 ctx: BaseContext | None = ...,
62 def copy(obj: _CT) -> _CT: ...
64 def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = ..., ctx: Any | None = ...) -> Synchronized[_T]: ...
66 def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedString: ...
68 def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedArray[_CT]: ...
70 def synchronized(obj: _CT, lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedBase[_CT]: ...
72 class _AcquireFunc(Protocol):
73 def __call__(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
75 class SynchronizedBase(Generic[_CT]):
77 release: Callable[[], None]
78 def __init__(self, obj: Any, lock: _LockLike | None = ..., ctx: Any | None = ...) -> None: ...
79 def __reduce__(self) -> tuple[Callable[..., Any], tuple[Any, _LockLike]]: ...
80 def get_obj(self) -> _CT: ...
81 def get_lock(self) -> _LockLike: ...
82 def __enter__(self) -> bool: ...
83 def __exit__(self, *args: Any) -> None: ...
85 class Synchronized(SynchronizedBase[_SimpleCData[_T]], Generic[_T]):
88 class SynchronizedArray(SynchronizedBase[ctypes.Array[_CT]], Generic[_CT]):
89 def __len__(self) -> int: ...
90 def __getitem__(self, i: int) -> _CT: ...
91 def __setitem__(self, i: int, o: _CT) -> None: ...
92 def __getslice__(self, start: int, stop: int) -> list[_CT]: ...
93 def __setslice__(self, start: int, stop: int, values: Iterable[_CT]) -> None: ...
95 class SynchronizedString(SynchronizedArray[c_char]):