Is there a way to tell if a function is executing inside a parfor?

13 ビュー (過去 30 日間)
Adam
Adam 2014 年 9 月 11 日
コメント済み: Adam 2014 年 9 月 12 日
When I just start typing on the command line and tab to give auto-complete options I came across
isinparfor
This sounded as though it is exactly what I am looking for, but it is undocumented, does nothing and when I look inside the function the 'parfor_depth' that it calls also seems not to do anything either.
I have a function which in some circumstances opens up a dialog with uiwait for the user to choose a directory. This function happens to now be being called from another function and the root function for these calls is being executed in a parfor loop. This causes problems because the program just hangs for ever in the uiwaits since the dialog boxes can't be shown within a parfor loop.
So I was hoping there would be some function or way of telling in the function whether or not it is being executed inside a parfor loop so that I can avoid doing the uiwait browser dialog in that case. So far I haven't been able to find one though.

採用された回答

Edric Ellis
Edric Ellis 2014 年 9 月 12 日
You could try using
isOnWorker = ~isempty(getCurrentTask());
to see if your code is running on a worker.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by