Jump to content

Primož Gabrijelčič

Members
  • Content Count

    173
  • Joined

  • Last visited

  • Days Won

    8

Primož Gabrijelčič last won the day on April 30 2019

Primož Gabrijelčič had the most liked content!

Community Reputation

160 Excellent

5 Followers

Technical Information

  • Delphi-Version
    Delphi 10.2 Tokyo

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Primož Gabrijelčič

    Best approach to Multi-file, multi-thread debug logging

    I'm usually doing such logging in a manner similar to the one Kas Ob. presented. I establish a logging queue. Usually a TOmniQueue as it does not require locking. Then I create a logging thread. In essence it does just: while logQueue.Get(msg) do Log(ms); Each part of the program that wants to log, just creates a `msg` record containing whatever info you need to perform the logging (message, severity, timestamp, target file ...) and pushes it into the logging queue. That's it.
  2. Primož Gabrijelčič

    Any Good tutorial on Parallel Programming Library?

    My book Hands-On Design Patterns with Delphi covers a Pipeline pattern which I fully implemented in PPL. It may give you some ideas on how to approach your problem. The source code is freely available on GitHub.
  3. Primož Gabrijelčič

    Canceling a scheduled task

    Sorry, I did not mean to imply that. You can definitely use TaskConfig.CancelWith and then check task.CancellationToken in your thread.
  4. Primož Gabrijelčič

    Canceling a scheduled task

    As you have correctly established, stopping a thread is cooperative. Thread owner can only nicely ask the worker thread to please stop, but if the worker thread keeps working, the owner can do nothing about that (short of calling TerminateThread, but that is really a bad idea). Passing cancellation token to the worker is a good approach. You can just capture `FCancel` in your code: .Execute( procedure begin OnStatsRefresh(TGITSVCMiddleWareRuntimeInfo.RunningStatistics(FCancel), FCancel); end); I don't which of your methods is slow - `RunningStatistics` or `OnStatsRefresh` so I passed `FCancel` to both.
  5. Primož Gabrijelčič

    r3040 build error

    Beautiful, thank you!
  6. Primož Gabrijelčič

    r3040 build error

    Can you put built packages somewhere where we can download them, pretty please?
  7. Primož Gabrijelčič

    x64 version

    OTL should work perfectly fine with the 64-bit Windows compiler. What error are you getting and which Delphi version are you using?
  8. Primož Gabrijelčič

    FastMM not required?

    FastMM is not required for OmniThreadLibrary. You can use any memory manager. Mandelbrot generates the image on double-click. It does behave strangely, though, I agree. I'll look into that.
  9. Primož Gabrijelčič

    Problem install OmniThreadLibrary-3.07.7 with Delphi tokyo 10.2

    You are compiling 32-bit version but your settings (path) point to 64-bit dcu. Maybe you can just try to rebuild instead of recompile?
  10. Primož Gabrijelčič

    Unknown thread inside IOmniTask

    It depends on how lBroadcaster's OnReceive callback is implemented. If that event is called in the context of the "inside thread", then yes - this locking is necessary and it is correctly implemented.
  11. Primož Gabrijelčič

    OmniThreadPool race conditions

    Yes. The answer does not depend on the rest of the statement 😞 Thread pool does not get destroyed unless you destroy it in the code. A thread from a thread pool does not get destroyed while it is running your code. You can process thread pool events to be informed when a thread will be destroyed: http://www.omnithreadlibrary.com/book/chap07.html#lowlevel-threadpool-monitoring
  12. Primož Gabrijelčič

    Changes in Parallel Library

    "This also appears to affect OmiThreadLibrary" without any accompanying code does not mean anything. It was probably a moon phase, or Mercury in retrograde, not OTL.
  13. Primož Gabrijelčič

    Passing parameter to ThreadDataFactory

    OK, now for reals 🙂 (Sorry for the wrong answer before. You did not provide a test project so I did not open my Delphi at all and just guessed at the answer.) As the SetThreadDataFactory doesn't yet support anonymous method factory, your best bet is to use a singleton to store parameters and provide a factory. Just a sketch of a solution: type TThreadFactory = class public class var Handle: THandle; class function Make: IInterface; end; FConnectionPool := CreateThreadPool('Connection pool'); TThreadFactory.Handle := aHandle; FConnectionPool.SetThreadDataFactory(TThreadFactory.Make);
  14. Primož Gabrijelčič

    Passing parameter to ThreadDataFactory

    Yeah, as it turned out, SetThreadDataFactory doesn't yet support an anonymous method factory. Have to fix that ... 😞 I'll write a better answer soon (today).
  15. Primož Gabrijelčič

    SetThreadDataFactory

    Ah, SetThreadDataFactory actually doesn't support taking an anonymous function as an argument. An oversight that I should fix in a future. So - pass a normal function or method name to SetThreadDataFactory, not an anonymous method. (And I will amend my answer to your previous question on that topic.)
×