Skip to content

Commit

Permalink
fix(tianmu): fix format using clang-format #792
Browse files Browse the repository at this point in the history
  • Loading branch information
hustjieke committed Oct 24, 2022
1 parent 606baaa commit b8cc4cf
Show file tree
Hide file tree
Showing 247 changed files with 5,412 additions and 3,185 deletions.
3 changes: 2 additions & 1 deletion storage/tianmu/async_tests/task_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class AppTemplate {
pollabled = true;
}

if (_stopped.load(std::memory_order_relaxed)) base::engine().exit(0);
if (_stopped.load(std::memory_order_relaxed))
base::engine().exit(0);

return pollabled;
}
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/base/core/checked_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ inline T *checked_ptr_do_get(T *ptr) noexcept {
template <typename Ptr, typename NullDerefAction = default_null_deref_action>
/// \cond GCC6_CONCEPT_DOC
GCC6_CONCEPT(requires std::is_default_constructible<NullDerefAction>::value &&requires(NullDerefAction action) {
NullDerefAction();
})
NullDerefAction();
})
/// \endcond
class checked_ptr {
public:
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/base/core/chunked_fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class chunked_fifo {
T &back();
const T &back() const;
template <typename... A>
inline void emplace_back(A &&...args);
inline void emplace_back(A &&... args);
inline T &front() const noexcept;
inline void pop_front() noexcept;
inline bool empty() const noexcept;
Expand Down Expand Up @@ -328,7 +328,7 @@ void chunked_fifo<T, items_per_chunk>::undo_room_back() {

template <typename T, size_t items_per_chunk>
template <typename... Args>
inline void chunked_fifo<T, items_per_chunk>::emplace_back(Args &&...args) {
inline void chunked_fifo<T, items_per_chunk>::emplace_back(Args &&... args) {
ensure_room_back();
auto p = &_back_chunk->items[mask(_back_chunk->end)].data;
try {
Expand Down
8 changes: 4 additions & 4 deletions storage/tianmu/base/core/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class circular_buffer {
void push_front(const T &data);
void push_front(T &&data);
template <typename... A>
void emplace_front(A &&...args);
void emplace_front(A &&... args);
void push_back(const T &data);
void push_back(T &&data);
template <typename... A>
void emplace_back(A &&...args);
void emplace_back(A &&... args);
T &front();
T &back();
void pop_front();
Expand Down Expand Up @@ -281,7 +281,7 @@ inline void circular_buffer<T, Alloc>::push_front(T &&data) {

template <typename T, typename Alloc>
template <typename... Args>
inline void circular_buffer<T, Alloc>::emplace_front(Args &&...args) {
inline void circular_buffer<T, Alloc>::emplace_front(Args &&... args) {
maybe_expand();
auto p = &_impl.storage[mask(_impl.begin - 1)];
_impl.construct(p, std::forward<Args>(args)...);
Expand All @@ -306,7 +306,7 @@ inline void circular_buffer<T, Alloc>::push_back(T &&data) {

template <typename T, typename Alloc>
template <typename... Args>
inline void circular_buffer<T, Alloc>::emplace_back(Args &&...args) {
inline void circular_buffer<T, Alloc>::emplace_back(Args &&... args) {
maybe_expand();
auto p = &_impl.storage[mask(_impl.end)];
_impl.construct(p, std::forward<Args>(args)...);
Expand Down
8 changes: 4 additions & 4 deletions storage/tianmu/base/core/circular_buffer_fixed_capacity.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ class circular_buffer_fixed_capacity {
void push_front(const T &data);
void push_front(T &&data);
template <typename... A>
T &emplace_front(A &&...args);
T &emplace_front(A &&... args);
void push_back(const T &data);
void push_back(T &&data);
template <typename... A>
T &emplace_back(A &&...args);
T &emplace_back(A &&... args);
T &front();
T &back();
void pop_front();
Expand Down Expand Up @@ -230,7 +230,7 @@ inline void circular_buffer_fixed_capacity<T, Capacity>::push_front(T &&data) {

template <typename T, size_t Capacity>
template <typename... Args>
inline T &circular_buffer_fixed_capacity<T, Capacity>::emplace_front(Args &&...args) {
inline T &circular_buffer_fixed_capacity<T, Capacity>::emplace_front(Args &&... args) {
auto p = new (obj(_begin - 1)) T(std::forward<Args>(args)...);
--_begin;
return *p;
Expand All @@ -250,7 +250,7 @@ inline void circular_buffer_fixed_capacity<T, Capacity>::push_back(T &&data) {

template <typename T, size_t Capacity>
template <typename... Args>
inline T &circular_buffer_fixed_capacity<T, Capacity>::emplace_back(Args &&...args) {
inline T &circular_buffer_fixed_capacity<T, Capacity>::emplace_back(Args &&... args) {
auto p = new (obj(_end)) T(std::forward<Args>(args)...);
++_end;
return *p;
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/base/core/do_with.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ inline auto with_lock(Lock &lock, Func &&func) {
/// \c f executes. \c f will be called with all arguments as
/// reference parameters.
template <typename T1, typename T2, typename T3_or_F, typename... More>
inline auto do_with(T1 &&rv1, T2 &&rv2, T3_or_F &&rv3, More &&...more) {
inline auto do_with(T1 &&rv1, T2 &&rv2, T3_or_F &&rv3, More &&... more) {
auto all = std::forward_as_tuple(std::forward<T1>(rv1), std::forward<T2>(rv2), std::forward<T3_or_F>(rv3),
std::forward<More>(more)...);
constexpr size_t nr = std::tuple_size<decltype(all)>::value - 1;
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/base/core/execution_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class concrete_execution_stage final : public execution_stage {
promise_type _ready;

template <typename... Args>
work_item(Args &&...args) : _in(std::forward<Args>(args)...) {}
work_item(Args &&... args) : _in(std::forward<Args>(args)...) {}

work_item(work_item &&other) = delete;
work_item(const work_item &) = delete;
Expand Down Expand Up @@ -330,7 +330,7 @@ class concrete_execution_stage final : public execution_stage {
/// \return future containing the result of the call to the stage's function
template <typename... Args>
GCC6_CONCEPT(requires std::is_constructible<input_type, Args...>::value)
return_type operator()(Args &&...args) {
return_type operator()(Args &&... args) {
_queue.emplace_back(std::forward<Args>(args)...);
_empty = false;
_stats.function_calls_enqueued++;
Expand Down
35 changes: 18 additions & 17 deletions storage/tianmu/base/core/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class shared_future;
/// to perform a computation (for example, because the data is cached
/// in some buffer).
template <typename... T, typename... A>
future<T...> make_ready_future(A &&...value);
future<T...> make_ready_future(A &&... value);

/// \brief Creates a \ref future in an available, failed state.
///
Expand Down Expand Up @@ -203,7 +203,7 @@ struct future_state {
_state = state::result;
}
template <typename... A>
void set(A &&...a) {
void set(A &&... a) {
assert(_state == state::future);
new (&_u.value) std::tuple<T...>(std::forward<A>(a)...);
_state = state::result;
Expand Down Expand Up @@ -454,7 +454,7 @@ class promise {
/// Forwards the arguments and makes them available to the associated
/// future. May be called either before or after \c get_future().
template <typename... A>
void set_value(A &&...a) noexcept {
void set_value(A &&... a) noexcept {
assert(_state);
_state->set(std::forward<A>(a)...);
make_ready<urgent::no>();
Expand Down Expand Up @@ -569,7 +569,7 @@ struct futurize {
/// Apply a function to an argument list
/// and return the result, as a future (if it wasn't already).
template <typename Func, typename... FuncArgs>
static inline type apply(Func &&func, FuncArgs &&...args) noexcept;
static inline type apply(Func &&func, FuncArgs &&... args) noexcept;

/// Convert a value or a future to a future
static inline type convert(T &&value) { return make_ready_future<T>(std::move(value)); }
Expand All @@ -596,7 +596,7 @@ struct futurize<void> {
static inline type apply(Func &&func, std::tuple<FuncArgs...> &&args) noexcept;

template <typename Func, typename... FuncArgs>
static inline type apply(Func &&func, FuncArgs &&...args) noexcept;
static inline type apply(Func &&func, FuncArgs &&... args) noexcept;

static inline type from_tuple(value_type &&value);
static inline type from_tuple(const value_type &value);
Expand All @@ -614,9 +614,9 @@ struct futurize<future<Args...>> {
static inline type apply(Func &&func, std::tuple<FuncArgs...> &&args) noexcept;

template <typename Func, typename... FuncArgs>
static inline type apply(Func &&func, FuncArgs &&...args) noexcept;
static inline type apply(Func &&func, FuncArgs &&... args) noexcept;

static inline type convert(Args &&...values) { return make_ready_future<Args...>(std::move(values)...); }
static inline type convert(Args &&... values) { return make_ready_future<Args...>(std::move(values)...); }
static inline type convert(type &&value) { return std::move(value); }

template <typename Arg>
Expand All @@ -639,7 +639,8 @@ GCC6_CONCEPT(

template <typename Func, typename Return, typename... T> concept bool ApplyReturns =
requires(Func f, T... args) {
{ f(std::forward<T>(args)...) } -> Return;
{ f(std::forward<T>(args)...) }
->Return;
};

template <typename Func, typename... T> concept bool ApplyReturnsAnyFuture =
Expand Down Expand Up @@ -672,7 +673,7 @@ class future {
private:
future(promise<T...> *pr) noexcept : _promise(pr) { _promise->_future = this; }
template <typename... A>
future(ready_future_marker, A &&...a) : _promise(nullptr) {
future(ready_future_marker, A &&... a) : _promise(nullptr) {
_local_state.set(std::forward<A>(a)...);
}
template <typename... A>
Expand Down Expand Up @@ -1070,7 +1071,7 @@ class future {
template <typename... U>
friend class promise;
template <typename... U, typename... A>
friend future<U...> make_ready_future(A &&...value);
friend future<U...> make_ready_future(A &&... value);
template <typename... U>
friend future<U...> make_exception_future(std::exception_ptr ex) noexcept;
template <typename... U, typename Exception>
Expand Down Expand Up @@ -1128,7 +1129,7 @@ inline void promise<T...>::abandoned() noexcept {
}

template <typename... T, typename... A>
inline future<T...> make_ready_future(A &&...value) {
inline future<T...> make_ready_future(A &&... value) {
return future<T...>(ready_future_marker(), std::forward<A>(value)...);
}

Expand Down Expand Up @@ -1164,7 +1165,7 @@ typename futurize<T>::type futurize<T>::apply(Func &&func, std::tuple<FuncArgs..

template <typename T>
template <typename Func, typename... FuncArgs>
typename futurize<T>::type futurize<T>::apply(Func &&func, FuncArgs &&...args) noexcept {
typename futurize<T>::type futurize<T>::apply(Func &&func, FuncArgs &&... args) noexcept {
try {
return convert(func(std::forward<FuncArgs>(args)...));
} catch (...) {
Expand All @@ -1174,7 +1175,7 @@ typename futurize<T>::type futurize<T>::apply(Func &&func, FuncArgs &&...args) n

template <typename Func, typename... FuncArgs>
inline std::enable_if_t<!is_future<std::result_of_t<Func(FuncArgs &&...)>>::value, future<>> do_void_futurize_apply(
Func &&func, FuncArgs &&...args) noexcept {
Func &&func, FuncArgs &&... args) noexcept {
try {
func(std::forward<FuncArgs>(args)...);
return make_ready_future<>();
Expand All @@ -1185,7 +1186,7 @@ inline std::enable_if_t<!is_future<std::result_of_t<Func(FuncArgs &&...)>>::valu

template <typename Func, typename... FuncArgs>
inline std::enable_if_t<is_future<std::result_of_t<Func(FuncArgs &&...)>>::value, future<>> do_void_futurize_apply(
Func &&func, FuncArgs &&...args) noexcept {
Func &&func, FuncArgs &&... args) noexcept {
try {
return func(std::forward<FuncArgs>(args)...);
} catch (...) {
Expand Down Expand Up @@ -1220,7 +1221,7 @@ typename futurize<void>::type futurize<void>::apply(Func &&func, std::tuple<Func
}

template <typename Func, typename... FuncArgs>
typename futurize<void>::type futurize<void>::apply(Func &&func, FuncArgs &&...args) noexcept {
typename futurize<void>::type futurize<void>::apply(Func &&func, FuncArgs &&... args) noexcept {
return do_void_futurize_apply(std::forward<Func>(func), std::forward<FuncArgs>(args)...);
}

Expand All @@ -1237,7 +1238,7 @@ typename futurize<future<Args...>>::type futurize<future<Args...>>::apply(Func &

template <typename... Args>
template <typename Func, typename... FuncArgs>
typename futurize<future<Args...>>::type futurize<future<Args...>>::apply(Func &&func, FuncArgs &&...args) noexcept {
typename futurize<future<Args...>>::type futurize<future<Args...>>::apply(Func &&func, FuncArgs &&... args) noexcept {
try {
return func(std::forward<FuncArgs>(args)...);
} catch (...) {
Expand Down Expand Up @@ -1277,7 +1278,7 @@ inline future<> futurize<void>::from_tuple([[maybe_unused]] std::tuple<> &&value
inline future<> futurize<void>::from_tuple([[maybe_unused]] const std::tuple<> &value) { return make_ready_future<>(); }

template <typename Func, typename... Args>
auto futurize_apply(Func &&func, Args &&...args) {
auto futurize_apply(Func &&func, Args &&... args) {
using futurator = futurize<std::result_of_t<Func(Args && ...)>>;
return futurator::apply(std::forward<Func>(func), std::forward<Args>(args)...);
}
Expand Down
Loading

0 comments on commit b8cc4cf

Please sign in to comment.