mirror of
https://github.com/tearshark/librf.git
synced 2024-10-01 15:57:07 +08:00
兼容gcc 10
This commit is contained in:
parent
d0ab0f462d
commit
b0b9934845
@ -475,7 +475,7 @@ namespace resumef
|
|||||||
for (int cnt = rand() % (1 + _mutex.size()); cnt >= 0; --cnt)
|
for (int cnt = rand() % (1 + _mutex.size()); cnt >= 0; --cnt)
|
||||||
{
|
{
|
||||||
std::this_thread::yield(); //还要考虑多线程里运行的情况
|
std::this_thread::yield(); //还要考虑多线程里运行的情况
|
||||||
co_await yield_awaitor{};
|
co_await yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
future_t<> _ReturnValue() const;
|
future_t<> _ReturnValue() const;
|
||||||
|
@ -104,7 +104,6 @@ struct LOCK_ASSEMBLE_NAME(lock_impl)
|
|||||||
static auto _Lock_nonmember2(_LA& _LkN) ->decltype(_LkN._ReturnValue())
|
static auto _Lock_nonmember2(_LA& _LkN) ->decltype(_LkN._ReturnValue())
|
||||||
{
|
{
|
||||||
// lock 2 locks, without deadlock, special case for better codegen and reduced metaprogramming for common case
|
// lock 2 locks, without deadlock, special case for better codegen and reduced metaprogramming for common case
|
||||||
#if defined(__GNUC__)
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
auto _Result__ = LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 0, 1));
|
auto _Result__ = LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 0, 1));
|
||||||
@ -112,12 +111,6 @@ struct LOCK_ASSEMBLE_NAME(lock_impl)
|
|||||||
_Result__ = LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 1, 0));
|
_Result__ = LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 1, 0));
|
||||||
if (!_Result__) break;
|
if (!_Result__) break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
while (LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 0, 1)) &&
|
|
||||||
LOCK_ASSEMBLE_AWAIT(_Lock_attempt_small2(_LkN, 1, 0)))
|
|
||||||
{ // keep trying
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<_LockAssembleT _LA>
|
template<_LockAssembleT _LA>
|
||||||
|
@ -158,7 +158,6 @@ static future_t<> resumable_mutex_range_push(size_t idx, mutex_t a, mutex_t b, m
|
|||||||
|
|
||||||
++g_counter;
|
++g_counter;
|
||||||
//std::cout << "push:" << g_counter << " on " << idx << std::endl;
|
//std::cout << "push:" << g_counter << " on " << idx << std::endl;
|
||||||
|
|
||||||
//co_await 5ms;
|
//co_await 5ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,9 +173,7 @@ static future_t<> resumable_mutex_range_pop(size_t idx, mutex_t a, mutex_t b, mu
|
|||||||
|
|
||||||
--g_counter;
|
--g_counter;
|
||||||
//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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user