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,8fa8eec8401ec58 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 10 Jun 2008 19:35:38 -0500 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Post hoc making a type thread safe References: <6b7vr9F3b6cjlU1@mid.individual.net> X-Newsreader: Tom's custom newsreader Message-ID: <4YOdnT-22cpGgNLVnZ2dnUVZ_hzinZ2d@comcast.com> Date: Tue, 10 Jun 2008 19:35:39 -0500 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 71.202.183.17 X-Trace: sv3-vnRyPLNPuB8+uvo5D2xoR1TIGEAoikOWED4KPX5wS1c1zYAKbTyEjq7Y6zMLQ7lmZ8T12RwrsIS61Z6!KgnKvNaaKKvdKGiKIuWh7aR970Pu8MlMwCg8LA0bGWVZU8jpohFityah58m+JHb+ngrS3UJZoBqH!UJ9DQXcVkUS0bUcv2yDxiPzAVW9iBw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Xref: g2news1.google.com comp.lang.ada:640 Date: 2008-06-10T19:35:39-05:00 List-Id: This isn't exactly what you appear to be asking for, but perhaps it would do what you need. In Claw.Sockets, it's desirable to avoid one thread trying to do something with a socket while another thread is in the middle of some activity with that socket. Our solution was a Controlled type whose declaration at the beginning of a procedure would raise an exception if the socket is already busy having something done to it by another task, or would set a Busy flag if the socket is not busy. On leaving the routine the Finalize will clear the Busy state. Once the mechanism is set up, this just requires a single line declaration Check_Busy : Check_Busy_Type(Socket'unchecked_access); to be included at the beginning of each routine to be interlocked.