Skip to content

Commit 3cd38af

Browse files
committed
Add clang-tidy CI, reformat codebase, and split acceptor_service
Add clang-tidy config and CI job. Update clang-format config (80-col limit, Allman-adjacent style) and reformat entire codebase. Split acceptor_service out of socket_service.hpp. Remove unused resume_coro.hpp.
1 parent 0ce691f commit 3cd38af

124 files changed

Lines changed: 4596 additions & 5423 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.clang-format‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ BraceWrapping:
3535
BeforeLambdaBody: false
3636
BeforeWhile: true
3737
IndentBraces: false
38-
SplitEmptyFunction: false
38+
SplitEmptyFunction: true
3939
SplitEmptyRecord: false
4040
SplitEmptyNamespace: false
4141

4242
# Alignment
43-
AlignAfterOpenBracket: DontAlign
43+
AlignAfterOpenBracket: AlwaysBreak
4444
AlignConsecutiveAssignments: false
4545
AlignConsecutiveDeclarations: false
4646
AlignEscapedNewlines: Left
@@ -49,22 +49,22 @@ AlignTrailingComments: true
4949
ContinuationIndentWidth: 4
5050

5151
# Line breaking
52-
ColumnLimit: 100
52+
ColumnLimit: 80
5353
AllowShortBlocksOnASingleLine: Empty
5454
AllowShortCaseLabelsOnASingleLine: false
55-
AllowShortFunctionsOnASingleLine: Inline
55+
AllowShortFunctionsOnASingleLine: Empty
5656
AllowShortIfStatementsOnASingleLine: Never
5757
AllowShortLambdasOnASingleLine: All
5858
AllowShortLoopsOnASingleLine: false
59-
AlwaysBreakAfterReturnType: None
59+
AlwaysBreakAfterReturnType: TopLevelDefinitions
6060
AlwaysBreakBeforeMultilineStrings: false
6161
AlwaysBreakTemplateDeclarations: Yes
6262
BinPackArguments: true
63-
BinPackParameters: true
63+
BinPackParameters: false
6464
BreakBeforeBinaryOperators: None
6565
BreakBeforeTernaryOperators: true
66-
BreakConstructorInitializers: BeforeColon
67-
BreakInheritanceList: BeforeColon
66+
BreakConstructorInitializers: BeforeComma
67+
BreakInheritanceList: BeforeComma
6868
BreakStringLiterals: true
6969

7070
# Spaces
@@ -75,7 +75,7 @@ SpaceBeforeAssignmentOperators: true
7575
SpaceBeforeCpp11BracedList: false
7676
SpaceBeforeCtorInitializerColon: true
7777
SpaceBeforeInheritanceColon: true
78-
SpaceBeforeParens: Never
78+
SpaceBeforeParens: ControlStatements
7979
SpaceBeforeRangeBasedForLoopColon: true
8080
SpaceBeforeSquareBrackets: false
8181
SpaceInEmptyBlock: false
@@ -102,16 +102,16 @@ AllowAllArgumentsOnNextLine: true
102102
AllowAllParametersOfDeclarationOnNextLine: true
103103
CompactNamespaces: false
104104
Cpp11BracedListStyle: true
105-
EmptyLineBeforeAccessModifier: LogicalBlock
105+
EmptyLineBeforeAccessModifier: Always
106106
FixNamespaceComments: true
107107
IndentAccessModifiers: false
108108
IndentWrappedFunctionNames: false
109109
InsertBraces: false
110110
InsertNewlineAtEOF: true
111111
KeepEmptyLinesAtTheStartOfBlocks: false
112-
MaxEmptyLinesToKeep: 2
112+
MaxEmptyLinesToKeep: 1
113113
PackConstructorInitializers: CurrentLine
114-
ReflowComments: true
114+
ReflowComments: false
115115
SeparateDefinitionBlocks: Leave
116116
ShortNamespaceLines: 0
117117

@@ -122,4 +122,4 @@ PenaltyBreakComment: 300
122122
PenaltyBreakFirstLessLess: 120
123123
PenaltyBreakString: 1000
124124
PenaltyExcessCharacter: 1000000
125-
PenaltyReturnTypeOnItsOwnLine: 60
125+
PenaltyReturnTypeOnItsOwnLine: 0

