Hi, > OK, good. When I call CreateThread, one of the parameters I need to pass it > is a function pointer to the code which will run in the new thread. My > question is: can I pass a Factor quotation or a word as the function pointer? > Or is there some wrapper to make it possible, like with-new-vm or something? >
Yes. See https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks for an example on how to pass callbacks to c functions. So if CreateThread has signature: FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPVOID lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ) You need to declare a callback: CALLBACK: DWORD ThreadProc ( LPVOID lpParameter ) Then a callback maker: : <ThreadProc> ( -- alien ) [ ] comparer ; <-replace [ ] with your code Then call it: f 1024 <ThreadProc> f 0 1234 CreateThread -- mvh/best regards Björn Lindqvist ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
