Re: Help with callbacks
"smallhairytroll" <[email protected]> Fri, 13 Jun 2003 06:20:43 -0000
| Newsgroups | gmane.lisp.corman |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], Roger Corman <roger@c...> wrote: > > >This is probably it then as both the timer and the thread callback > >fail (The thread callback is definitely called from a foreign > >thread). > Lisp code can only be executed by threads which are known by the > lisp system. The reason is that garbage collection can be > triggered at any time, by any thread. If this happens, only > threads known to the garbage collector get scanned. If any lisp > code is running on a thread not known to the collector, it will > not be properly updated, which is usually fatal to that thread. > If you have a native DLL (compiled in C or C++, for example) you > can put code in the DllMain function which calls BlessThread() > whenever a new thread is instantiated. :) Can you tell how happy I am ? It works!!! Thanks Roger and Chris. Calling BlessThread() within DLL_THREAD_ATTACH did the trick. HMODULE module = LoadLibrary("CormanLispServer.dll"); char* funcName; FuncPtr func; switch (ul_reason_for_call) { ... case DLL_THREAD_ATTACH: funcName = "BlessThread"; func = (FuncPtr)GetProcAddress(module, funcName); func(); break; case DLL_THREAD_DETACH: funcName = "UnblessThread"; func = (FuncPtr)GetProcAddress(module, funcName); func(); break; ...} Thanks again for all your help/time guys :) (I sure hope someone else uses this library in addition to me.) -Luke ------------------------ Yahoo! Groups Sponsor ---------------------~--> Looking for the latest Free IT White Papers? Visit SearchSecurity.com to access over 500 white papers. Get instant access at SearchSecurity.com Today http://us.click.yahoo.com/.lAzoD/QLNGAA/witMAA/SyjtlB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/