Attila Kovacs 631 Posted April 9, 2020 (edited) is it ok regarding to multithread design pattern to free an object in a different process thread as it was created in? Seems to work, but are there any caveats? function TfrmSync.NewCookieList: TclCookieList; begin Result := TclCookieList.Create(nil, TclCookieItem); Result.Assign(FCookies); end; mainthread begin ... Fpipeline := Parallel.pipeline.Stage(Retriever, ....)...Run; Fpipeline.input.Add(TRetrieverParam.Create(..., NewCookieList)); <---- New instance ... Fpipeline.input.CompleteAdding; end; procedure TfrmSync.Retriever(const input: TOmniValue; var output: TOmniValue); begin ..... TRetrieverParam(input).CookieList.Free; <---- EOL end; Edited April 10, 2020 by Attila Kovacs Share this post Link to post
Dalija Prasnikar 1402 Posted April 9, 2020 No caveats for above code. You can freely Free object instance from different thread than one where it is created. Problem would arise if you would have object instance that is being simultaneously accessed by multiple threads. 1 Share this post Link to post
Fr0sT.Brutal 900 Posted April 10, 2020 I guess you didn't really meant process 1 Share this post Link to post
Attila Kovacs 631 Posted April 10, 2020 @Fr0sT.Brutal eauhm, yes, thread of course.... thanks! Share this post Link to post