| 169 | } // namespace |
| 170 | |
| 171 | Maybe<void> VirtualMachine::BlockingRunProbeFunc( |
| 172 | const std::function<bool(vm::VirtualMachineEngine*)>& prob_func) { |
| 173 | JUST(Singleton<ForeignLockHelper>::Get()->WithScopedRelease([&, this]() -> Maybe<void> { |
| 174 | auto bc = std::make_shared<BlockingCounter>(1); |
| 175 | engine_->InsertProbe([bc, prob_func](vm::VirtualMachineEngine* engine) { |
| 176 | if (!prob_func(engine)) { return false; } |
| 177 | bc->Decrease(); |
| 178 | return true; |
| 179 | }); |
| 180 | if (threads_closed_ || !multi_thread_) { |
| 181 | ScheduleUntilVMEmpty(engine_.Mutable(), SingleThreadScheduleCtx()); |
| 182 | } else { |
| 183 | pending_notifier_.Notify(); |
| 184 | } |
| 185 | JUST(bc->WaitUntilCntEqualZero(VirtualMachine::GetPredicatorNoMoreInstructionsFinished())); |
| 186 | return Maybe<void>::Ok(); |
| 187 | })); |
| 188 | return Maybe<void>::Ok(); |
| 189 | } |
| 190 | |
| 191 | Maybe<void> VirtualMachine::ShrinkAllMem() { |
| 192 | auto try_shrink_men = [](vm::VirtualMachineEngine* engine) -> bool { |
nothing calls this directly
no test coverage detected