{ | { | ||||
if constexpr (USE_LINK_QUEUE) | if constexpr (USE_LINK_QUEUE) | ||||
{ | { | ||||
return reinterpret_cast<state_read_t*>(_read_awakes.try_pop()); | |||||
return _read_awakes.try_pop(); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (!_read_awakes.empty()) | if (!_read_awakes.empty()) | ||||
{ | { | ||||
state_write_t* state = _read_awakes.front(); | |||||
state_read_t* state = _read_awakes.front(); | |||||
_read_awakes.pop_front(); | _read_awakes.pop_front(); | ||||
return state; | return state; | ||||
} | } | ||||
{ | { | ||||
if constexpr (USE_LINK_QUEUE) | if constexpr (USE_LINK_QUEUE) | ||||
{ | { | ||||
return reinterpret_cast<state_write_t*>(_write_awakes.try_pop()); | |||||
return _write_awakes.try_pop(); | |||||
} | } | ||||
else | else | ||||
{ | { |
return false; | return false; | ||||
_state = new detail::state_mutex_t(); | _state = new detail::state_mutex_t(); | ||||
(void)_state->on_await_suspend(handler, parent->get_scheduler(), _root); | |||||
_state->on_await_suspend(handler, parent->get_scheduler(), _root); | |||||
_mutex->add_wait_list_lockless(_state.get()); | _mutex->add_wait_list_lockless(_state.get()); | ||||
template<typename T> | template<typename T> | ||||
concept _AwaitorT = requires(T&& v) | concept _AwaitorT = requires(T&& v) | ||||
{ | { | ||||
{ v.await_ready() } -> bool; | |||||
{ v.await_ready() } ->bool; | |||||
{ v.await_suspend(std::declval<std::experimental::coroutine_handle<promise_t<>>>()) }; | { v.await_suspend(std::declval<std::experimental::coroutine_handle<promise_t<>>>()) }; | ||||
{ v.await_resume() }; | { v.await_resume() }; | ||||
requires traits::is_valid_await_suspend_return_v< | |||||
decltype(v.await_suspend(std::declval<std::experimental::coroutine_handle<promise_t<>>>())) | |||||
>; | |||||
}; | }; | ||||
template<typename T> | template<typename T> |
//test_ring_queue<resumef::ring_queue_spinlock<int, false, uint32_t>>(); | //test_ring_queue<resumef::ring_queue_spinlock<int, false, uint32_t>>(); | ||||
//test_ring_queue<resumef::ring_queue_lockfree<int, uint64_t>>(); | //test_ring_queue<resumef::ring_queue_lockfree<int, uint64_t>>(); | ||||
//resumable_main_event_v2(); | |||||
//resumable_main_event(); | |||||
//resumable_main_event_timeout(); | |||||
//resumable_main_sleep(); | |||||
//resumable_main_resumable(); | |||||
//return 0; | |||||
resumable_main_channel_mult_thread(); | |||||
resumable_main_channel(); | |||||
return 0; | |||||
//if (argc > 1) | //if (argc > 1) | ||||
// resumable_main_benchmark_asio_client(atoi(argv[1])); | // resumable_main_benchmark_asio_client(atoi(argv[1])); |
</PropertyGroup> | </PropertyGroup> | ||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
<ConfigurationType>Application</ConfigurationType> | <ConfigurationType>Application</ConfigurationType> | ||||
<PlatformToolset>ClangCL</PlatformToolset> | |||||
<PlatformToolset>v142</PlatformToolset> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | <UseDebugLibraries>true</UseDebugLibraries> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
<ConfigurationType>Application</ConfigurationType> | <ConfigurationType>Application</ConfigurationType> | ||||
<UseDebugLibraries>false</UseDebugLibraries> | <UseDebugLibraries>false</UseDebugLibraries> | ||||
<PlatformToolset>ClangCL</PlatformToolset> | |||||
<PlatformToolset>v142</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
<CharacterSet>NotSet</CharacterSet> | <CharacterSet>NotSet</CharacterSet> | ||||
</PropertyGroup> | </PropertyGroup> |