diff --git a/.clang-format b/.clang-format index 97c11d2..a309831 100644 --- a/.clang-format +++ b/.clang-format @@ -1,39 +1,68 @@ ---- -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: 'true' -AlignEscapedNewlines: Right -AlignTrailingComments: 'true' -AllowShortFunctionsOnASingleLine: 'true' -AllowShortBlocksOnASingleLine: 'true' -AlwaysBreakTemplateDeclarations: 'true' -AccessModifierOffset: -4 -BinPackArguments: 'false' -BinPackParameters: 'false' -BreakBeforeBraces: Mozilla -BreakBeforeInheritanceComma: 'true' -BreakBeforeTernaryOperators: 'true' -BreakConstructorInitializers: BeforeComma -BreakStringLiterals: 'true' -ColumnLimit: '80' -CompactNamespaces: 'false' -ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' -FixNamespaceComments: 'true' -ForEachMacros: ['IMMER_CATCH', 'IMMER_TRY'] -IndentCaseLabels: 'false' -IndentWidth: '4' -IndentWrappedFunctionNames: 'false' -KeepEmptyLinesAtTheStartOfBlocks: 'false' +BasedOnStyle: Mozilla Language: Cpp -MaxEmptyLinesToKeep: '1' -NamespaceIndentation: None -PointerAlignment: Left -ReflowComments: 'true' -SortIncludes: 'true' -SortUsingDeclarations: 'true' -SpaceAfterCStyleCast: 'true' -SpaceAfterTemplateKeyword: 'true' -SpaceBeforeAssignmentOperators: 'true' -SpaceBeforeParens: ControlStatements -TabWidth: '4' -UseTab: Never -... +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: Always +ColumnLimit: 80 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +FixNamespaceComments: true +IncludeBlocks: Regroup +IncludeCategories: + # Seastar files (with angles) + - Regex: '^ #include -//using namespace seastar; +// using namespace seastar; seastar::logger lg("hanoidb"); -static seastar:future<> hello_from_all_cores() { - co_await seastar:smp::invoke_on_all([]() -> seastar::future<> { - lg.info("Hello from every core"); - }); +static seastar::future<> hello_from_all_cores_serial() { + for (unsigned i = 0; i < seastar::smp::count; ++i) { + co_await seastar::smp::submit_to( + i, [] { lg.info("serial - Hello from every core"); }); + }; + co_return; +} + +static seastar::future<> hello_from_all_cores_parallel() { + co_await seastar::smp::invoke_on_all( + []() -> seastar::future<> { + lg.info("parallel - Hello from every core"); + co_return; + }); co_return; } int main(int argc, char** argv) { - seastar::app_template app; + seastar::app_template app; - return app.run(argc, argv, [&] () -> seastar::future { - co_await hello_from_all_cores(); - co_return 0; - }); + return app.run(argc, argv, [&]() -> seastar::future { + co_await hello_from_all_cores_serial(); + co_await hello_from_all_cores_parallel(); + co_return 0; + }); }