@@ -9,6 +9,12 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | |||
set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc") | |||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | |||
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines -pthread") | |||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -ggdb") | |||
else() | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") | |||
endif() | |||
endif() | |||
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}") |
@@ -534,14 +534,13 @@ namespace resumef | |||
co_return std::move(unlock_guard); | |||
} | |||
#ifndef __GNUC__ | |||
template<class... _Mtxs, typename> | |||
inline future_t<> mutex_t::lock(adopt_manual_unlock_t, _Mtxs&... mtxs) | |||
inline future_t<> mutex_t::lock(adopt_manual_unlock_t _noused, _Mtxs&... mtxs) | |||
{ | |||
(void)_noused; //GCC: 这个参数不起一个名字,会导致GCC编译器内部错误。 | |||
mutex_t::_MutexAwaitAssembleT _MAA{ root_state(), mtxs... }; | |||
co_await detail::mutex_lock_await_lock_impl::_Lock_range(_MAA); | |||
} | |||
#endif | |||
template<class... _Mtxs, typename> | |||
inline future_t<> mutex_t::unlock(_Mtxs&... mtxs) |
@@ -34,12 +34,8 @@ int main(int argc, const char* argv[]) | |||
(void)argc; | |||
(void)argv; | |||
//test_ring_queue_simple<resumef::ring_queue<int>>(); | |||
//test_ring_queue<resumef::ring_queue_spinlock<int, false, uint32_t>>(); | |||
//test_ring_queue<resumef::ring_queue_lockfree<int, uint64_t>>(); | |||
//resumable_main_channel(); | |||
//return 0; | |||
resumable_main_mutex(); | |||
return 0; | |||
//if (argc > 1) | |||
// resumable_main_benchmark_asio_client(atoi(argv[1])); |
@@ -167,7 +167,7 @@ static future_t<> resumable_mutex_range_pop(size_t idx, mutex_t a, mutex_t b, mu | |||
{ | |||
for (int i = 0; i < 10000; ++i) | |||
{ | |||
co_await mutex_t::lock(adopt_manual_unlock, a, b, c); | |||
batch_unlock_t __lockers = co_await mutex_t::lock(a, b, c); | |||
assert(a.is_locked()); | |||
assert(b.is_locked()); | |||
assert(c.is_locked()); | |||
@@ -176,7 +176,7 @@ static future_t<> resumable_mutex_range_pop(size_t idx, mutex_t a, mutex_t b, mu | |||
//std::cout << "pop :" << g_counter << " on " << idx << std::endl; | |||
//co_await 5ms; | |||
co_await mutex_t::unlock(a, b, c); | |||
//co_await mutex_t::unlock(a, b, c); | |||
} | |||
} | |||
@@ -206,11 +206,14 @@ static void resumable_mutex_lock_range() | |||
void resumable_main_mutex() | |||
{ | |||
std::cout << "begin resumable_mutex_synch()" << std::endl; | |||
resumable_mutex_synch(); | |||
std::cout << std::endl; | |||
std::cout << "begin resumable_mutex_async()" << std::endl; | |||
resumable_mutex_async(); | |||
std::cout << std::endl; | |||
std::cout << "begin resumable_mutex_lock_range()" << std::endl; | |||
resumable_mutex_lock_range(); | |||
} |