Hallo List,
I’m currently trying to build a cross platform C++ Ruby Extension
module.
All works with Linux, but when trying to build under MINGW32 for Windows
I have the problem that I cannot join a std::thread that was created in
my extension module earlier.
The extension module code is fairly simple (stripped down to show the
problem isolated):
class SayHello
{
public:
void operator()() const {
std::cout<< “hello” << std::endl;
}
};
VALUE method_test1(VALUE self) {
std::thread t((SayHello()));
t.join();
return rb_str_new2(“success”);
}
void Init_test() {
mTest = rb_define_class(“Test”, rb_cObject);
rb_define_method(mTest, “test1”, (VALUE (*)(…)) method_test1, 0);
}
Environment is: Windows 7, 32bit, Ruby 1.9.3-p545 (download from
rubyinstaller.org), MingW i686-4.8.3-release-posix-sjlj-rt_v3-rev0
(download from MingW-w64 project), MSYS2
The thread starts up and finishes, but the join is blocking
indefinitely.
Please let me know what further information you might need to maybe help
me nailing down the problem.
Is there some interaction with the thread magic that ruby itself does in
thread_win32.c? Are there any symbols / functions exported from the ruby
dll or interpreter that might interfere with my usage in the extension
module?
My thread here is completely independant and doesn’t need any
interaction
with ruby itself.
Thanks
Tino