‎.clang-tidy‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (c) 2026 Steve Gerbino
3+
#
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/cppalliance/corosio
8+
#
9+
10+
# Conservative config: high-signal checks, minimal false positives.
11+
# Run: clang-tidy -p build src/corosio/src/detail/epoll/scheduler.cpp
12+
13+
Checks: >
14+
-*,
15+
bugprone-*,
16+
-bugprone-branch-clone,
17+
-bugprone-easily-swappable-parameters,
18+
-bugprone-narrowing-conversions,
19+
-bugprone-switch-missing-default-case,
20+
clang-analyzer-*,
21+
-clang-analyzer-optin.*,
22+
concurrency-*,
23+
-concurrency-mt-unsafe,
24+
misc-redundant-expression,
25+
misc-unconventional-assign-operator,
26+
misc-unused-parameters,
27+
modernize-use-override,
28+
performance-*,
29+
-performance-enum-size,
30+
-performance-noexcept-move-constructor,
31+
readability-container-size-empty,
32+
readability-redundant-smartptr-get,
33+
34+
HeaderFilterRegex: '(boost/corosio|src/detail)/'
35+
FormatStyle: file

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,12 @@ jobs:
213213
container: "ubuntu:24.04"
214214
b2-toolset: "clang"
215215
is-latest: true
216-
name: "Clang 20: C++20-23"
216+
name: "Clang 20: C++20-23 (clang-tidy)"
217217
shared: true
218218
build-type: "Release"
219219
build-cmake: true
220+
install: "clang-tidy-20"
221+
clang-tidy: true
220222

221223
- compiler: "clang"
222224
version: "20"
@@ -702,6 +704,7 @@ jobs:
702704
extra-args: |
703705
-D Boost_VERBOSE=ON
704706
-D BOOST_INCLUDE_LIBRARIES="${{ steps.patch.outputs.module }}"
707+
-D CMAKE_EXPORT_COMPILE_COMMANDS=ON
705708
${{ matrix.compiler == 'mingw' && '-D CMAKE_VERBOSE_MAKEFILE=ON' || '' }}
706709
${{ env.CMAKE_WOLFSSL_INCLUDE && format('-D WolfSSL_INCLUDE_DIR={0}', env.CMAKE_WOLFSSL_INCLUDE) || '' }}
707710
${{ env.CMAKE_WOLFSSL_LIBRARY && format('-D WolfSSL_LIBRARY={0}', env.CMAKE_WOLFSSL_LIBRARY) || '' }}
@@ -713,6 +716,15 @@ jobs:
713716
package-artifact: false
714717
ref-source-dir: boost-root/libs/corosio
715718

719+
- name: Run clang-tidy
720+
if: ${{ matrix.clang-tidy }}
721+
run: |
722+
python3 -c "import json; [print(e['file']) for e in json.load(open('__build_cmake_test__/compile_commands.json'))]" \
723+
| grep '/libs/corosio/src/' \
724+
| xargs clang-tidy-20 \
725+
-p __build_cmake_test__ \
726+
--warnings-as-errors='*'
727+
716728
- name: Set Path
717729
if: startsWith(matrix.runs-on, 'windows') && matrix.shared
718730
run: echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH

‎include/boost/corosio/basic_io_context.hpp‎

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
5050
5151
@return An executor associated with this context.
5252
*/
53-
executor_type
54-
get_executor() const noexcept;
53+
executor_type get_executor() const noexcept;
5554

5655
/** Signal the context to stop processing.
5756
5857
This causes `run()` to return as soon as possible. Any pending
5958
work items remain queued.
6059
*/
61-
void
62-
stop()
60+
void stop()
6361
{
6462
sched_->stop();
6563
}
@@ -69,8 +67,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
6967
@return `true` if `stop()` has been called and `restart()`
7068
has not been called since.
7169
*/
72-
bool
73-
stopped() const noexcept
70+
bool stopped() const noexcept
7471
{
7572
return sched_->stopped();
7673
}
@@ -80,8 +77,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
8077
This function must be called before `run()` can be called
8178
again after `stop()` has been called.
8279
*/
83-
void
84-
restart()
80+
void restart()
8581
{
8682
sched_->restart();
8783
}
@@ -97,8 +93,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
9793
9894
@return The number of handlers executed.
9995
*/
100-
std::size_t
101-
run()
96+
std::size_t run()
10297
{
10398
return sched_->run();
10499
}
@@ -114,8 +109,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
114109
115110
@return The number of handlers executed (0 or 1).
116111
*/
117-
std::size_t
118-
run_one()
112+
std::size_t run_one()
119113
{
120114
return sched_->run_one();
121115
}
@@ -134,8 +128,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
134128
@return The number of handlers executed.
135129
*/
136130
template<class Rep, class Period>
137-
std::size_t
138-
run_for(std::chrono::duration<Rep, Period> const& rel_time)
131+
std::size_t run_for(std::chrono::duration<Rep, Period> const& rel_time)
139132
{
140133
return run_until(std::chrono::steady_clock::now() + rel_time);
141134
}
@@ -178,8 +171,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
178171
@return The number of handlers executed (0 or 1).
179172
*/
180173
template<class Rep, class Period>
181-
std::size_t
182-
run_one_for(std::chrono::duration<Rep, Period> const& rel_time)
174+
std::size_t run_one_for(std::chrono::duration<Rep, Period> const& rel_time)
183175
{
184176
return run_one_until(std::chrono::steady_clock::now() + rel_time);
185177
}
@@ -209,8 +201,10 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
209201
rel_time = std::chrono::seconds(1);
210202

