+
+void simcall_run_object_access(std::function<void()> const& code, simgrid::kernel::actor::ObjectAccessSimcallItem* item)
+{
+ auto self = simgrid::kernel::actor::ActorImpl::self();
+
+ // We only need a simcall if the order of the setters is important (parallel run or MC execution).
+ // Otherwise, just call the function with no simcall
+
+ if (simgrid::kernel::context::is_parallel()
+#if SIMGRID_HAVE_MC
+ || MC_is_active() || MC_record_replay_is_active()
+#endif
+ ) {
+
+ simgrid::kernel::actor::ObjectAccessSimcallObserver observer{self, item};
+ simcall(simgrid::kernel::actor::Simcall::Type::RUN_ANSWERED, code, &observer);
+ item->take_ownership();
+ } else {
+ // don't return from the context-switch we don't do
+ self->simcall_.call_ = simgrid::kernel::actor::Simcall::Type::RUN_BLOCKING;
+ self->simcall_.code_ = &code;
+ self->simcall_.observer_ = nullptr;
+ self->simcall_handle(0);
+ }
+}
\ No newline at end of file