Transaction mémoire isolée (parallel)

De Wiki1000

Un transaction mémoire par exécuteur :

//Procedure doProcess(inst:WFClasseA);
var inst:WFClasseA;
begin
  // One separate transaction
  // Use private to allocate a new transaction in a new context
  withP  private Transaction do
   begin
     inst.unCode := 'X'+inttostr(index);
     inst.Caption := 'Objet A'+inttostr(index);
     inst.unEntier := 1+Trunc(Random(100));
   end;
end;
 
//Procedure ProcessSomeA(AList:WFClasseAList);
var tk:Int64;
begin
  tk := GetTickCount;
  try
  foreachP var inst in AList do 
   begin
    parallel dProcess(inst);
   end;
  finally
  tk := GetTickCount-tk;
  showmessage(Format('%s ms',[TickToString(tk)]));
  end;
end;
Tip-20px.png Tip : Notez l'utilisation de private pour allouer une nouvelle transaction ; sans cette option chaque exécuteur partagerait la même transaction.




Whos here now:   Members 0   Guests 0   Bots & Crawlers 1
 
Outils personnels