MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / BlockingRunProbeFunc

Method BlockingRunProbeFunc

oneflow/core/vm/virtual_machine.cpp:171–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169} // namespace
170
171Maybe<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
191Maybe<void> VirtualMachine::ShrinkAllMem() {
192 auto try_shrink_men = [](vm::VirtualMachineEngine* engine) -> bool {

Callers

nothing calls this directly

Calls 9

GetFunction · 0.85
ScheduleUntilVMEmptyFunction · 0.85
InsertProbeMethod · 0.80
NotifyMethod · 0.80
WithScopedReleaseMethod · 0.45
DecreaseMethod · 0.45
MutableMethod · 0.45
WaitUntilCntEqualZeroMethod · 0.45

Tested by

no test coverage detected