Re: [Boost-users] threads in a DLL with callbacks
Hi, can I make another plea for any answers to my question (below). It may
be that the answer is so obviously 'of course it does' that I didn't get a
response.
I did think about posting to the threads.devel list, but it didn't look like
the right place...
Nik
----- Original Message -----
From: "Nicholas Cain"
Hi,
I've created a component that's distributed as a DLL. The user loads the DLL, calls various methods on it and gets some data back asyncronously via callbacks.
Within the component there are several threads (using boost threads of course) any of which might call the callbacks. In all our sample code demonstrating how to create callbacks and call the methods we use boost mutexes to protect the callback functions and this works just fine.
Some of our clients however don't want to dip their toes into boost, and want to use windows methods to protect the callbacks. For instance so far they've tried various methods such as CComAutoCriticalSection and EnterCriticalSection.
They still have a crash which they're attributing to my DLL. I keep pushing them to at least try the boost mutex as in our sample code, but no luck so far.
My question is; should the windows critical section protect the callbacks just as well as the boost mutexes, or does it require a boost mutex protection? (or do you require a code example to know the answer to this?)
Nik
"Nicholas Cain"
Hi, can I make another plea for any answers to my question (below). It may be that the answer is so obviously 'of course it does' that I didn't get a response.
Sorry for the late reply.
My question is; should the windows critical section protect the callbacks just as well as the boost mutexes, or does it require a boost mutex protection? (or do you require a code example to know the answer to this?)
Yes. CRITICAL_SECTION should provide exactly the same level of protection as Boost::mutex. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
What do you use as callback? Anthony Williams schrieb:
"Nicholas Cain"
writes: Hi, can I make another plea for any answers to my question (below). It may be that the answer is so obviously 'of course it does' that I didn't get a response.
Sorry for the late reply.
My question is; should the windows critical section protect the callbacks just as well as the boost mutexes, or does it require a boost mutex protection? (or do you require a code example to know the answer to this?)
Yes. CRITICAL_SECTION should provide exactly the same level of protection as Boost::mutex.
Anthony
Just a function pointer passed to the DLL
----- Original Message -----
From: "Hansi"
What do you use as callback?
Anthony Williams schrieb:
"Nicholas Cain"
writes: Hi, can I make another plea for any answers to my question (below). It may be that the answer is so obviously 'of course it does' that I didn't get a response.
Sorry for the late reply.
My question is; should the windows critical section protect the callbacks just as well as the boost mutexes, or does it require a boost mutex protection? (or do you require a code example to know the answer to this?)
Yes. CRITICAL_SECTION should provide exactly the same level of protection as Boost::mutex.
Anthony
participants (3)
-
Anthony Williams
-
Hansi
-
Nicholas Cain