Skip to content

Commit

Permalink
fix pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed Sep 19, 2024
1 parent 8658c98 commit b29de6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ include(CTest) # for BUILD_TESTING option
include(CMakePackageConfigHelpers) # for write_basic_package_version_file

option(BUILD_DEPS "Use FetchContent download and build dependencies" OFF)
set(BUILD_TESTING ON)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_CXX_STANDARD 20)
set(BUILD_TESTING ON)
endif()

if(BUILD_DEPS)
include(FetchContent)
Expand Down Expand Up @@ -57,10 +61,6 @@ if(BUILD_TESTING AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
endif()

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_CXX_STANDARD 20)
endif()

file(GLOB_RECURSE BABYLON_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/babylon/*.cpp")
add_library(babylon "${BABYLON_SRCS}")
add_library(babylon::babylon ALIAS babylon)
Expand Down
13 changes: 10 additions & 3 deletions src/babylon/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class FutureContext {
inline CallbackNode* seal() noexcept;

inline ValueType& value() noexcept;
inline ValueType* pointer() noexcept;

void wait_slow() noexcept;
bool wait_for_slow(int64_t timeout_ns) noexcept;
Expand Down Expand Up @@ -196,7 +197,7 @@ template <typename T, typename M>
template <typename... Args, typename>
inline void FutureContext<T, M>::set_value(Args&&... args) {
// 构造并设置value
new (&value()) ValueType(::std::forward<Args>(args)...);
new (pointer()) ValueType(::std::forward<Args>(args)...);
// 原子发布数据:
// 1、获取当前注册的回调链
// 2、标记后续不再接受回调注册
Expand Down Expand Up @@ -256,7 +257,7 @@ inline void FutureContext<T, M>::on_finish(C&& callback) noexcept {
auto* node = new CallbackNode(
::std::bind(internal::future::run_callback<C, ValueType>,
uncomposable_bind_argument(::std::forward<C>(callback)),
::std::ref(value())));
::std::ref(*pointer())));
#endif // __cplusplus

while (true) {
Expand Down Expand Up @@ -311,7 +312,13 @@ template <typename T, typename M>
inline typename FutureContext<T, M>::ValueType&
FutureContext<T, M>::value() noexcept {
assert(ready(::std::memory_order_acquire) && "cannot read value before ready");
return *reinterpret_cast<ValueType*>(_storage);
return *pointer();
}

template <typename T, typename M>
inline typename FutureContext<T, M>::ValueType*
FutureContext<T, M>::pointer() noexcept {
return reinterpret_cast<ValueType*>(_storage);
}

template <typename T, typename M>
Expand Down
2 changes: 0 additions & 2 deletions src/babylon/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ int FastLocalTimeConverter::to_weekday(::absl::CivilSecond civil) noexcept {
return 5;
case ::absl::Weekday::saturday:
return 6;
default:
break;
}
::abort();
}
Expand Down

0 comments on commit b29de6d

Please sign in to comment.