22 #ifndef GRPC_CORE_LIB_IOMGR_CFSTREAM_HANDLE_H
23 #define GRPC_CORE_LIB_IOMGR_CFSTREAM_HANDLE_H
30 #import <CoreFoundation/CoreFoundation.h>
36 class GrpcLibraryInitHolder {
38 GrpcLibraryInitHolder();
39 virtual ~GrpcLibraryInitHolder();
42 class CFStreamHandle :
public GrpcLibraryInitHolder {
44 static CFStreamHandle* CreateStreamHandle(CFReadStreamRef read_stream,
45 CFWriteStreamRef write_stream);
47 CFStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream);
48 CFStreamHandle(
const CFStreamHandle&
ref) =
delete;
49 CFStreamHandle(CFStreamHandle&&
ref) =
delete;
50 CFStreamHandle& operator=(
const CFStreamHandle& rhs) =
delete;
51 ~CFStreamHandle()
override;
58 void Ref(
const char*
file =
"",
int line = 0,
const char* reason =
nullptr);
59 void Unref(
const char*
file =
"",
int line = 0,
const char* reason =
nullptr);
62 static void ReadCallback(CFReadStreamRef
stream, CFStreamEventType
type,
63 void* client_callback_info);
64 static void WriteCallback(CFWriteStreamRef
stream, CFStreamEventType
type,
65 void* client_callback_info);
66 static void* Retain(
void* info);
67 static void Release(
void* info);
73 dispatch_queue_t dispatch_queue_;
79 #define CFSTREAM_HANDLE_REF(handle, reason) \
80 (handle)->Ref(__FILE__, __LINE__, (reason))
81 #define CFSTREAM_HANDLE_UNREF(handle, reason) \
82 (handle)->Unref(__FILE__, __LINE__, (reason))
84 #define CFSTREAM_HANDLE_REF(handle, reason) (handle)->Ref()
85 #define CFSTREAM_HANDLE_UNREF(handle, reason) (handle)->Unref()