Merge pull request #19798 from yang-g/cf_stream

Let CFStreamHandle be covered by grpc_init/shutdown
pull/19672/head
Yang Gao 5 years ago committed by GitHub
commit 36c2cdbabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/lib/iomgr/cfstream_handle.cc
  2. 10
      src/core/lib/iomgr/cfstream_handle.h

@ -25,6 +25,7 @@
#import <CoreFoundation/CoreFoundation.h>
#import "src/core/lib/iomgr/cfstream_handle.h"
#include <grpc/grpc.h>
#include <grpc/support/atm.h>
#include <grpc/support/sync.h>
@ -35,6 +36,10 @@
extern grpc_core::TraceFlag grpc_tcp_trace;
GrpcLibraryInitHolder::GrpcLibraryInitHolder() { grpc_init(); }
GrpcLibraryInitHolder::~GrpcLibraryInitHolder() { grpc_shutdown(); }
void* CFStreamHandle::Retain(void* info) {
CFStreamHandle* handle = static_cast<CFStreamHandle*>(info);
CFSTREAM_HANDLE_REF(handle, "retain");

@ -33,11 +33,17 @@
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/lockfree_event.h"
class CFStreamHandle final {
class GrpcLibraryInitHolder {
public:
GrpcLibraryInitHolder();
virtual ~GrpcLibraryInitHolder();
};
class CFStreamHandle : public GrpcLibraryInitHolder {
public:
static CFStreamHandle* CreateStreamHandle(CFReadStreamRef read_stream,
CFWriteStreamRef write_stream);
~CFStreamHandle();
~CFStreamHandle() override;
CFStreamHandle(const CFStreamHandle& ref) = delete;
CFStreamHandle(CFStreamHandle&& ref) = delete;
CFStreamHandle& operator=(const CFStreamHandle& rhs) = delete;

Loading…
Cancel
Save