Переглянути джерело

完成新版本下协程frame pointer的测试

tags/v2.9.7
tearshark 4 роки тому
джерело
коміт
aa96b843dd

+ 19
- 0
librf/src/state.cpp Переглянути файл

@@ -9,6 +9,25 @@ namespace resumef
{
}
void state_base_t::resume()
{
coroutine_handle<> handler;
scoped_lock<lock_type> __guard(_mtx);
if (_initor != nullptr)
{
handler = _initor;
_initor = nullptr;
handler();
}
else if (_coro != nullptr)
{
handler = _coro;
_coro = nullptr;
handler();
}
}
void state_base_t::set_exception(std::exception_ptr e)
{
scoped_lock<lock_type> __guard(this->_mtx);

+ 5
- 34
librf/src/state.h Переглянути файл

@@ -38,30 +38,13 @@ namespace resumef
RF_API virtual ~state_base_t();
virtual bool has_value() const = 0;
void resume();
bool is_ready() const
{
return _is_awaitor == false || has_value() || _exception != nullptr;
}
void resume()
{
coroutine_handle<> handler;
scoped_lock<lock_type> __guard(_mtx);
if (_initor != nullptr)
{
handler = _initor;
_initor = nullptr;
handler();
}
else if(_coro != nullptr)
{
handler = _coro;
_coro = nullptr;
handler();
}
}
coroutine_handle<> get_handler() const
{
return _coro;
@@ -71,12 +54,15 @@ namespace resumef
return _initor != nullptr || _coro != nullptr;
}
scheduler_t* get_scheduler() const
{
return _parent ? _parent->get_scheduler() : _scheduler;
}
void set_scheduler(scheduler_t* sch)
{
scoped_lock<lock_type> __guard(_mtx);
_scheduler = sch;
}
void set_scheduler_handler(scheduler_t* sch, coroutine_handle<> handler)
{
scoped_lock<lock_type> __guard(_mtx);
@@ -86,25 +72,10 @@ namespace resumef
_coro = handler;
}
scheduler_t* get_scheduler() const
{
return _parent ? _parent->get_scheduler() : _scheduler;
}
state_base_t * get_parent() const
{
return _parent;
}
/*
const state_base_t* root_state() const
{
return _parent ? _parent->root_state() : this;
}
state_base_t* root_state()
{
return _parent ? _parent->root_state() : this;
}
*/
void set_exception(std::exception_ptr e);

+ 4
- 4
tutorial/test_async_routine.cpp Переглянути файл

@@ -18,7 +18,7 @@ future_t<> test_routine_use_timer()
{
co_await resumef::sleep_for(100ms);
std::cout << "timer after 100ms" << std::endl;
std::cout << "1:frame=" << _coro_frame_ptr() << ",promise=" << _coro_promise_ptr(void) << std::endl << std::endl;
std::cout << "1:frame=" << _coro_frame_ptr() << std::endl;
}
}
@@ -27,11 +27,11 @@ future_t<> test_routine_use_timer_2()
std::cout << "test_routine_use_timer_2" << std::endl;
co_await test_routine_use_timer();
std::cout << "2:frame=" << _coro_frame_ptr() << ",promise=" << _coro_promise_ptr(void) << std::endl << std::endl;
std::cout << "2:frame=" << _coro_frame_ptr() << std::endl;
co_await test_routine_use_timer();
std::cout << "2:frame=" << _coro_frame_ptr() << ",promise=" << _coro_promise_ptr(void) << std::endl << std::endl;
std::cout << "2:frame=" << _coro_frame_ptr() << std::endl;
co_await test_routine_use_timer();
std::cout << "2:frame=" << _coro_frame_ptr() << ",promise=" << _coro_promise_ptr(void) << std::endl << std::endl;
std::cout << "2:frame=" << _coro_frame_ptr() << std::endl;
}
void resumable_main_routine()

+ 3
- 3
vs_proj/librf.cpp Переглянути файл

@@ -28,8 +28,9 @@ extern void resumable_main_benchmark_asio_client(intptr_t nNum);
int main(int argc, const char* argv[])
{
resumable_main_cb();
resumable_main_suspend_always();
//resumable_main_cb();
//resumable_main_suspend_always();
resumable_main_routine();
//resumable_main_exception();
/*
@@ -45,7 +46,6 @@ int main(int argc, const char* argv[])
resumable_main_yield_return();
resumable_main_timer();
resumable_main_sleep();
resumable_main_routine();
resumable_main_resumable();
resumable_main_mutex();
resumable_main_event();

+ 1
- 4
vs_proj/librf.vcxproj Переглянути файл

@@ -247,10 +247,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\tutorial\test_async_routine.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\tutorial\test_async_routine.cpp" />
<ClCompile Include="..\tutorial\test_async_sleep.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

Завантаження…
Відмінити
Зберегти