MATLAB PARALLEL COMPUTING TOOLBOX - S Uživatelská příručka Strana 360

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 656
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 359
11 Functions — Alphabetical List
11-16
cancel (FevalFuture)
Cancel queued or running future
Syntax
cancel(F)
Description
cancel(F) stops the queued and running futures contained in F. No action is taken
for finished futures. Each element of F that is not already in state 'finished' has
its State property set to 'finished', and its Error property is set to contain an
MException indicating that execution was cancelled.
Examples
Run a function several times until a satisfactory result is found. In this case, the array of
futures F is cancelled when a result is greater than 0.95.
N = 100;
for idx = N:-1:1
F(idx) = parfeval(@rand,1); % Create a random scalar
end
result = NaN; % No result yet.
for idx = 1:N
[~, thisResult] = fetchNext(F);
if thisResult > 0.95
result = thisResult;
% Have all the results needed, so break
break;
end
end
% With required result, cancel any remaining futures
cancel(F)
result
Zobrazit stránku 359
1 2 ... 355 356 357 358 359 360 361 362 363 364 365 ... 655 656

Komentáře k této Příručce

Žádné komentáře