You're looking at it [the problem] wrong. Think of all threads being separate programs entirely with all globals being *really* global (throughout the machine). Now, in order to "execute" something in another thread, you must have the other thread look for something to do. That is, each thread is in control of it's own destiny. You can't make thread 1 call a subroutine from thread 2 -- but you can set a flag in thread 2 and have thread 1 periodically look at this flag and, if it's set, call a subroutine. If you want to get really fancy, you could implement a deque protected by a mutex and thread 2 could do push_back while thread 1 is doing !empty, front, pop_front (each protected by the mutex of course).
Ciao, Dee -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Roel Vanhout Sent: Thursday, January 29, 2004 8:08 AM To: [EMAIL PROTECTED] Subject: Re: [msvc] basic threading question Hello Paul, Paul Grenyer wrote: > Were you able to use boost, time locked condition variables would allow > you to do this. Well since boost does wrap around pthreads/win32 threads I would expect that, if I would understand the mechanism better, I could write a similar functionality in C. I have tried to understand how to do this with the boost ScopedTimedLock concept (that is what you mean, right?) but I don't quite see how I could call a function in another thread with it. As far as I understand it, it's only a Mutex, that is, it grants exclusive access to a variable to a thread. Could you elaborate on how you would do this with boost like you say? Pardon my ignorance, I think I just don't 'get' the mechanism involved. cheers, roel > Regards > Paul > > Paul Grenyer > Email: [EMAIL PROTECTED] > Web: http://www.paulgrenyer.co.uk > > Have you met Aeryn: http://www.paulgrenyer.co.uk/aeryn/? > Version 0.3.0 beta now available for download. > > > > _______________________________________________ > msvc mailing list > [EMAIL PROTECTED] > See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive. _______________________________________________ msvc mailing list [EMAIL PROTECTED] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
