Open SwissFrank opened 2 years ago
Looking at thread_mosq.c, I see it is written exclusively with pthread's. Any particular reason C++11 threads aren't supported? Simply no demand, not a priority?
I'm getting the feeling that:
1) the Win64 distribution is not compiled with WITH_THREADING, and therefore
2) if a user does run the top loop in a separate thread, it will probably "appear" to "work" for a few messages and under light load, but then almost sure to blow up as nothing is locked anywhere. Would you agree?
Would you accept a donation of C++11 threads if someone were to contribute them? (Not offering--yet, just an idea.)
Hi Frank,
Windows thread support is back for the 2.1 release, I don't intend to change anything for 2.0 in that regard. C++11 threads aren't available in C, so that's why they wouldn't be used.
The Windows readme mentions that the threaded functions aren't available in Windows. Unfortunately wrapping mosquitto_loop_forever()
in a thread won't work, because the internal locking isn't carried out when compiled without thread support.
Cheers,
Roger
Hi Roger,
Many thanks for the comprehensive reply. My short-term workaround is simply to call mosquitto_loop(mosq,0,1) in a timer event 100x/sec. It doesn't sound ideal but in fact it probably takes <0.1%CPU.
I still maintain a 150,000 line C library written mostly in like 1996 and know the inertia of such projects. C++ APIs are naturally challenging to use in such code. But have you considered having the library itself written in portable C++11, which today seems omnipresently available, and simply making sure the entry points have C bindings? (I'm not talking of rewriting it to be OO, rather, just keeping the code 99% as is and replacing or supplementing the pthread and Windows thread implementations with std::thread calls.) Or are there platforms (embedded systems??) where C++11 simply isn't supported?
Cheers, Frank
On Fri, Jul 22, 2022 at 7:41 AM Roger Light @.***> wrote:
Hi Frank,
Windows thread support is back for the 2.1 release, I don't intend to change anything for 2.0 in that regard. C++11 threads aren't available in C, so that's why they wouldn't be used.
The Windows readme mentions that the threaded functions aren't available in Windows. Unfortunately wrapping mosquitto_loop_forever() in a thread won't work, because the internal locking isn't carried out when compiled without thread support.
Cheers,
Roger
— Reply to this email directly, view it on GitHub https://github.com/eclipse/mosquitto/issues/2591#issuecomment-1192002230, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQXYJTXWNVAEPHH3LEJ5ETVVHGZ7ANCNFSM53433ZUQ . You are receiving this because you authored the thread.Message ID: @.***>
Hi Roger,
I am also experiencing the same issue in v2.0.14. When do you intend to release V2.1 with support for threads? or is there any older version in achieve that I can use to make mosquitto_loop_start() work in windows?
Cheers, Shrilesh
bump
bump
bump
Hi everyone,
I'm using the version v.2.0.15 and I'm still having the same issues. Any help?
Regards
As I've seen in a closed issue, this function isn't supported on Windows. (BTW this limitation, and the possible return code, aren't documented on https://mosquitto.org/api/files/mosquitto-h.html .)
I've tried the following simplistic workaround and it works fine in a simple test program but dies in a more complicated situation whereby I supply a library running under a third-party piece of software.
The code is something along these lines:
void mytoploop(struct mosquitto mosq) { int iRC; if (iRC = mosquitto_loop_forever(mosq, -1, 1)) { const char psz = mosquitto_strerror(iRC); printf("mosquitto_loop_forever(): %s\n", psz); return; } }
Basically, my question are:
Many Thanks.