Celebr0 0 Posted October 7 (edited) Hello, I just started studying the OmniThreadLibrary library, but I can’t figure out how to parallelize this Regex procedure ? procedure pars(const Regex: TRegEx; const str: string); var Match: TMatch; begin Match := Regex.Match(str); //Parallel.ForEach(???).Execute( ??????????????? while Match.Success do begin //Match.Value; Match := Match.NextMatch; end; end; Edited October 7 by Celebr0 Share this post Link to post
Dave Novo 51 Posted October 7 Parallelizing works well if you can break your overall job into multiple independent tasks, and each task can operate independently of the results of the other task. If the tasks depend on each other in any way, it becomes quite complex quite quickly, generally having to introduce locking and communication mechanisms. In the case of RegEx parsing, how would you break your overall search into multiple independent searches. I dont see an easy way to do this. Each match depends on the results of previous matches. I am not saying it cannot be done, someone might have thought of something extremely clever, but its going to be complicated I think. Share this post Link to post
Brian Evans 105 Posted October 7 Results/matches are produced linearly so ForEach() has nothing to work on. You could use tasks to do the work on each match. (4. Low-level multi-threading (omnithreadlibrary.com)) Share this post Link to post
Celebr0 0 Posted October 8 6 hours ago, Brian Evans said: Results/matches are produced linearly so ForEach() has nothing to work on. You could use tasks to do the work on each match. (4. Low-level multi-threading (omnithreadlibrary.com)) That even Regex cannot be accelerated in any way through OmniLibrary ? Share this post Link to post