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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1bb0c0c18c89737 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-15 18:51:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!HSNX.atgi.net!sjc-peer.news.verio.net!news.verio.net!iad-read.news.verio.net.POSTED!not-for-mail From: Dr Nancy's Sweetie Subject: Re: On-Screen Elapsed Time Display? Newsgroups: comp.lang.ada References: <7NGq9.19522$T_.457776@iad-read.news.verio.net> Organization: Rowan College of New Jersey User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (SunOS/5.8 (sun4u)) Message-ID: Date: Wed, 16 Oct 2002 01:45:08 GMT NNTP-Posting-Host: 150.250.64.69 X-Complaints-To: abuse@verio.net X-Trace: iad-read.news.verio.net 1034732708 150.250.64.69 (Wed, 16 Oct 2002 01:45:08 GMT) NNTP-Posting-Date: Wed, 16 Oct 2002 01:45:08 GMT Xref: archiver1.google.com comp.lang.ada:29825 Date: 2002-10-16T01:45:08+00:00 List-Id: [ Hmm, well, it seems to have posted the same article twice. Here's the right one, I hope. ] tmoran@acm.org wrote: : Look into using a "protected type" instead of semaphores. It may : be more efficient and it's certainly safer. For instance, consider : what would happen in your program if Set_Time_Window(Time_String); : raised, but didn't handle, an exception. Oooh, hadn't thought of that. I'm essentially an Ada newbie. As with anyone learning a new language, I still speak with an accent. 8-) I'm still waiting for the day when I accidentally type in the Spaceship Operator for an Ada program. : Area.Time is a variable accessed by two different tasks. Could that : cause any problems, say if one task updated Area.Time in the middle of : the other task's usage of it? Possibly access to Area.Time also needs : to be controlled via a protected type. This one I've thought of; Area.Time gets initialized to zero, incremented only by the timer, and then read outside the timer only after the game is over (and the timer is stopped). But the program is still a work in progress (you can see the "Debug.Print" calls in the hunk I came up with). : You said Set_Time_Window updates the screen with the new time. : What then does Update_Screen do? Update_Screen is from the Ada binding for ncurses; it is what actually makes the physical screen look like the screen in memory. Set_Time_Window sets the logical window with how it should look, and then the call to Update_Screen makes ncurses actually update what the user can see. : It's a good idea to have the "single file" sections as short as : possible. Every place your program writes to the screen will have to : be surrounded by semaphores (or use the protected type). It's simpler, : and less prone to error, if the synchronization is done inside the : write-to-screen routines, rather than by each of their callers. I had sort of started to discover this myself. 8-) Thanks, Darren Darren Provine ! kilroy@elvis.rowan.edu ! http://www.rowan.edu/~kilroy "It is wonderful to be here in the great state of Chicago." -- Dan Quayle