On Thu, Jun 29, 2023 at 12:46 PM Tiaan Wessels <tiaanwess...@gmail.com>
wrote:

> Hi,
> The examples for multi-threading focuses on stdc++ threads. I am trying
> instead on integrating qpid proton into a broker application which is based
> on POSIX threads. I am struggling with this e.g. callbacks not called when
> i expect the to be etc. and i am wondering whether this is not due some
> fundamental clash with POSIX threads. Are there any reason why qpid proton
> cannot be integrated into such an environment ?
>

There shouldn't be. C++11 library that you are using is most likely using
pthreads itself.


> I might add that the broker blocks all unix signals on startup and then
> starts a thread dedicated to signal handling. I presume qpid proton does
> not care how signal handling is done ?
>

True, there is no signal handling in Proton whatsoever.


> The container.run is performed from a POSIX thread created for the
> container.
> The main interaction constraint i have is that messages to send appears in
> a POSIX thread within the broker framework and i am transferring this
> message to qpid proton's thread by means of a work queue.
>

Are you using the proton work_queue to communicate between threads?
https://github.com/apache/qpid-proton/blob/f1b9ee0fc69d0836053f1f2c03a72861f787990a/cpp/include/proton/work_queue.hpp#L311-L326
You can only call proton functions from within an event handler, with
carefully specified exceptions. Search the headers for `**Thread safety**`
and `thread safe`.

You could possibly try to compile and run your app with thread sanitizer
(in gcc or clang it is -fsanitize=tsan, for both compilation and linking).
If your only tsan violations are (possibly) in your use of proton, then
this might highlight something, maybe.
-- 
Mit freundlichen Grüßen / Kind regards
Jiri Daněk

Reply via email to