Skip to content

Commit 062d5a5

Browse files
authored
Add comments to a singleton. (#11333)
1 parent b7c683b commit 062d5a5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

paddle/fluid/framework/data_type.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct DataTypeMap {
2828
};
2929

3030
static DataTypeMap* InitDataTypeMap();
31+
// C++11 removes the need for manual locking. Concurrent execution shall wait if
32+
// a static local variable is already being initialized.
33+
// https://stackoverflow.com/questions/11711920/how-to-implement-multithread-safe-singleton-in-c11-without-using-mutex
3134
static DataTypeMap& gDataTypeMap() {
3235
static DataTypeMap* g_data_type_map_ = InitDataTypeMap();
3336
return *g_data_type_map_;

0 commit comments

Comments
 (0)