Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 05, 2005 threads | ||||
---|---|---|---|---|
| ||||
Can someone point me in the right direction please? I have a class with several methods. one of those methods should be called as a with new thread and do something untill the class is destroyed. here is a test class that i experiment with: class serverinit { private: Socket listener; ushort port; Thread listenerthread; int (*fp)(void *); initdata data; public: Socket listenerdata() { return listener; } // read property Socket listenerdata(Socket value) { return listener = value; } // write property ushort portdata() { return port; } // read property ushort portdata(ushort value) { return port = value; } // write property Thread listenerthreaddata() { return listenerthread; } // read property Thread listenerthreaddata(Thread value) { return listenerthread = value; } // write property static int serverinitializer(void *dataorg) { Socket reciever; initdata *data = cast(initdata *)dataorg; for(;;) { try { reciever = data.listener.accept(); assert(reciever.isAlive); Thread newthread = new Thread(data.fp, reciever); newthread.start(); } catch { if(reciever) reciever.close(); } } return 0; } this(int (*fp)(void *),ushort onport) { assert(fp != null); this.fp = fp; port = onport; data.fp = fp; listener = new TcpSocket; assert(listener.isAlive); data.listener = listener; listener.blocking = false; listener.bind(new InternetAddress(port)); listener.listen(10); listenerthread = new Thread(&serverinitializer, &data); // XXXXX assert(listenerthread != null); } ~this() { listener.close(); listenerthread.pause(); delete listenerthread; } } with a debugger, i can see that the line XXXXX is executed, but the function will not listen. when i don't use the data-initdata construct, i can not compile, since this is not allowed in a static method. richard |
July 05, 2005 Re: threads | ||||
---|---|---|---|---|
| ||||
Posted in reply to rko | when is listenerthread.start() called? I didn't see anything glancing through the code. "rko" <rko_member@pathlink.com> wrote in message news:dade2h$2m9u$1@digitaldaemon.com... > Can someone point me in the right direction please? > I have a class with several methods. one of those methods should be called > as a > with new thread and do something untill the class is destroyed. > here is a test class that i experiment with: |
July 05, 2005 Re: threads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | In article <daec9m$ddq$1@digitaldaemon.com>, Ben Hinkle says... > >when is listenerthread.start() called? I didn't see anything glancing through the code. > >"rko" <rko_member@pathlink.com> wrote in message news:dade2h$2m9u$1@digitaldaemon.com... >> Can someone point me in the right direction please? >> I have a class with several methods. one of those methods should be called >> as a >> with new thread and do something untill the class is destroyed. >> here is a test class that i experiment with: > > thanx that you even answered. when i came home i saw that too. shame is dripping from me. richard |
July 05, 2005 [OT] Re: threads | ||||
---|---|---|---|---|
| ||||
Posted in reply to rko | "rko" <rko_member@pathlink.com> wrote in message news:daehai$hqb$1@digitaldaemon.com... > shame is dripping > from me. That's one of the more .. original expressions I've heard ;) |
July 06, 2005 Re: [OT] Re: threads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | In article <daf6na$13c5$1@digitaldaemon.com>, Jarrett Billingsley says... > >"rko" <rko_member@pathlink.com> wrote in message news:daehai$hqb$1@digitaldaemon.com... >> shame is dripping >> from me. > >That's one of the more .. original expressions I've heard ;) > > I'll say. Perhaps he meant to say "I'm all wet." - EricAnderton at yahoo |
Copyright © 1999-2021 by the D Language Foundation