Jump to content

Primož Gabrijelčič

Members
  • Content Count

    247
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Primož Gabrijelčič


  1. Short answer: Use Parallel.For.

     

    Long answer: Parallel.ForEach was written not for parallel processing of integers but for parallel processing of any weird kind of data. Because of that it is overly complex and not good for simple (for i in range) cases. It is usually about 10x slower than PPL's TParallel.For. That is why I later wrote Parallel.For, which works only on integer ranges and is on par with the PPL implementation.

    • Thanks 3

  2. Yes, it fails because the owner (anonymous thread) is destroyed before the worker (Parallel.Async). You could also run into problems because the owner thread is not processing Windows messages, which is a requirement for threads that own OTL tasks. Not in this simple example, but as soon as you start sending messages towards the owner or using OnTerminate handlers you would run into trouble.


  3. This should work just fine, I wrote a very similar code today and there were no problems:

      FWorker :=
        Parallel.BackgroundWorker.NumTasks(1)
        .Execute(
          procedure (const workItem: IOmniWorkItem)
          var
            result: TTextBoxDetectorResults;
          begin
            var data := workItem.Data.ToRecord<TTextBoxDetectorData>;
            result := FAnalyzer_Asy.Analyze(data);
            workItem.Result := TOmniValue.FromRecord<TTextBoxDetectorResults>(result);
          end)
        .OnRequestDone_Asy(
           procedure (const Sender: IOmniBackgroundWorker; const workItem: IOmniWorkItem)
           begin
             var results := workItem.Result.ToRecord<TTextBoxDetectorResults>;
             OnAnalyzed_Asy(Self, workItem.UniqueID, results);
           end)

    You will have to put together a reproducible test case.


  4. 13 hours ago, Bill Meyer said:

    Second, that Amazon freely adjusts the sell price, when and as they wish.

    The same goes for Packt. They sell books for $5 (action!) without asking. They even created a monstrosity which combines both my books together and they are selling it separately (again, without asking). But they did manage to make me more money than my self-published OmniThreadLibrary book, even though their commision is much higher than LeanPubs. So they do sell many books.

    • Like 1

  5. On 2/16/2023 at 10:53 AM, TheOnlyOne said:

    I have a question about your experience with PacktPub - how was it?

    Mixed. They do their job, but you can definitely tell that it is an Indian team behind. Everything is "yes, of course" and then maybe something happens. Or maybe not. Plus they are very set in some formulaic ways - if you want to write a book, it has to fall into some already defined slot for which they know how they want organize it and then they insist on their way (how the content should be structured, what is allowed and what not etc). That is helpful, but also limiting and frustrating.

     

    Most of the time it works the best if you also say "yes, of course" and then do it in your own way. 🙂

     

    Technical staff and editors are mediocre, at best. They definitely will not catch all errors.

     

    So - if you are looking for a perfect partner, they are not the one. If, however, you can just say "eh, whatever" from time to time and move on, they work just fine. They do pay on time, though. 

     

    As for the other publishing houses, I have no idea.

    • Like 4
    • Haha 2
×