proxygen
SocketPair.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 namespace folly {
20 
21 class SocketPair {
22  public:
24 
25  explicit SocketPair(Mode mode = NONBLOCKING);
26  ~SocketPair();
27 
28  int operator[](int index) const {
29  return fds_[index];
30  }
31 
32  void closeFD0();
33  void closeFD1();
34 
35  int extractFD0() {
36  return extractFD(0);
37  }
38  int extractFD1() {
39  return extractFD(1);
40  }
41  int extractFD(int index) {
42  int fd = fds_[index];
43  fds_[index] = -1;
44  return fd;
45  }
46 
47  private:
48  int fds_[2];
49 };
50 
51 } // namespace folly
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
folly::Optional< PskKeyExchangeMode > mode
int extractFD(int index)
Definition: SocketPair.h:41
int operator[](int index) const
Definition: SocketPair.h:28
SocketPair(Mode mode=NONBLOCKING)
Definition: SocketPair.cpp:29