Przeglądaj źródła

gcc 10下编译通过

tags/2.9.10
tearshark 4 lat temu
rodzic
commit
d0ab0f462d
4 zmienionych plików z 15 dodań i 11 usunięć
  1. 6
    0
      CMakeLists.txt
  2. 2
    3
      librf/src/mutex_v2.inl
  3. 2
    6
      test_librf.cpp
  4. 5
    2
      tutorial/test_async_mutex.cpp

+ 6
- 0
CMakeLists.txt Wyświetl plik

set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc") set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines -pthread") 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() endif()
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}") message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}")

+ 2
- 3
librf/src/mutex_v2.inl Wyświetl plik

co_return std::move(unlock_guard); co_return std::move(unlock_guard);
} }


#ifndef __GNUC__
template<class... _Mtxs, typename> 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... }; mutex_t::_MutexAwaitAssembleT _MAA{ root_state(), mtxs... };
co_await detail::mutex_lock_await_lock_impl::_Lock_range(_MAA); co_await detail::mutex_lock_await_lock_impl::_Lock_range(_MAA);
} }
#endif
template<class... _Mtxs, typename> template<class... _Mtxs, typename>
inline future_t<> mutex_t::unlock(_Mtxs&... mtxs) inline future_t<> mutex_t::unlock(_Mtxs&... mtxs)

+ 2
- 6
test_librf.cpp Wyświetl plik

(void)argc; (void)argc;
(void)argv; (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) //if (argc > 1)
// resumable_main_benchmark_asio_client(atoi(argv[1])); // resumable_main_benchmark_asio_client(atoi(argv[1]));

+ 5
- 2
tutorial/test_async_mutex.cpp Wyświetl plik

{ {
for (int i = 0; i < 10000; ++i) 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(a.is_locked());
assert(b.is_locked()); assert(b.is_locked());
assert(c.is_locked()); assert(c.is_locked());
//std::cout << "pop :" << g_counter << " on " << idx << std::endl; //std::cout << "pop :" << g_counter << " on " << idx << std::endl;
//co_await 5ms; //co_await 5ms;
co_await mutex_t::unlock(a, b, c);
//co_await mutex_t::unlock(a, b, c);
} }
} }
void resumable_main_mutex() void resumable_main_mutex()
{ {
std::cout << "begin resumable_mutex_synch()" << std::endl;
resumable_mutex_synch(); resumable_mutex_synch();
std::cout << std::endl; std::cout << std::endl;
std::cout << "begin resumable_mutex_async()" << std::endl;
resumable_mutex_async(); resumable_mutex_async();
std::cout << std::endl; std::cout << std::endl;
std::cout << "begin resumable_mutex_lock_range()" << std::endl;
resumable_mutex_lock_range(); resumable_mutex_lock_range();
} }

Ładowanie…
Anuluj
Zapisz