13template <
typename T>
struct async_queue : sc_core::sc_prim_channel,
async_source_if<T> {
15 async_queue(
unsigned size = 16)
18 explicit async_queue(
const char* nm,
unsigned size = 16)
19 : sc_core::sc_prim_channel{nm}
22 void push(T
const& v) {
24 pending_update.store(
true, std::memory_order_release);
25 async_request_update();
29 que.emplace(std::move(v));
30 pending_update.store(
true, std::memory_order_release);
31 async_request_update();
34 bool try_get(T& v)
override {
36 if(
auto f = que.front()) {
45 const sc_core::sc_event& data_event()
const override {
return ev_; }
48 void update()
override {
49 if(pending_update.exchange(
false, std::memory_order_acq_rel))
50 ev_.notify(sc_core::SC_ZERO_TIME);
53 sc_core::sc_event ev_;
54 std::atomic<bool> pending_update{
false};