[AGENT++] runnable thread

Frank Fock fock at snmp4j.org
Thu Sep 8 19:29:55 CEST 2005


Hello Ram,

What is the exact problem you encounter? The code looks OK.

Best regards,
Frank

Ram Rathan wrote:

>Hello all,  Please help me understand on how to start a simple custom function (read()) as a thread. Here is what I have understood so far from examples and documentation. But I have not managed to get it going. HELP ! any example will help ... Thanks.
>
>-------------------------------------------------
>class readweb: MibTable {
> public:
>	readweb();
>	virtual ~readweb();
>	static readweb* instance;
> protected:
>	ThreadPool*    threadPool;
>};
>
>class CmdThread: public Runnable {
> public:
>	CmdThread() { }
>	virtual ~CmdThread() { }
>	virtual void run();
>};
>
>void CmdThread::run()
>{
>        readweb::instance->start_synch();
>	read();
>	readweb::instance->end_synch();
>}
>
>virtual int read(param)
>{
> try {
>......... my function here
>}
> return;
>}
>
>virtual void update(Request* req) {
>....
>	#ifdef _THREADS
>		CmdThread* ct = new CmdThread();
>		((readweb*))->threadPool->execute(ct);
>	#endif
>...
>}
>
>main()
>{
>......
>}
>
>readweb* readweb::instance = 0;
>readweb::readweb():MibTable("1.3.6.1.4.1.4976.6", 1, FALSE)
>{
>	instance = this;
>	threadPool = new ThreadPool(2);
>}
>
>readweb::~readweb()
>{
>	delete threadPool;
>}
>_________________________________________
>_______________________________________________
>AGENTPP mailing list
>AGENTPP at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/agentpp
>
>
>  
>





More information about the AGENTPP mailing list