}
friend void intrusive_ptr_add_ref(Activity* a) { a->refcount_.fetch_add(1, std::memory_order_relaxed); }
#endif
+ Activity* add_ref()
+ {
+ intrusive_ptr_add_ref(this);
+ return this;
+ }
+ Activity* unref()
+ {
+ intrusive_ptr_release(this);
+ return this;
+ }
private:
kernel::activity::ActivityImplPtr pimpl_ = nullptr;
sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
{
- return (mailbox->put_async(payload, simulated_size_in_bytes)).detach();
+ auto comm = mailbox->put_async(payload, simulated_size_in_bytes);
+ comm->add_ref();
+ return comm.get();
}
/** @brief Set the mailbox to receive in asynchronous mode