proxygen
Init.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-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 #include <folly/CPortability.h>
20 
21 /*
22  * Calls common init functions in the necessary order
23  * Among other things, this ensures that folly::Singletons are initialized
24  * correctly and installs signal handlers for a superior debugging experience.
25  * It also initializes gflags and glog.
26  *
27  * @param argc, argv arguments to your main
28  * @param removeFlags if true, will update argc,argv to remove recognized
29  * gflags passed on the command line
30  */
31 namespace folly {
32 
33 void init(int* argc, char*** argv, bool removeFlags = true);
34 
35 /*
36  * An RAII object to be constructed at the beginning of main() and destructed
37  * implicitly at the end of main().
38  *
39  * The constructor performs the same setup as folly::init(), including
40  * initializing singletons managed by folly::Singleton.
41  *
42  * The destructor destroys all singletons managed by folly::Singleton, yielding
43  * better shutdown behavior when performed at the end of main(). In particular,
44  * this guarantees that all singletons managed by folly::Singleton are destroyed
45  * before all Meyers singletons are destroyed.
46  */
47 class Init {
48  public:
49  // Force ctor & dtor out of line for better stack traces even with LTO.
50  FOLLY_NOINLINE Init(int* argc, char*** argv, bool removeFlags = true);
52 };
53 
54 } // namespace folly
FOLLY_NOINLINE Init(int *argc, char ***argv, bool removeFlags=true)
Definition: Init.cpp:62
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
#define FOLLY_NOINLINE
Definition: CPortability.h:142
char ** argv
FOLLY_NOINLINE ~Init()
Definition: Init.cpp:66