Debian Codegraph @

src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h

raw
1 /*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 #import <Foundation/Foundation.h>
20 #include <grpc/grpc.h>
21
22 typedef void (^GRPCQueueCompletionHandler)(bool success);
23
24 /**
25 * This class lets one more easily use |grpc_completion_queue|. To use it, pass the value of the
26 * |unmanagedQueue| property of an instance of this class to |grpc_channel_create_call|. Then for
27 * every |grpc_call_*| method that accepts a tag, you can pass a block of type
28 * |GRPCQueueCompletionHandler| (remembering to cast it using |__bridge_retained|). The block is
29 * guaranteed to eventually be called, by a concurrent queue, and then released. Each such block is
30 * passed a |bool| that tells if the operation was successful.
31 *
32 * Release the GRPCCompletionQueue object only after you are not going to pass any more blocks to
33 * the |grpc_call| that's using it.
34 */
35 @interface GRPCCompletionQueue : NSObject
36 @property(nonatomic, readonly) grpc_completion_queue *unmanagedQueue;
37
38 + (instancetype)completionQueue;
39 @end