211203
std::size_t s = sched_->wait_one(
212-
static_cast<long>(std::chrono::duration_cast<
213-
std::chrono::microseconds>(rel_time).count()));
204+
static_cast<long>(
205+
std::chrono::duration_cast<std::chrono::microseconds>(
206+
rel_time)
207+
.count()));
214208

215209
if (s || stopped())
216210
return s;
@@ -231,8 +225,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
231225
232226
@return The number of handlers executed.
233227
*/
234-
std::size_t
235-
poll()
228+
std::size_t poll()
236229
{
237230
return sched_->poll();
238231
}
@@ -248,8 +241,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
248241
249242
@return The number of handlers executed (0 or 1).
250243
*/
251-
std::size_t
252-
poll_one()
244+
std::size_t poll_one()
253245
{
254246
return sched_->poll_one();
255247
}
@@ -259,11 +251,7 @@ class BOOST_COROSIO_DECL basic_io_context : public capy::execution_context
259251
260252
Derived classes must set sched_ in their constructor body.
261253
*/
262-
basic_io_context()
263-
: capy::execution_context(this)
264-
, sched_(nullptr)
265-
{
266-
}
254+
basic_io_context() : capy::execution_context(this), sched_(nullptr) {}
267255

268256
detail::scheduler* sched_;
269257
};
@@ -297,18 +285,13 @@ class basic_io_context::executor_type
297285
298286
@param ctx The context to associate with this executor.
299287
*/
300-
explicit
301-
executor_type(basic_io_context& ctx) noexcept
302-
: ctx_(&ctx)
303-
{
304-
}
288+
explicit executor_type(basic_io_context& ctx) noexcept : ctx_(&ctx) {}
305289

306290
/** Return a reference to the associated execution context.
307291
308292
@return Reference to the context.
309293
*/
310-
basic_io_context&
311-
context() const noexcept
294+
basic_io_context& context() const noexcept
312295
{
313296
return *ctx_;
314297
}
@@ -317,8 +300,7 @@ class basic_io_context::executor_type
317300
318301
@return `true` if `run()` is being called on this thread.
319302
*/
320-
bool
321-
running_in_this_thread() const noexcept
303+
bool running_in_this_thread() const noexcept
322304
{
323305
return ctx_->sched_->running_in_this_thread();
324306
}
@@ -327,8 +309,7 @@ class basic_io_context::executor_type
327309
328310
Must be paired with `on_work_finished()`.
329311
*/
330-
void
331-
on_work_started() const noexcept
312+
void on_work_started() const noexcept
332313
{
333314
ctx_->sched_->on_work_started();
334315
}
@@ -338,8 +319,7 @@ class basic_io_context::executor_type
338319
@par Preconditions
339320
A preceding call to `on_work_started()` on an equal executor.
340321
*/
341-
void
342-
on_work_finished() const noexcept
322+
void on_work_finished() const noexcept
343323
{
344324
ctx_->sched_->on_work_finished();
345325
}
@@ -354,8 +334,7 @@ class basic_io_context::executor_type
354334
355335
@return A handle for symmetric transfer or `std::noop_coroutine()`.
356336
*/
357-
std::coroutine_handle<>
358-
dispatch(std::coroutine_handle<> h) const
337+
std::coroutine_handle<> dispatch(std::coroutine_handle<> h) const
359338
{
360339
if (running_in_this_thread())
361340
return h;
@@ -370,8 +349,7 @@ class basic_io_context::executor_type
370349
371350
@param h The coroutine handle to post.
372351
*/
373-
void
374-
post(std::coroutine_handle<> h) const
352+
void post(std::coroutine_handle<> h) const
375353
{
376354
ctx_->sched_->post(h);
377355
}
@@ -380,8 +358,7 @@ class basic_io_context::executor_type
380358
381359
@return `true` if both executors refer to the same context.
382360
*/
383-
bool
384-
operator==(executor_type const& other) const noexcept
361+
bool operator==(executor_type const& other) const noexcept
385362
{
386363
return ctx_ == other.ctx_;
387364
}
@@ -390,17 +367,14 @@ class basic_io_context::executor_type
390367
391368
@return `true` if the executors refer to different contexts.
392369
*/
393-
bool
394-
operator!=(executor_type const& other) const noexcept
370+
bool operator!=(executor_type const& other) const noexcept
395371
{
396372
return ctx_ != other.ctx_;
397373
}
398374
};
399375

400-
inline
401-
basic_io_context::executor_type
402-
basic_io_context::
403-
get_executor() const noexcept
376+
inline basic_io_context::executor_type
377+
basic_io_context::get_executor() const noexcept
404378
{
405379
return executor_type(const_cast<basic_io_context&>(*this));
406380
}

0 commit comments

Comments
 (0)