concurrency problem with pointers
evilrat
evilrat666 at gmail.com
Thu Jul 18 08:29:23 PDT 2013
i hate asking for help, but... now i'm pushed in the corner. so
here is my problem:
i have struct with handle, and i need to send this struct or
handle to second thread, all fine but feeding this struct or
handle to send results in multiple errors(mostly complains about
thread local data). and unfortunatelly shared and __gshared
doesn't helps(complains about unknown size of handle).
well, i wish i could describe in details without code but... here
is simplified example
--------
void main() {
MyData data;
// load data
...
MyWindow wnd(data);
wnd.show();
auto tid = spawn(&newViewThread);
send(tid, wnd);
}
// struct because i want benefit from RAII, but if necessary
could switch to class
struct MyWindow {
this ( MyData data ) { ... }
// WINDOW defined as struct but has no size
WINDOW* handle;
}
// 3rd party func to get window
WINDOW* createWindow(...);
----------
shortly speaking, WINDOW is pointer to window in C library so
it's "shared", and i need it in another thread to make opengl
context current in that thread, but compiler simply doesn't allow
me to do anything with that, and i can't change definition since
it's 3rd party bindings. any suggestions?
More information about the Digitalmars-d-learn
mailing list