Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-concurrency
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-concurrency
Commits
73ffae31
Commit
73ffae31
authored
Jul 07, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reroganise source tree into unified include/typon
parent
68ca2bb2
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
178 additions
and
140 deletions
+178
-140
rt/include/typon/continuation.hpp
rt/include/typon/continuation.hpp
+2
-2
rt/include/typon/defer.hpp
rt/include/typon/defer.hpp
+27
-0
rt/include/typon/event_count.hpp
rt/include/typon/event_count.hpp
+5
-5
rt/include/typon/fork.hpp
rt/include/typon/fork.hpp
+6
-6
rt/include/typon/forked.hpp
rt/include/typon/forked.hpp
+8
-9
rt/include/typon/fundamental/meta.hpp
rt/include/typon/fundamental/meta.hpp
+0
-21
rt/include/typon/future.hpp
rt/include/typon/future.hpp
+7
-7
rt/include/typon/garbage_collector.hpp
rt/include/typon/garbage_collector.hpp
+11
-11
rt/include/typon/join.hpp
rt/include/typon/join.hpp
+4
-4
rt/include/typon/parent.hpp
rt/include/typon/parent.hpp
+4
-4
rt/include/typon/pool.hpp
rt/include/typon/pool.hpp
+4
-4
rt/include/typon/promise.hpp
rt/include/typon/promise.hpp
+7
-8
rt/include/typon/random.hpp
rt/include/typon/random.hpp
+4
-4
rt/include/typon/result.hpp
rt/include/typon/result.hpp
+2
-2
rt/include/typon/ring.hpp
rt/include/typon/ring.hpp
+36
-0
rt/include/typon/ring_buffer.hpp
rt/include/typon/ring_buffer.hpp
+15
-15
rt/include/typon/root.hpp
rt/include/typon/root.hpp
+4
-4
rt/include/typon/scheduler.hpp
rt/include/typon/scheduler.hpp
+12
-13
rt/include/typon/stack.hpp
rt/include/typon/stack.hpp
+10
-11
rt/include/typon/task.hpp
rt/include/typon/task.hpp
+3
-3
rt/include/typon/typon.hpp
rt/include/typon/typon.hpp
+7
-7
No files found.
rt/include/typon/co
re/co
ntinuation.hpp
→
rt/include/typon/continuation.hpp
View file @
73ffae31
#ifndef TYPON_CO
RE_CO
NTINUATION_HPP_INCLUDED
#define TYPON_CO
RE_CO
NTINUATION_HPP_INCLUDED
#ifndef TYPON_CONTINUATION_HPP_INCLUDED
#define TYPON_CONTINUATION_HPP_INCLUDED
#include <coroutine>
#include <cstdint>
...
...
rt/include/typon/
fundamental/scope
.hpp
→
rt/include/typon/
defer
.hpp
View file @
73ffae31
#ifndef TYPON_
FUNDAMENTAL_
SCOPE_HPP_INCLUDED
#define TYPON_
FUNDAMENTAL_
SCOPE_HPP_INCLUDED
#ifndef TYPON_SCOPE_HPP_INCLUDED
#define TYPON_SCOPE_HPP_INCLUDED
#include <concepts>
namespace
typon
::
fdt
namespace
typon
{
template
<
std
::
invocable
<
>
F
>
struct
d
efer
struct
D
efer
{
F
_f
;
~
d
efer
()
~
D
efer
()
{
_f
();
}
};
template
<
std
::
invocable
<
>
F
>
defer
(
F
)
->
d
efer
<
F
>
;
Defer
(
F
)
->
D
efer
<
F
>
;
}
#endif // TYPON_
FUNDAMENTAL_
SCOPE_HPP_INCLUDED
#endif // TYPON_SCOPE_HPP_INCLUDED
rt/include/typon/
fundamental/
event_count.hpp
→
rt/include/typon/event_count.hpp
View file @
73ffae31
#ifndef TYPON_EVENTCOUNT_HPP_INCLUDED
#define TYPON_EVENTCOUNT_HPP_INCLUDED
#ifndef TYPON_EVENT
_
COUNT_HPP_INCLUDED
#define TYPON_EVENT
_
COUNT_HPP_INCLUDED
#include <atomic>
#include <cstdint>
namespace
typon
::
fdt
::
lock_free
namespace
typon
{
template
<
unsigned
int
N
=
10
>
struct
event_c
ount
struct
EventC
ount
{
using
u64
=
std
::
uint_fast64_t
;
...
...
@@ -63,4 +63,4 @@ namespace typon::fdt::lock_free
}
#endif // TYPON_EVENTCOUNT_HPP_INCLUDED
#endif // TYPON_EVENT
_
COUNT_HPP_INCLUDED
rt/include/typon/
core/
fork.hpp
→
rt/include/typon/fork.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
FORK_HPP_INCLUDED
#define TYPON_
CORE_
FORK_HPP_INCLUDED
#ifndef TYPON_FORK_HPP_INCLUDED
#define TYPON_FORK_HPP_INCLUDED
#include <coroutine>
#include <cstdint>
#include <typon/
core/
forked.hpp>
#include <typon/
core/
parent.hpp>
#include <typon/
core/
result.hpp>
#include <typon/
core/
scheduler.hpp>
#include <typon/forked.hpp>
#include <typon/parent.hpp>
#include <typon/result.hpp>
#include <typon/scheduler.hpp>
namespace
typon
...
...
rt/include/typon/
core/
forked.hpp
→
rt/include/typon/forked.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
FORKED_HPP_INCLUDED
#define TYPON_
CORE_
FORKED_HPP_INCLUDED
#ifndef TYPON_FORKED_HPP_INCLUDED
#define TYPON_FORKED_HPP_INCLUDED
#include <coroutine>
#include <memory>
#include <type_traits>
#include <utility>
#include <typon/fundamental/scope.hpp>
#include <typon/core/result.hpp>
#include <typon/defer.hpp>
#include <typon/result.hpp>
namespace
typon
...
...
@@ -30,7 +29,7 @@ namespace typon
{
if
(
ready
)
{
fdt
::
d
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
D
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
std
::
construct_at
(
std
::
addressof
(
_value
),
coroutine
.
promise
().
get
());
}
else
...
...
@@ -152,7 +151,7 @@ namespace typon
{
if
(
ready
)
{
fdt
::
d
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
D
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
std
::
construct_at
(
std
::
addressof
(
_value
),
coroutine
.
promise
().
get
());
}
else
...
...
@@ -196,7 +195,7 @@ namespace typon
{
if
(
ready
)
{
fdt
::
d
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
D
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
_value
=
std
::
addressof
(
coroutine
.
promise
().
get
());
}
else
...
...
@@ -228,7 +227,7 @@ namespace typon
{
if
(
ready
)
{
fdt
::
d
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
D
efer
defer
{
[
&
coroutine
]()
{
coroutine
.
destroy
();
}
};
coroutine
.
promise
().
get
();
}
else
...
...
rt/include/typon/fundamental/meta.hpp
deleted
100644 → 0
View file @
68ca2bb2
#ifndef TYPON_META_HPP_INCLUDED
#define TYPON_META_HPP_INCLUDED
namespace
typon
::
fdt
::
meta
{
template
<
template
<
typename
...
>
typename
T
>
struct
lazy
{
template
<
typename
...
Args
>
using
type
=
T
<
Args
...
>
;
};
template
<
typename
...
T
>
static
constexpr
bool
always_false_v
{
false
};
}
#endif // TYPON_META_HPP_INCLUDED
rt/include/typon/
core/
future.hpp
→
rt/include/typon/future.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
FUTURE_HPP_INCLUDED
#define TYPON_
CORE_
FUTURE_HPP_INCLUDED
#ifndef TYPON_FUTURE_HPP_INCLUDED
#define TYPON_FUTURE_HPP_INCLUDED
#include <atomic>
#include <coroutine>
#include <cstdint>
#include <typon/co
re/co
ntinuation.hpp>
#include <typon/
core/
result.hpp>
#include <typon/
core/
scheduler.hpp>
#include <typon/
core/
stack.hpp>
#include <typon/continuation.hpp>
#include <typon/result.hpp>
#include <typon/scheduler.hpp>
#include <typon/stack.hpp>
namespace
typon
...
...
@@ -183,4 +183,4 @@ namespace typon
}
#endif // TYPON_
CORE_
FUTURE_HPP_INCLUDED
#endif // TYPON_FUTURE_HPP_INCLUDED
rt/include/typon/
fundamental/
garbage_collector.hpp
→
rt/include/typon/garbage_collector.hpp
View file @
73ffae31
#ifndef TYPON_
FUNDAMENTAL_
GARBAGE_COLLECTOR_HPP_INCLUDED
#define TYPON_
FUNDAMENTAL_
GARBAGE_COLLECTOR_HPP_INCLUDED
#ifndef TYPON_GARBAGE_COLLECTOR_HPP_INCLUDED
#define TYPON_GARBAGE_COLLECTOR_HPP_INCLUDED
#include <atomic>
#include <bit>
...
...
@@ -7,10 +7,10 @@
#include <type_traits>
namespace
typon
::
fdt
::
lock_free
namespace
typon
{
struct
garbage_c
ollector
struct
GarbageC
ollector
{
using
u64
=
std
::
uint_fast64_t
;
using
uint
=
unsigned
int
;
...
...
@@ -50,7 +50,7 @@ namespace typon::fdt::lock_free
std
::
atomic
<
node
*>
_head
;
std
::
atomic
<
node
*>
_tail
;
garbage_c
ollector
(
uint
concurrency
)
noexcept
GarbageC
ollector
(
uint
concurrency
)
noexcept
:
_concurrency
(
concurrency
)
,
_bits
(
std
::
bit_width
(
concurrency
))
,
_stamps
(
new
std
::
atomic
<
u64
>
[
concurrency
])
...
...
@@ -66,19 +66,19 @@ namespace typon::fdt::lock_free
auto
epoch
(
uint
id
)
noexcept
{
struct
e
poch
struct
E
poch
{
garbage_c
ollector
&
_gc
;
GarbageC
ollector
&
_gc
;
uint
_id
;
~
e
poch
()
~
E
poch
()
{
_gc
.
leave
(
_id
);
}
};
enter
(
id
);
return
e
poch
{
*
this
,
id
};
return
E
poch
{
*
this
,
id
};
}
void
enter
(
uint
id
)
noexcept
...
...
@@ -149,7 +149,7 @@ namespace typon::fdt::lock_free
}
}
~
garbage_c
ollector
()
~
GarbageC
ollector
()
{
delete
[]
_stamps
;
auto
tail
=
_tail
.
load
();
...
...
@@ -164,4 +164,4 @@ namespace typon::fdt::lock_free
}
#endif // TYPON_
FUNDAMENTAL_
GARBAGE_COLLECTOR_HPP_INCLUDED
#endif // TYPON_GARBAGE_COLLECTOR_HPP_INCLUDED
rt/include/typon/
core/
join.hpp
→
rt/include/typon/join.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
JOIN_HPP_INCLUDED
#define TYPON_
CORE_
JOIN_HPP_INCLUDED
#ifndef TYPON_JOIN_HPP_INCLUDED
#define TYPON_JOIN_HPP_INCLUDED
#include <coroutine>
#include <utility>
#include <typon/
core/
parent.hpp>
#include <typon/
core/
result.hpp>
#include <typon/parent.hpp>
#include <typon/result.hpp>
namespace
typon
...
...
rt/include/typon/
core/
parent.hpp
→
rt/include/typon/parent.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
PARENT_HPP_INCLUDED
#define TYPON_
CORE_
PARENT_HPP_INCLUDED
#ifndef TYPON_PARENT_HPP_INCLUDED
#define TYPON_PARENT_HPP_INCLUDED
#include <atomic>
#include <concepts>
...
...
@@ -9,7 +9,7 @@
#include <limits>
#include <vector>
#include <typon/co
re/co
ntinuation.hpp>
#include <typon/continuation.hpp>
namespace
typon
...
...
@@ -104,4 +104,4 @@ namespace typon
}
#endif // TYPON_
CORE_
PARENT_HPP_INCLUDED
#endif // TYPON_PARENT_HPP_INCLUDED
rt/include/typon/
core/
pool.hpp
→
rt/include/typon/pool.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
POOL_HPP_INCLUDED
#define TYPON_
CORE_
POOL_HPP_INCLUDED
#ifndef TYPON_POOL_HPP_INCLUDED
#define TYPON_POOL_HPP_INCLUDED
#include <mutex>
#include <vector>
#include <typon/
core/
stack.hpp>
#include <typon/stack.hpp>
namespace
typon
...
...
@@ -66,4 +66,4 @@ namespace typon
}
#endif // TYPON_
CORE_
POOL_HPP_INCLUDED
#endif // TYPON_POOL_HPP_INCLUDED
rt/include/typon/
core/
promise.hpp
→
rt/include/typon/promise.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
PROMISE_HPP_INCLUDED
#define TYPON_
CORE_
PROMISE_HPP_INCLUDED
#ifndef TYPON_PROMISE_HPP_INCLUDED
#define TYPON_PROMISE_HPP_INCLUDED
#include <atomic>
#include <cstdint>
#include <memory>
#include <type_traits>
#include <typon/fundamental/scope.hpp>
#include <typon/core/stack.hpp>
#include <typon/core/scheduler.hpp>
#include <typon/defer.hpp>
#include <typon/stack.hpp>
#include <typon/scheduler.hpp>
namespace
typon
...
...
@@ -66,7 +65,7 @@ namespace typon
T
await_resume
()
noexcept
{
fdt
::
d
efer
defer
(
[
this
]()
{
std
::
destroy_at
(
std
::
addressof
(
_value
));
});
D
efer
defer
(
[
this
]()
{
std
::
destroy_at
(
std
::
addressof
(
_value
));
});
_consumed
=
true
;
return
std
::
move
(
_value
);
}
...
...
@@ -197,4 +196,4 @@ namespace typon
}
#endif // TYPON_
CORE_
PROMISE_HPP_INCLUDED
#endif // TYPON_PROMISE_HPP_INCLUDED
rt/include/typon/
fundamental/
random.hpp
→
rt/include/typon/random.hpp
View file @
73ffae31
#ifndef TYPON_
FUNDAMENTAL_
RANDOM_HPP_INCLUDED
#define TYPON_
FUNDAMENTAL_
RANDOM_HPP_INCLUDED
#ifndef TYPON_RANDOM_HPP_INCLUDED
#define TYPON_RANDOM_HPP_INCLUDED
#include <random>
namespace
typon
::
fdt
::
random
namespace
typon
::
random
{
static
thread_local
std
::
mt19937
random
{
std
::
random_device
{}()
};
...
...
@@ -14,4 +14,4 @@ namespace typon::fdt::random
}
#endif // TYPON_
FUNDAMENTAL_
RANDOM_HPP_INCLUDED
#endif // TYPON_RANDOM_HPP_INCLUDED
rt/include/typon/
core/
result.hpp
→
rt/include/typon/result.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
RESULT_HPP_INCLUDED
#define TYPON_
CORE_
RESULT_HPP_INCLUDED
#ifndef TYPON_RESULT_HPP_INCLUDED
#define TYPON_RESULT_HPP_INCLUDED
#include <exception>
...
...
rt/include/typon/
fundamental/binary_
ring.hpp
→
rt/include/typon/ring.hpp
View file @
73ffae31
#ifndef TYPON_
FUNDAMENTAL_BINARY_
RING_HPP_INCLUDED
#define TYPON_
FUNDAMENTAL_BINARY_
RING_HPP_INCLUDED
#ifndef TYPON_RING_HPP_INCLUDED
#define TYPON_RING_HPP_INCLUDED
#include <atomic>
#include <cstdint>
#include <type_traits>
namespace
typon
::
fdt
namespace
typon
{
template
<
typename
I
>
requires
std
::
is_unsigned_v
<
I
>
struct
binary_r
ing
struct
R
ing
{
const
I
_mask
;
binary_r
ing
(
std
::
uint_least8_t
bits
)
noexcept
R
ing
(
std
::
uint_least8_t
bits
)
noexcept
:
_mask
((
I
(
1
)
<<
bits
)
-
1
)
{}
...
...
@@ -24,7 +24,7 @@ namespace typon::fdt
return
_mask
+
1
;
}
friend
I
operator
%
(
I
x
,
binary_r
ing
ring
)
noexcept
friend
I
operator
%
(
I
x
,
R
ing
ring
)
noexcept
{
return
x
&
ring
.
_mask
;
}
...
...
@@ -33,4 +33,4 @@ namespace typon::fdt
}
#endif // TYPON_
FUNDAMENTAL_BINARY_
RING_HPP_INCLUDED
#endif // TYPON_RING_HPP_INCLUDED
rt/include/typon/
fundamental/
ring_buffer.hpp
→
rt/include/typon/ring_buffer.hpp
View file @
73ffae31
#ifndef TYPON_
FUNDAMENTAL_RING
BUFFER_HPP_INCLUDED
#define TYPON_
FUNDAMENTAL_RING
BUFFER_HPP_INCLUDED
#ifndef TYPON_
RING_
BUFFER_HPP_INCLUDED
#define TYPON_
RING_
BUFFER_HPP_INCLUDED
#include <atomic>
#include <bit>
#include <cstdint>
#include <type_traits>
#include <typon/
fundamental/binary_
ring.hpp>
#include <typon/ring.hpp>
namespace
typon
::
fdt
::
lock_free
namespace
typon
{
template
<
typename
T
>
requires
std
::
is_trivially_copyable_v
<
T
>
&&
std
::
is_trivially_destructible_v
<
T
>
struct
ring_b
uffer
struct
RingB
uffer
{
using
u8
=
std
::
uint_least8_t
;
using
u64
=
std
::
uint_fast64_t
;
using
enum
std
::
memory_order
;
binary_r
ing
<
u64
>
_ring
;
ring_b
uffer
*
_next
;
R
ing
<
u64
>
_ring
;
RingB
uffer
*
_next
;
std
::
atomic
<
T
>
*
const
_array
;
ring_buffer
(
u8
bits
,
ring_b
uffer
*
next
=
nullptr
)
noexcept
RingBuffer
(
u8
bits
,
RingB
uffer
*
next
=
nullptr
)
noexcept
:
_ring
(
bits
)
,
_next
(
next
)
,
_array
(
new
std
::
atomic
<
T
>
[
this
->
capacity
()])
{}
~
ring_b
uffer
()
~
RingB
uffer
()
{
delete
[]
_array
;
if
(
_next
)
...
...
@@ -56,7 +56,7 @@ namespace typon::fdt::lock_free
return
_array
[
index
%
_ring
].
load
(
relaxed
);
}
ring_buffer
*
fill
(
ring_b
uffer
*
sink
,
u64
start
,
u64
end
)
noexcept
RingBuffer
*
fill
(
RingB
uffer
*
sink
,
u64
start
,
u64
end
)
noexcept
{
for
(
u64
i
=
start
;
i
<
end
;
i
++
)
{
...
...
@@ -65,15 +65,15 @@ namespace typon::fdt::lock_free
return
sink
;
}
ring_b
uffer
*
grow
(
u64
start
,
u64
end
)
noexcept
RingB
uffer
*
grow
(
u64
start
,
u64
end
)
noexcept
{
auto
buffer
=
new
ring_b
uffer
(
std
::
countr_zero
(
_ring
.
size
())
+
1
,
this
);
auto
buffer
=
new
RingB
uffer
(
std
::
countr_zero
(
_ring
.
size
())
+
1
,
this
);
return
fill
(
buffer
,
start
,
end
);
}
ring_b
uffer
*
shrink
(
u64
start
,
u64
end
)
noexcept
RingB
uffer
*
shrink
(
u64
start
,
u64
end
)
noexcept
{
ring_b
uffer
*
last
=
nullptr
;
RingB
uffer
*
last
=
nullptr
;
auto
next
=
this
;
auto
size
=
(
end
-
start
);
auto
threshold
=
size
*
2
;
...
...
@@ -94,4 +94,4 @@ namespace typon::fdt::lock_free
}
#endif // TYPON_
FUNDAMENTAL_RING
BUFFER_HPP_INCLUDED
#endif // TYPON_
RING_
BUFFER_HPP_INCLUDED
rt/include/typon/
core/
root.hpp
→
rt/include/typon/root.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
ROOT_HPP_INCLUDED
#define TYPON_
CORE_
ROOT_HPP_INCLUDED
#ifndef TYPON_ROOT_HPP_INCLUDED
#define TYPON_ROOT_HPP_INCLUDED
#include <atomic>
#include <coroutine>
#include <cstdint>
#include <typon/
core/
result.hpp>
#include <typon/
core/
scheduler.hpp>
#include <typon/result.hpp>
#include <typon/scheduler.hpp>
namespace
typon
...
...
rt/include/typon/
core/
scheduler.hpp
→
rt/include/typon/scheduler.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
SCHEDULER_HPP_INCLUDED
#define TYPON_
CORE_
SCHEDULER_HPP_INCLUDED
#ifndef TYPON_SCHEDULER_HPP_INCLUDED
#define TYPON_SCHEDULER_HPP_INCLUDED
#include <atomic>
#include <bit>
...
...
@@ -10,13 +10,12 @@
#include <utility>
#include <vector>
#include <typon/fundamental/event_count.hpp>
#include <typon/fundamental/garbage_collector.hpp>
#include <typon/fundamental/random.hpp>
#include <typon/core/continuation.hpp>
#include <typon/core/pool.hpp>
#include <typon/core/stack.hpp>
#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>
namespace
typon
...
...
@@ -32,11 +31,11 @@ namespace typon
const
uint
_mask
;
std
::
atomic
<
uint
>
_thieves
=
0
;
std
::
atomic
<
u64
>
_potential
=
0
;
fdt
::
lock_free
::
event_c
ount
<>
_notifyer
;
EventC
ount
<>
_notifyer
;
std
::
vector
<
Pool
>
_pool
;
std
::
vector
<
Stack
*>
_stack
;
std
::
vector
<
std
::
thread
>
_thread
;
fdt
::
lock_free
::
garbage_c
ollector
_gc
;
GarbageC
ollector
_gc
;
static
inline
thread_local
uint
thread_id
;
...
...
@@ -177,7 +176,7 @@ namespace typon
{
continue
;
}
auto
index
=
size
>
1
?
fdt
::
random
::
random
()
%
size
:
0
;
auto
index
=
size
>
1
?
random
::
random
()
%
size
:
0
;
auto
stack
=
pool
.
get
(
index
);
auto
state
=
stack
->
_state
.
load
();
if
(
state
==
Stack
::
ACTIVE
)
...
...
@@ -249,7 +248,7 @@ namespace typon
Pool
&
random
()
noexcept
{
return
_pool
[
fdt
::
random
::
random
()
&
_mask
];
return
_pool
[
random
::
random
()
&
_mask
];
}
~
Scheduler
()
noexcept
...
...
rt/include/typon/
core/
stack.hpp
→
rt/include/typon/stack.hpp
View file @
73ffae31
...
...
@@ -7,9 +7,8 @@
#include <type_traits>
#include <utility>
#include <typon/fundamental/ring_buffer.hpp>
#include <typon/core/continuation.hpp>
#include <typon/continuation.hpp>
#include <typon/ring_buffer.hpp>
namespace
typon
...
...
@@ -17,8 +16,8 @@ namespace typon
struct
Stack
{
using
ring_buffer
=
fdt
::
lock_free
::
ring_b
uffer
<
Continuation
*>
;
using
u64
=
ring_b
uffer
::
u64
;
using
RingBuffer
=
typon
::
RingB
uffer
<
Continuation
*>
;
using
u64
=
RingB
uffer
::
u64
;
using
enum
std
::
memory_order
;
...
...
@@ -26,12 +25,12 @@ namespace typon
std
::
atomic
<
u64
>
_top
{
1
};
std
::
atomic
<
u64
>
_bottom
{
1
};
std
::
atomic
<
ring_b
uffer
*>
_buffer
;
std
::
atomic
<
RingB
uffer
*>
_buffer
;
std
::
atomic
<
State
>
_state
;
std
::
coroutine_handle
<>
_coroutine
;
Stack
(
State
state
)
noexcept
:
_buffer
(
new
ring_b
uffer
(
3
))
:
_buffer
(
new
RingB
uffer
(
3
))
,
_state
(
state
)
{}
...
...
@@ -44,7 +43,7 @@ namespace typon
{
u64
bottom
=
_bottom
.
load
(
relaxed
);
u64
top
=
_top
.
load
(
acquire
);
ring_b
uffer
*
buffer
=
_buffer
.
load
(
relaxed
);
RingB
uffer
*
buffer
=
_buffer
.
load
(
relaxed
);
if
(
bottom
-
top
>
buffer
->
capacity
()
-
1
)
{
buffer
=
buffer
->
grow
(
top
,
bottom
);
...
...
@@ -78,7 +77,7 @@ namespace typon
Continuation
*
peek
()
noexcept
{
u64
bottom
=
_bottom
.
load
(
relaxed
)
-
1
;
ring_b
uffer
*
buffer
=
_buffer
.
load
(
relaxed
);
RingB
uffer
*
buffer
=
_buffer
.
load
(
relaxed
);
return
buffer
->
get
(
bottom
);
}
...
...
@@ -87,7 +86,7 @@ namespace typon
u64
top
=
_top
.
load
(
acquire
);
std
::
atomic_thread_fence
(
seq_cst
);
u64
bottom
=
_bottom
.
load
(
acquire
);
ring_b
uffer
*
buffer
=
_buffer
.
load
(
consume
);
RingB
uffer
*
buffer
=
_buffer
.
load
(
consume
);
if
(
top
<
bottom
)
{
Continuation
*
x
=
buffer
->
get
(
top
);
...
...
@@ -118,7 +117,7 @@ namespace typon
return
x
;
}
ring_b
uffer
*
reclaim
()
noexcept
RingB
uffer
*
reclaim
()
noexcept
{
u64
bottom
=
_bottom
.
load
(
relaxed
);
u64
top
=
_top
.
load
(
relaxed
);
...
...
rt/include/typon/
core/
task.hpp
→
rt/include/typon/task.hpp
View file @
73ffae31
#ifndef TYPON_
CORE_
TASK_HPP_INCLUDED
#define TYPON_
CORE_
TASK_HPP_INCLUDED
#ifndef TYPON_TASK_HPP_INCLUDED
#define TYPON_TASK_HPP_INCLUDED
#include <coroutine>
#include <utility>
#include <typon/
core/
result.hpp>
#include <typon/result.hpp>
namespace
typon
...
...
rt/include/typon/typon.hpp
View file @
73ffae31
...
...
@@ -3,13 +3,13 @@
#include <utility>
#include <typon/
core/
fork.hpp>
#include <typon/
core/
forked.hpp>
#include <typon/
core/
future.hpp>
#include <typon/
core/
join.hpp>
#include <typon/
core/
promise.hpp>
#include <typon/
core/
root.hpp>
#include <typon/
core/
task.hpp>
#include <typon/fork.hpp>
#include <typon/forked.hpp>
#include <typon/future.hpp>
#include <typon/join.hpp>
#include <typon/promise.hpp>
#include <typon/root.hpp>
#include <typon/task.hpp>
namespace
typon
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment