xref: /aosp_15_r20/external/grpc-grpc/src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pxd.pxi (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Copyright 2020 The gRPC Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16ctypedef queue[grpc_event] cpp_event_queue
17
18
19IF UNAME_SYSNAME == "Windows":
20    cdef extern from "winsock2.h" nogil:
21        ctypedef uint32_t WIN_SOCKET "SOCKET"
22        WIN_SOCKET win_socket "socket" (int af, int type, int protocol)
23        int win_socket_send "send" (WIN_SOCKET s, const char *buf, int len, int flags)
24
25
26cdef void _unified_socket_write(int fd) nogil
27
28
29cdef class BaseCompletionQueue:
30    cdef grpc_completion_queue *_cq
31
32    cdef grpc_completion_queue* c_ptr(self)
33
34
35cdef class _BoundEventLoop:
36    cdef readonly object loop
37    cdef readonly object read_socket  # socket.socket
38    cdef bint _has_reader
39
40
41cdef class PollerCompletionQueue(BaseCompletionQueue):
42    cdef bint _shutdown
43    cdef cpp_event_queue _queue
44    cdef mutex _queue_mutex
45    cdef object _poller_thread  # threading.Thread
46    cdef int _write_fd
47    cdef object _read_socket    # socket.socket
48    cdef object _write_socket   # socket.socket
49    cdef dict _loops            # Mapping[asyncio.AbstractLoop, _BoundEventLoop]
50
51    cdef void _poll(self) nogil
52    cdef shutdown(self)
53