Commit 7933d8e1 authored by Xavier Thompson's avatar Xavier Thompson

Rename continuation.hpp into theft_point.hpp

parent 3f3c9f45
......@@ -5,10 +5,10 @@
#include <coroutine>
#include <cstdint>
#include <typon/continuation.hpp>
#include <typon/result.hpp>
#include <typon/scheduler.hpp>
#include <typon/stack.hpp>
#include <typon/theft_point.hpp>
namespace typon
......@@ -18,7 +18,7 @@ namespace typon
struct [[nodiscard]] Future
{
struct promise_type;
using u64 = Continuation::u64;
using u64 = TheftPoint::u64;
using enum std::memory_order;
......@@ -87,10 +87,10 @@ namespace typon
{
std::coroutine_handle<> await_suspend(std::coroutine_handle<promise_type> coroutine) noexcept
{
auto continuation = Scheduler::peek();
auto theftpoint = Scheduler::peek();
if (Scheduler::pop())
{
return continuation->_coroutine;
return theftpoint->_coroutine;
}
auto state = coroutine.promise()._state.exchange(ready, acq_rel);
if (state == discarded)
......@@ -118,7 +118,7 @@ namespace typon
{
Future _future;
std::coroutine_handle<promise_type> _coroutine;
Continuation _continuation;
TheftPoint _theftpoint;
awaitable(Future && f, std::coroutine_handle<promise_type> c) noexcept
: _future(std::move(f))
......@@ -132,16 +132,16 @@ namespace typon
auto await_suspend(std::coroutine_handle<> continuation) noexcept
{
_continuation._coroutine = continuation;
_theftpoint._coroutine = continuation;
std::coroutine_handle<> on_stack_handle = _coroutine;
Scheduler::push(&(_continuation));
Scheduler::push(&(_theftpoint));
return on_stack_handle;
}
auto await_resume() noexcept
{
_future._ready = !_continuation._thefts;
_future._ready = !_theftpoint._thefts;
return std::move(_future);
}
};
......
......@@ -10,12 +10,12 @@
#include <utility>
#include <vector>
#include <typon/continuation.hpp>
#include <typon/event_count.hpp>
#include <typon/garbage_collector.hpp>
#include <typon/pool.hpp>
#include <typon/random.hpp>
#include <typon/stack.hpp>
#include <typon/theft_point.hpp>
namespace typon
......@@ -58,7 +58,7 @@ namespace typon
get()._notifyer.notify_one();
}
static void push(Continuation * task) noexcept
static void push(TheftPoint * task) noexcept
{
get()._stack[thread_id]->push(task);
}
......@@ -73,7 +73,7 @@ namespace typon
return result;
}
static Continuation * peek() noexcept
static TheftPoint * peek() noexcept
{
return get()._stack[thread_id]->peek();
}
......
......@@ -9,7 +9,7 @@
#include <limits>
#include <vector>
#include <typon/continuation.hpp>
#include <typon/theft_point.hpp>
namespace typon
......@@ -65,9 +65,9 @@ namespace typon
};
struct Span : Continuation
struct Span : TheftPoint
{
using u64 = Continuation::u64;
using u64 = TheftPoint::u64;
static constexpr u64 UMAX = std::numeric_limits<u64>::max();
......@@ -78,7 +78,7 @@ namespace typon
std::atomic<u64> _n = UMAX;
Span(std::coroutine_handle<> coroutine) noexcept
: Continuation(coroutine)
: TheftPoint(coroutine)
{}
void resume()
......
......@@ -7,8 +7,8 @@
#include <type_traits>
#include <utility>
#include <typon/continuation.hpp>
#include <typon/ring_buffer.hpp>
#include <typon/theft_point.hpp>
namespace typon
......@@ -16,7 +16,7 @@ namespace typon
struct Stack
{
using RingBuffer = typon::RingBuffer<Continuation *>;
using RingBuffer = typon::RingBuffer<TheftPoint *>;
using u64 = RingBuffer::u64;
using enum std::memory_order;
......@@ -39,7 +39,7 @@ namespace typon
delete _buffer.load(relaxed);
}
void push(Continuation * x) noexcept
void push(TheftPoint * x) noexcept
{
u64 bottom = _bottom.load(relaxed);
u64 top = _top.load(acquire);
......@@ -74,14 +74,14 @@ namespace typon
return false;
}
Continuation * peek() noexcept
TheftPoint * peek() noexcept
{
u64 bottom = _bottom.load(relaxed) - 1;
RingBuffer * buffer = _buffer.load(relaxed);
return buffer->get(bottom);
}
Continuation * steal() noexcept
TheftPoint * steal() noexcept
{
u64 top = _top.load(acquire);
std::atomic_thread_fence(seq_cst);
......@@ -89,7 +89,7 @@ namespace typon
RingBuffer * buffer = _buffer.load(consume);
if (top < bottom)
{
Continuation * x = buffer->get(top);
TheftPoint * x = buffer->get(top);
if (!_top.compare_exchange_strong(top, top + 1, seq_cst, relaxed))
{
return nullptr;
......@@ -99,12 +99,12 @@ namespace typon
return nullptr;
}
Continuation * pop_top() noexcept
TheftPoint * pop_top() noexcept
{
u64 top = _top.load(relaxed);
u64 bottom = _bottom.load(relaxed);
auto buffer = _buffer.load(relaxed);
Continuation * x = nullptr;
TheftPoint * x = nullptr;
if (top < bottom)
{
x = buffer->get(top);
......
#ifndef TYPON_CONTINUATION_HPP_INCLUDED
#define TYPON_CONTINUATION_HPP_INCLUDED
#ifndef TYPON_THEFT_POINT_HPP_INCLUDED
#define TYPON_THEFT_POINT_HPP_INCLUDED
#include <coroutine>
#include <cstdint>
......@@ -8,16 +8,16 @@
namespace typon
{
struct Continuation
struct TheftPoint
{
using u64 = std::uint_fast64_t;
std::coroutine_handle<> _coroutine;
u64 _thefts = 0;
Continuation() noexcept {}
TheftPoint() noexcept {}
Continuation(std::coroutine_handle<> coroutine) noexcept
TheftPoint(std::coroutine_handle<> coroutine) noexcept
: _coroutine(coroutine)
{}
};
......@@ -25,4 +25,4 @@ namespace typon
}
#endif // TYPON_CONTINUATION_HPP_INCLUDED
#endif // TYPON_THEFT_POINT_HPP_INCLUDED
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment