From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!blackbush.cw.net!cw.net!feed.news.tiscali.de!news.belwue.de!news.tu-darmstadt.de!tsicnews.teliasonera.com!news.otenet.gr!news.grnet.gr!newsfd02.forthnet.gr!not-for-mail From: Ioannis Vranos Newsgroups: comp.lang.ada Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Fri, 25 Mar 2005 05:27:09 +0200 Organization: FORTHnet S.A., Atthidon 4, GR-17671 Kalithea, Greece, Tel: +30 2109559000, Fax: +30 2109559333, url: http://www.forthnet.gr Message-ID: <1111721237.600158@athnrd02> References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1111607633.301232.62490@z14g2000cwz.googlegroups.com> <4241e04c$0$11471$9b4e6d93@newsread2.arcor-online.net> <1111614619.83944@athnrd02> <3895971.bl8ACDBTNI@linux1.krischik.com> NNTP-Posting-Host: athnrd02.forthnet.gr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: athprx02.forthnet.gr 1111721237 18055 193.92.150.73 (25 Mar 2005 03:27:17 GMT) X-Complaints-To: abuse@forthnet.gr NNTP-Posting-Date: Fri, 25 Mar 2005 03:27:17 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en In-Reply-To: <3895971.bl8ACDBTNI@linux1.krischik.com> Cache-Post-Path: newsfd02!unknown@ppp16-adsl-51.ath.forthnet.gr Xref: g2news1.google.com comp.lang.ada:9957 Date: 2005-03-25T05:27:09+02:00 List-Id: --->> At first, in this and other messages you had set the follow-ups to --->> comp.lang.ada which means we can not follow the discussion --->> anymore!] Martin Krischik wrote: > Yes, and process/system boundaries when Annex E is implemented. > > Martin ISO C++ defines no threading facilities so far (but *care has been taken* to be easy implementing the algorithms and container operations as thread-safe). The only multithreading I know is the .NET lock-based multithreading. I can't understand how in such an environment you can expect to catch exceptions reliably. I can only assume that Ada's built in multithreading mechanism is not lock-based. Here is a .NET example: #using using namespace System; using namespace System::Threading; class SomeException {}; __gc class SomeClass { int index; //... public: // ... void DoSomething() { Monitor::Enter(this); throw SomeException(); // Modify index Monitor::Exit(this); } void DoSomethingElse() { Monitor::Enter(this); // Modify index Monitor::Exit(this); } // ... }; int main() try { SomeClass *ps= __gc new SomeClass; Thread *pthread1= __gc new Thread ( __gc new ThreadStart(ps, &SomeClass::DoSomething) ); Thread *pthread2= __gc new Thread ( __gc new ThreadStart(ps, &SomeClass::DoSomethingElse) ); //Start execution of ps->DoSomething() pthread1->Start(); //Start execution of ps->DoSomethingElse() pthread2->Start(); } catch(SomeException) { Console::WriteLine("SomeException caught in main thread!\n"); } How can you expect to catch the exception in the main thread for example, since it terminates immediately after the two calls in the try block? The proper way in .NET (this isn't production-level code BTW): #using using namespace System; using namespace System::Threading; class SomeException {}; __gc class SomeClass { int index; //... public: // ... void DoSomething() try { Monitor::Enter(this); throw SomeException(); // Modify index Monitor::Exit(this); } ==> Handle inside the specific thread locally catch(SomeException) { // ... } void DoSomethingElse() { Monitor::Enter(this); // Modify index Monitor::Exit(this); } // ... }; int main() try { SomeClass *ps= __gc new SomeClass; Thread *pthread1= __gc new Thread ( __gc new ThreadStart(ps, &SomeClass::DoSomething) ); Thread *pthread2= __gc new Thread ( __gc new ThreadStart(ps, &SomeClass::DoSomethingElse) ); //Start execution of ps->DoSomething() pthread1->Start(); //Start execution of ps->DoSomethingElse() pthread2->Start(); } catch(Exception *pe) { Console::WriteLine("{0}", pe->Message); } -- Ioannis Vranos http://www23.brinkster.com/noicys