Hi -
On Jan 22, 2008, at 3:32 PM, Richard wrote:
>
> Tried this, for some reason the C++ compiler does notlike declaring
> this variable as a static variable. Someone told me to try this:
>
> pthread_create (&WatchdogMonitorId, NULL, &(this->resetWatchdog),
> NULL);
> >From what i undestand about the nature of the error the compiler may
> be having problems becasue the class might not be thread safe. I am
> not sure why this is an issue i have a flag to manage the thread.
> This is a lot different then treads in borland :( the down side to
> having borland do all the dirty work for you is that when you have to
> do it you dont know how to lol.
>
I would suggest using a platform independent middleware for handling
nasty complexity such as this. There is one in particular that I am
using (under a couple other layers of middleware that I am working on)
called ACE (http://www.cs.wustl.edu/~schmidt/ACE.html) which makes
encapsulating a thread in a class as simple as this:
class WatchDog : public ACE_Task_Base
{
public:
int svc (void)
{
// business logic goes here
}
// other public methods
private:
// any state information that you may need
// but all details of threading are hidden in the middleware
};
and then in your application code:
WatchDog Fido;
Fido.activate ();
In the interest of full disclosure, I should say that I am part of the
research group that maintains ACE.
hth,
/-Will
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|