Jump to content

Shrinavat

Members
  • Content Count

    70
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Shrinavat

  1. Questions from my last post are still relevant 10+ days later. Dear @Primož Gabrijelčič, please reply! PS If this OTL subforum is not intended for questions, I am sorry for the time I have wasted. Is there another forum that I can ask specific OTL question and get an answer from the developer?
  2. I carefully read the "3.9 Background worker" chapter from the "Parallel Programming with OmniThreadLibrary" book, and - hallelujah! I was able to solve my problem with the help of Parallel.BackgroundWorker and Parallel.ParallelTask. Well, at least I think so... Again, project full source is in attachment, here is the main unit part: Everything running like clockwork. But I have a few questions again: 1) If I change numTasks value in Renderer := Parallel.ParallelTask.NumTasks(numTasks).NoWait line to Environment.Process.Affinity.Count - 1, the application starts to work incorrectly. The code after Renderer.WaitFor(INFINITE); line is never executed and my app remains hanging in task Manager after closing. Is this my bug or OTL bug? 2) If I uncomment workItem.Result.OwnsObject := True; line in Asy_Factory procedure and comment out workItem.Result.AsObject.Free; line in HandleRequestDone procedure, I obtain the following AV: "Access violation at address 00604CBF in module 'ImageFactory_BackgroundWorker.exe'. Read of address 00000000." Why? After all, TOmniValue is the owner of TObject-type data! When a object-owning TOmniValue goes out of scope, the owned object is automatically destroyed. But this is not so in my case, so I would like to know why it happens. Is this OTL bug? Dear @Primož Gabrijelčič, please could you answer these questions? Also, your opinion on my ImageFactory code is very important to me! Especially the asynchronous part of the code. Maybe is there a better/easier/rather way to do this? test_ImageFactory_BackgroundWorker.zip
  3. Shrinavat

    Rio IDE Menu Font Size

    Need to hook @Brandingapi@GetThemeFont$qqrv from designide260.bpl:
  4. Hello, Is it posible add "spoiler" button in editor toolbar? Of course I can use [ spoiler ][/ spoiler ] tags but without code formatting: Spoiler test It would be nice to be able to hide large chunks of code. Thanks.
  5. @Sherlock You are absolutely right.
  6. So, I decided to abandon the idea of parallel building a large image from tiles. I coded a small test application for testing my "image factory". Project full source is in attachment, here is the main unit part: Screenshots: I'm not sure I did it right. And now I have a bunch of questions, mostly trivial. If you can answer any, please do. 1) Why does stage II start before the creation of ImageFactory pipeline? (see log) 2) Why can't I restart any task? I get "Adding to complete collection" error. 3) How to terminate the pipeline correctly? Sometimes my app remains hanging in task Manager after closing. 4) Are LargeBitmaps created in parallel when there are several (for task #2/#3)? Despite the increase in FPipelineImageFactory.NumTasks for task #2/#3, the number of threads has not changed in the debugger. Also it is noticeable in the log - the line "stage I" appears sequentially. 5) Getting the result - Image32.Bitmap.Assign(FResultBitmap) in OnStopInvoke method - is that right way? If not, how do I get this correctly? 6) Is the overlay order always preserved? That is, for task #3 the overlay_2 over overlay_1 which on base image? with this code: with FPipelineImageFactory.Input do begin Add(TOmniValue.FromRecord<TTaskRec>(Rec1)); Add(TOmniValue.FromRecord<TTaskRec>(Rec2)); Add(TOmniValue.FromRecord<TTaskRec>(Rec3)); CompleteAdding; end; Thanks in advance! test_ImageFactory.zip
  7. Thank you for the helpful tips! I will experiment more with these techniques.
  8. Dear Primož, please could you give me some advice on how to implement my "image factory"? With a variable number of parallel tasks and constantly working in the background. Everything is as I described above. Please!!!
  9. Ok, I get it. That answers my original question, but now I'm curious about my next question. How to implement some kind of "image factory", which is constantly running in the background? It must have a variable number of parallel subtasks to create each image. In my opinion, the "pipeline" abstraction is not suitable for this, since it is a sequential conveyor.
  10. Why should I use a pipeline? And what about ForkJoin abstraction? Here is a quote from the "Parallel Programming with OmniThreadLibrary" book: Isn't that for my case (to create multiple different LargeImages in parallel and then merge them into one resulting image)?
  11. After more thinking I agree with you. I will do without multithreading when creating a single LargeImage. But I have another question. Put my previous code in the BuildLargeBitmap function: function BuildLargeBitmap(some parameters): TBitmap32; begin // creating a large image from tiles end; I need to create multiple different LargeImages in parallel and then merge them into one resulting image. Schematically, as in the attached image. The number of LargeImages is not constant (!) and can be from 1 to 5. Each LargeImage is created from unrelated databases (there are no problems with competing DB connections). If the number of LargeImage is 1, then ResultImage = LargeImage1. Moreover, this operation of building LargeImages and merging them is repeated many times during the application life cycle. That is, I need to have a some "image factory" that is constantly running in the background. I do not understand how to do this using OmniThreadLibrary abstractions. I would be very grateful if someone could help me create a sketch of the code for this task!
  12. Hi, How to correctly check if the parent menu item has at least one child item with Checked = True? Is it good way? function HasCheckedSubItems(AMenuItem: TMenuItem): Boolean; var i: integer; begin Result := False; for i := 0 to AMenuItem.Count - 1 do if AMenuItem.Items[i].Checked then Exit(True); end I'd appreciate any help you can give me. Thank you.
×