ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Trying to encapsulate thread in class

To:
Subject: Re: [ts-7000] Re: Trying to encapsulate thread in class
From: "William R. Otte" <>
Date: Tue, 22 Jan 2008 16:06:08 -0600
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/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU