Hi Alex,
My last post went missing.. Thanks for the help! Here is a summary of what i am trying to do..
I am trying to create a golang interface to a legacy multi-threaded dll which communicates via a callback mechanism for a client. I load the dll register a callback with it. the DLL controller then spawns of "child" threads each of which carry out intensive computation (ffts and the like) and then call the registered callback via the pointer.
Now I used the syscall.Newcallback to register a go function as callback .. This works as long as it is not called from the "child" threads. So this is a limitation in syscall. As i was debugging the code in runtime i realized that runtime.cgocallback_gofunc was hanging on needm -> lockextra() .. This was because there was no extra "m" available as it assumed. To fix this i had to import "cgo" which fixed that issue.
But now i am stuck at :
// Switch stack and make the call.
MOVQ DI, SP
CALL runtime·cgocallbackg(SB)
Will debug this further.. But the bottom line is that syscall.Newcallback doesnt work if called from threads (those created with _beginthread.)..
Perhaps a better solution would be to fix the dll to communicate using a message queue (zeromq) or have a blocking function which go can call to signal events (like some examples have done before).. but am loathe to leave the confines of emacs/liteIde for Visual studio :) But anyway the syscall documentation could have this disclaimer on the limitation of using the callbacks.
P.S: the callback uses __stdcall so that is not an issue..
/Sven