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 async_request_update();
28 que.emplace(std::move(v));
29 pending_update.store(
true, std::memory_order_release);
30 async_request_update();
33 bool try_get(T& v)
override {
35 if(
auto f = que.front()) {
44 const sc_core::sc_event& data_event()
const override {
return ev_; }
47 void update()
override {
48 if(pending_update.exchange(
false, std::memory_order_acq_rel))
49 ev_.notify(sc_core::SC_ZERO_TIME);
52 sc_core::sc_event ev_;
53 std::atomic<bool> pending_update{
false};