home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-035 < prev    next >
Text File  |  2010-09-21  |  74KB  |  2,097 lines

  1. Received-Date: Wed, 15 Jun 1994 15:34:00 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-035
  4. To: csmp-digest@ens.fr
  5. Date: Wed, 15 Jun 1994 15:33:50 +0200 (MET DST)
  6. X-Mailer: ELM [version 2.4 PL23]
  7. Mime-Version: 1.0
  8. Content-Type: text/plain; charset=ISO-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Errors-To: listman@ens.fr
  11. Reply-To: pottier@clipper.ens.fr
  12. X-Sequence: 38
  13.  
  14. C.S.M.P. Digest             Wed, 15 Jun 94       Volume 3 : Issue 35
  15.  
  16. Today's Topics:
  17.  
  18.         "Magical" conversion from (char *) to Pascal string in C++
  19.         "New" bugs in 'develop' floating window code?
  20.         Detecting Universal Headers?
  21.         Enumerating messages from PowerTalk
  22.         MicroSeconds trap # and arguments?
  23.         Ok, where's my Quickdraw globals?  (Help!)
  24.         Symantec C++ 7.0- any good?
  25.         Thread Mgr for blocking I-O
  26.  
  27.  
  28.  
  29. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  30. (pottier@clipper.ens.fr).
  31.  
  32. The digest is a collection of article threads from the internet newsgroup
  33. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  34. regularly and want an archive of the discussions.  If you don't know what a
  35. newsgroup is, you probably don't have access to it.  Ask your systems
  36. administrator(s) for details.  If you don't have access to news, you may
  37. still be able to post messages to the group by using a mail server like
  38. anon.penet.fi (mail help@anon.penet.fi for more information).
  39.  
  40. Each issue of the digest contains one or more sets of articles (called
  41. threads), with each set corresponding to a 'discussion' of a particular
  42. subject.  The articles are not edited; all articles included in this digest
  43. are in their original posted form (as received by our news server at
  44. nef.ens.fr).  Article threads are not added to the digest until the last
  45. article added to the thread is at least two weeks old (this is to ensure that
  46. the thread is dead before adding it to the digest).  Article threads that
  47. consist of only one message are generally not included in the digest.
  48.  
  49. The digest is officially distributed by two means, by email and ftp.
  50.  
  51. If you want to receive the digest by mail, send email to listserv@ens.fr
  52. with no subject and one of the following commands as body:
  53.     help                        Sends you a summary of commands
  54.     subscribe csmp-digest Your Name    Adds you to the mailing list
  55.     signoff csmp-digest            Removes you from the list
  56. Once you have subscribed, you will automatically receive each new
  57. issue as it is created.
  58.  
  59. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  60. Questions related to the ftp site should be directed to
  61. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  62. digest are available there.
  63.  
  64. Also, the digests are available to WAIS users.  To search back issues
  65. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  66. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  67.  
  68.  
  69. -------------------------------------------------------
  70.  
  71. >From oleg@ponder.csci.unt.edu (Kiselyov Oleg)
  72. Subject: "Magical" conversion from (char *) to Pascal string in C++
  73. Date: 31 May 1994 14:28:19 GMT
  74. Organization: University of North Texas, Denton
  75.  
  76. There has been some discussion recently about conversion of a C string
  77. to the Pascal string and correctly casting of the result.
  78. I thought I'd throw in my couple of cents:
  79.  
  80. First, let's define the following class
  81.  
  82. class Pstr        // Pascal String, this is just a type conversion
  83. {
  84.   Str255 pas_string;
  85. public:
  86.   Pstr(const char * c_str);
  87.  ~Pstr(void) {}
  88.   operator unsigned char const * () { return pas_string; }
  89. };
  90.  
  91.                 // Used to "implicitly" convert from C to 
  92. Pstr::Pstr(const char * c_str)    // Pascal string 
  93. {
  94.   strncpy((char *)pas_string,c_str,sizeof(*this)-2);
  95.   CtoPstr((char *)pas_string);
  96. }
  97.  
  98. After that, one can write smth like that
  99.  
  100.   char * title = "some title";    
  101.   this_window = NewWindow(nil,rect += window_offset,(Pstr)title,....etc)
  102.  
  103. It is THAT simple: just putting (Pstr) before a C string magically converts
  104. it to a Pascal string and "does" correct casting, while keeping the original
  105. C string intact.
  106.  
  107. The way I figure it, (Pstr)title should make an object of type Pstr
  108. from 'title' by applying the Pstr::Pstr(const char * c_str)
  109. constructor. Since NewWindow() requires a pascal string as its third
  110. argument, the operator 'unsigned char const *' would apply, which
  111. gives exactly what NewWindow() wants. And here how it actually works
  112. (peeked from the object code generated by the Symantec C++ compiler):
  113. the compiler allocates 256 bytes on stack, copies the C string in
  114. there, calls CtoPstr(), and then pushes the address of that temporary
  115. PASCAL string into stack for NewWindow(). After the NewWindow()
  116. returns, the temporary space allocated for the Pascal string is
  117. disposed of (by simply incrementing A7, mind you).  To me, it looks
  118. exactly as I wanted: conversion of a C string into the PASCAL one
  119. without messing up the C string.
  120.  
  121. Here is more of the same idea:
  122.  
  123. class ScreenRect : public Rect
  124. {
  125. public:
  126.   ScreenRect(const Rect& rect)     { *this = *(ScreenRect *)▭ }
  127.   ScreenRect(const rowcol& heightwidth);
  128.   ~ScreenRect(void) {}
  129.   ScreenRect& operator += (const int offset);
  130.   operator Rect * (void) { return this; }
  131.   void print(const char * title = "") const;
  132. };
  133.                 // Create a rectangle of given height/width
  134.                 // positioned at the origin
  135. ScreenRect::ScreenRect(const rowcol& heightwidth)
  136. {
  137.   left = top = 0;
  138.   bottom = heightwidth.row();
  139.   right  = heightwidth.col();
  140. }
  141.  
  142.                 // Shifting a rectangle by the same amount
  143.                 // in X and Y
  144. ScreenRect& ScreenRect::operator += (const int offset)
  145.   top += offset; bottom += offset; left += offset; right += offset;
  146.   return *this;
  147. }
  148.  
  149.  
  150. Then I can write
  151.     ScreenRect sub_horizon(q_bounds());
  152.     sub_horizon.print("sub horizon");
  153.     EraseRect(sub_horizon);
  154.  
  155. or, even crazier,
  156.  
  157. ScreenWindow::ScreenWindow(ScreenRect rect, const char * title)
  158. {
  159.     const int window_offset = 100;        // Cannot be 0 or small!
  160.     this_window = NewWindow(nil,rect += window_offset,(Pstr)title,...
  161. }
  162.  
  163. So, all QuickDraw functions AUTOMATICALLY accept ScreenRect as if it
  164. were Rect *.
  165. This way, one can build C++ classes around all QuickDraw (and other
  166. OS) data types, and one can still use original QuickDraw functions on
  167. the new "objects". I've done just that for a few OS data types, I can
  168. post it if there is some interest.
  169.  
  170. BTW, this all is perfectly legal C++ and would work everywhere. The
  171. code snippets in this post are fragments of an actual working
  172. program. It compiles with Symantec C++ versions 6.0, 6.0.1, and 7.0.
  173.  
  174.                         Oleg
  175.  
  176. P.S. I'm not a frequent reader of this newsgroup, please send any comments
  177. to oleg@ponder.csci.unt.edu or oleg@unt.edu
  178.  
  179.  
  180. +++++++++++++++++++++++++++
  181.  
  182. >From lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
  183. Date: 1 Jun 1994 13:59:08 GMT
  184. Organization: Information & Media Science, Aarhus University, DENMARK
  185.  
  186. In article <2sfhi3$312@hermes.unt.edu>, oleg@ponder.csci.unt.edu (Kiselyov
  187. Oleg) wrote:
  188.  
  189. > There has been some discussion recently about conversion of a C string
  190. > to the Pascal string and correctly casting of the result.
  191. > I thought I'd throw in my couple of cents:
  192. > First, let's define the following class
  193. > class Pstr        // Pascal String, this is just a type conversion
  194. > {
  195. >   Str255 pas_string;
  196. > public:
  197. >   Pstr(const char * c_str);
  198. >  ~Pstr(void) {}
  199. >   operator unsigned char const * () { return pas_string; }
  200. > };
  201. > After that, one can write smth like that
  202. >   char * title = "some title";    
  203. >   this_window = NewWindow(nil,rect += window_offset,(Pstr)title,....etc)
  204. > It is THAT simple: just putting (Pstr) before a C string magically converts
  205. > it to a Pascal string and "does" correct casting, while keeping the original
  206. > C string intact.
  207.  
  208. A friend and I used this approach to implement a string class that worked
  209. transparently with Pascal strings, while providing >255 character strings.
  210. Basically, the character storage had a pascal length byte in front and a C
  211. string terminating zero in the end. When casting to unsigned char*, the
  212. length byte would be set to something <255, and all operations would check
  213. for length byte <255 and drop a terminating zero at the end. This way, the
  214. string object could be passed to pascal routines expecting (VAR
  215. result:StrNNN) parameters, and the resulting pascal string (possibly not
  216. correctly 0 terminated) would be usable.
  217.  
  218. Alas this broke when we switched from Symantec C++ to MetroWerks. We
  219. haven't tried it with the latest release, though.
  220.  
  221. With Symantec C++, it worked great. No more C-String/Str255 hassles. Just
  222. always use String. Period.
  223.  
  224. If there is any interest, I could post the source.
  225.  
  226. > P.S. I'm not a frequent reader of this newsgroup, please send any comments
  227. > to oleg@ponder.csci.unt.edu or oleg@unt.edu
  228.  
  229. --
  230. Lasse Hillerxe Petersen     !     *       \
  231. Information & Media Science !        ---   |
  232. Erhus University            !     /       /
  233. DENMARK                     !
  234.  
  235. ---------------------------
  236.  
  237. >From egurney@vcd.hp.com (Eddy J. Gurney)
  238. Subject: "New" bugs in 'develop' floating window code?
  239. Date: Sat, 28 May 1994 22:10:09 GMT
  240. Organization: Hewlett-Packard VCD
  241.  
  242. I recently incorporated Dean Yu's "WindowExtensions.c" library (article
  243. in 'develop' issue 15, "Floating Windows: Keeping Afloat in the
  244. Window Manager", code off issue 16 or newer do to some bug fixes)
  245. into my application to give it floating window ability. Since then
  246. I've pretty much had to abandon my plans to use floating windows
  247. since Modeless Dialogs do not work correctly with floating windows
  248. [IsDialogEvent()/DialogSelect() no longer work... wish I would have
  249. known that _before_ I started... :-]
  250.  
  251. Anyway, I am interested in using the code in another app and found two
  252. bugs while I was experimenting with it. Since I've seen some discussion
  253. here in c.s.m.p on this code, I thought I'd ask if anyone has already
  254. fixed these before I attempt to do it myself.
  255.  
  256. * First bug:
  257. Open a new window, A. Open a new window, B. Hide window B and dispose of
  258. window A. Now create a new window C. It does NOT get hilited, but it IS
  259. active. I believe this is a bug in ShowReferencedWindow where it does
  260. the following check:
  261.  
  262.     windowBehind = GetNextWindow(windowToShow);
  263.     if (windowBehind == FrontNonFloatingWindow()) {
  264.     if (windowBehind != nil)
  265.     DeactivateWindow(windowBehind);
  266.  
  267.      // Set the highlight state Set
  268.     WindowHilite(windowToShow, true);
  269.     }
  270.  
  271. this will only set windowToShow's hilite state to true if the window
  272. immediately after the one being shown is the frontmost VISIBLE
  273. non-floating window.
  274.  
  275. * Second bug:
  276. Open a new window, A. Open a new window, B. Open a new window, C and
  277. hide window B. Now show window B and hide window C. Now hide window
  278. B, leaving only window A visible. Window A is NOT active and is NOT
  279. hilited.
  280.  
  281. Checking WindowList shows the order C->B->A->0, and that window C is
  282. active and hilited, even though it is not visible. (This same sequence
  283. using ToolBox routines has WindowList order A->B->C->0). I believe this
  284. is a bug in HideReferencedWindow where it says:
  285.  
  286.     if (windowToHide == frontNonFloater) {
  287.     windowBehind = GetNextWindow(windowToHide);
  288.     if (windowBehind != nil) {
  289.         SetNextWindow(windowToHide, GetNextWindow(windowBehind));
  290.         SetNextWindow(windowBehind, windowToHide);
  291.         ...
  292.  
  293. This assumes that 'windowBehind' (the next window in the window list
  294. after the window being hidden) is visible.
  295.  
  296. It would be nice if these routines emulated the behavior of the system
  297. ShowWindow/HideWindow; if anyone has already fixed these bugs or has
  298. ideas on how to fix them so they act like the ToolBox, please let me
  299. know. I'll post the "fixes" if/when I figure them out.
  300.  
  301. -- 
  302. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  303. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  304. "Failures are divided into two classes-- those who thought and never did,
  305.       and those who did and never thought."     John Charles Salak
  306.  
  307. +++++++++++++++++++++++++++
  308.  
  309. >From Thomas Reed <reed@medicine.wustl.edu>
  310. Date: 31 May 1994 14:14:46 GMT
  311. Organization: Washington University
  312.  
  313. In article <CqJ9Kx.3zB@vcd.hp.com> Eddy J. Gurney, egurney@vcd.hp.com
  314. writes:
  315. >I recently incorporated Dean Yu's "WindowExtensions.c" library (article
  316. >in 'develop' issue 15, "Floating Windows: Keeping Afloat in the
  317. >Window Manager", code off issue 16 or newer do to some bug fixes)
  318. >into my application to give it floating window ability.
  319.  
  320. On an aside, does anyone know if you can use this code to create a
  321. floating window that will float over ALL windows at ALL times?  i.e. -
  322. even when other apps are in the front, the window will float over ALL
  323. windows?
  324.  
  325. I know this is possible using some kind of calls from the new IM: Text,
  326. but as I only have the old IMs, I can't use this too easily.  I also
  327. don't want to limit this capability to Sys 7.1 only.  I'd like it to work
  328. in previous versions of Sys 7.
  329.  
  330. Thanks!
  331.  
  332. -Thomas
  333. =====================================================
  334. Thomas Reed                    Washington University
  335. Reed@telesphere.wustl.edu          Medical School
  336. (also:  Reed@medicine.wustl.edu)
  337. - ---------------------------------------------------
  338. Clothes make the man.  Naked people have little or no
  339. influence on society.  -- Mark Twain
  340. =====================================================
  341.  
  342. Opinions posted are not the opinions of Wash. U.
  343.  
  344. +++++++++++++++++++++++++++
  345.  
  346. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  347. Date: Tue, 31 May 1994 19:17:35 GMT
  348. Organization: Apple Computer
  349.  
  350. Thomas Reed, reed@medicine.wustl.edu writes:
  351. > On an aside, does anyone know if you can use this code to create a
  352. > floating window that will float over ALL windows at ALL times?  i.e. -
  353. > even when other apps are in the front, the window will float over ALL
  354. > windows?
  355.  
  356. No. The only ways to do this are:
  357. (A) Build some TSM (Text Services Manager) 'service' windows, which always
  358. float. You need System 7.1 or later for this, since TSM is part of
  359. WorldScript.
  360. (B) Use the Layer Manager, which does exist, but was never made public, was
  361. never extensively tested, and which the Toolbox people swear will finally
  362. disappear next year with the Copland system release. A few 3rd parties did
  363. manager to reverse engineer the API, but they'll definitely have some work to
  364. do when Copland ships.
  365. (C) Punch a hole out of the GrayRgn and patch the Window Manager to draw your
  366. stuff in the hole when it needs updating. Also hook into the Event Manager to
  367. grab mouse clicks in that part of the screen. Note that what you have is not
  368. a window at all, just a hole in the screen, so you are responsible for
  369. drawing the title bar and controls yourself. This is REALLY skanky and REALLY
  370. complicated, but has been done by several shipping extensions.
  371.  
  372. Needless to say I'd recommend (A), even though I hear there are some weird
  373. issues associated with running TSM windows. Donald Brown of CE Software wrote
  374. a little demo app that does this for last years' MacHack; perhaps the source
  375. code is around somewhere.
  376.  
  377. --Jens Alfke
  378.   jens_alfke@powertalk              Rebel girl, rebel girl,
  379.             .apple.com              Rebel girl you are the queen of my world
  380.  
  381. +++++++++++++++++++++++++++
  382.  
  383. >From Joe Francis <Joe.Francis@dartmouth.edu>
  384. Date: 31 May 1994 19:38:09 GMT
  385. Organization: Smooth Roo Software
  386.  
  387. Eddy J. Gurney, egurney@vcd.hp.com writes:
  388. > * First bug:
  389. > Open a new window, A. Open a new window, B. Hide window B and dispose of
  390. > window A. Now create a new window C. It does NOT get hilited, but it IS
  391. > active. [....]
  392.  
  393. > * Second bug:
  394. > Open a new window, A. Open a new window, B. Open a new window, C and
  395. > hide window B. Now show window B and hide window C. Now hide window
  396. > B, leaving only window A visible. Window A is NOT active and is NOT
  397. > hilited.  [....]
  398.  
  399. Here are my versions of the related routines.  These should fix the bugs 
  400. you saw.  Please let me know if these cause any problems.  I edited this
  401. a little to make the wrappng work better for the post - I may have 
  402. introduced typos.  Caveat Emptor.  If this code fails, I will refund
  403. your full purchase price.  :-P
  404.  
  405. pascal void ShowReferencedWindow(WindowRef windowToShow)
  406. {
  407.     WindowRef            frontNonFloatingWindow;
  408.     ActivateHandlerUPP    activateHandlerProc;
  409.     short                windowClass;
  410.     Boolean                windowIsInFront = false;
  411.     
  412.     if (GetWindowVisible(windowToShow) != false)
  413.         return;
  414.         
  415.     windowClass = GetWindowKind(windowToShow);
  416.     frontNonFloatingWindow = FrontNonFloatingWindow();
  417.     
  418.     // If the window we are showing will become frontdoc, deactivate
  419.     // former frontdoc, and activate new one.
  420.     
  421.     if (windowClass != kApplicationFloaterKind) 
  422.     {
  423.         if (IsInFrontOf(windowToShow,frontNonFloatingWindow))
  424.         {
  425.             if (frontNonFloatingWindow) 
  426.                 DeactivateWindow(frontNonFloatingWindow);
  427.             SetWindowHilite(windowToShow, true);
  428.             windowIsInFront = true;
  429.         }
  430.     }
  431.     else 
  432.     {
  433.     
  434.     // A floating window is about to be shown. 
  435.     // Make sure the windows in the window list
  436.     // are all in the right place.
  437.     
  438.         ValidateWindowList();
  439.         
  440.     // Check to see if a modal window is up 
  441.     // before trying to highlight it.
  442.     
  443.         frontNonFloatingWindow = FrontNonFloatingWindow();
  444.         if ((frontNonFloatingWindow != nil) &&
  445.             (frontNonFloatingWindow == (WindowRef) FrontWindow()) &&
  446.             (WindowIsModal(frontNonFloatingWindow)))
  447.             SetWindowHilite(windowToShow, false);
  448.         else 
  449.         {
  450.             SetWindowHilite(windowToShow, true);
  451.             windowIsInFront = true;
  452.         }
  453.     }
  454.     
  455.     // Show the window
  456.     
  457.     ShowHide((WindowPtr) windowToShow, true);
  458.     
  459.     // If this is the new frontmost document window 
  460.     // or a floating window, send it an activate event
  461.     
  462.     if (windowIsInFront) 
  463.     {
  464.         activateHandlerProc = GetActivateHandlerProc(windowToShow);
  465.         if (activateHandlerProc != nil)
  466.             CallActivateHandlerProc(activateHandlerProc, 
  467.                     windowToShow, kActivateWindow);
  468.     }
  469. }
  470.  
  471. pascal void HideReferencedWindow(WindowRef windowToHide)
  472. {
  473.     WindowRef            frontFloater;
  474.     WindowRef            frontNonFloater;
  475.     
  476.     // The original code here reorders windows in the window list
  477.     //  to make hidden windows swap places with the window behind
  478.     //  them if:
  479.     //  a) they are either the frontmost floater or frontmost doc;
  480.     //  b) there is a window of the same type behind them;
  481.     //  c) that window behind is visible
  482.     //  That didn't make a lot of sense to me, and it caused bugs,
  483.     //  so I've scrapped it and taken a simpler approach.    
  484.     
  485.     // Don't do anything if the window is already invisible.
  486.     
  487.     if (GetWindowVisible(windowToHide) == false)
  488.         return;
  489.     
  490.     // Get the first visible floating window, if any.
  491.     
  492.     frontFloater = (WindowRef) FrontWindow();
  493.     if (GetWindowKind(frontFloater) != kApplicationFloaterKind)
  494.         frontFloater = nil;
  495.         
  496.     // Get the first visible document window, if any.
  497.     
  498.     frontNonFloater = FrontNonFloatingWindow();
  499.     
  500.     // Hide the window.
  501.     
  502.     ShowHide((WindowPtr) windowToHide, false);
  503.  
  504.     // if we are hiding the frontmost doc window, activate the next
  505.     // frontmost doc window, if any are visible.
  506.     
  507.     if (windowToHide == frontNonFloater)
  508.     {
  509.         // now that we've hidden windowToHide, frontNonFloater will 
  510.         // be different
  511.         frontNonFloater = FrontNonFloatingWindow();
  512.         if (frontNonFloater)
  513.         {
  514.             ActivateWindow(frontNonFloater);
  515.         }
  516.     }
  517. }
  518.  
  519. Boolean IsInFrontOf(WindowRef win1, WindowRef win2)
  520. {
  521.     WindowRef    nextWindow = win1;
  522.  
  523.     //nil windows are always behind other windows
  524.     if (!win1) return false;  
  525.     
  526.     //other windows are always ahead of nil windows
  527.     if (!win2) return true; 
  528.     
  529.     //ok, so the programmer asked me a dumb question  
  530.     if (win1 == win2) return false;  
  531.     
  532.     while (nextWindow)
  533.     {
  534.         nextWindow = GetNextWindow(nextWindow);
  535.         if (nextWindow==win2) return true;
  536.     }
  537.     return false;
  538. }
  539.  
  540. - ------------------------------------------------------------------------
  541. Clap... Hop.... say "Kweepa".....
  542. - ------------------------------------------------------------------------
  543.  
  544. +++++++++++++++++++++++++++
  545.  
  546. >From Joe Francis <Joe.Francis@dartmouth.edu>
  547. Date: 31 May 1994 19:43:05 GMT
  548. Organization: Smooth Roo Software
  549.  
  550. Thomas Reed, reed@medicine.wustl.edu writes:
  551. > On an aside, does anyone know if you can use this code to create a
  552. > floating window that will float over ALL windows at ALL times?  i.e. -
  553. > even when other apps are in the front, the window will float over ALL
  554. > windows?
  555.  
  556. The "develop" floating windows code (by Dean Yu) acheives it's floating
  557. by juggling windows around in the window list.  The window list, though,
  558. is process specific.  Other applications windows are not in the window
  559. list your app sees when it is in the forground.  So the answer is no,
  560. the develop code can not be used to do what you want.
  561.  
  562. - ------------------------------------------------------------------------
  563. No matter how subtle the wizard, a knife between the shoulder blades
  564. will seriously cramp his style.
  565. - ------------------------------------------------------------------------
  566.  
  567. +++++++++++++++++++++++++++
  568.  
  569. >From mxmora@unix.sri.com (Matt Mora)
  570. Date: 1 Jun 94 15:34:17 GMT
  571. Organization: SRI International, Menlo Park, CA
  572.  
  573. In article <1994May31.191735.10959@gallant.apple.com> Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  574. >Thomas Reed, reed@medicine.wustl.edu writes:
  575.  
  576. >Needless to say I'd recommend (A), even though I hear there are some weird
  577. >issues associated with running TSM windows. Donald Brown of CE Software wrote
  578. >a little demo app that does this for last years' MacHack; perhaps the source
  579. >code is around somewhere.
  580.  
  581.  
  582. Matt Slot just posted some code to do the floating windows stuff to 
  583. a.s.m.
  584.  
  585.  
  586. Xavier
  587.  
  588.  
  589. -- 
  590. ___________________________________________________________
  591. Matthew Xavier Mora                       Matt_Mora@sri.com
  592. SRI International                       mxmora@unix.sri.com
  593. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  594.  
  595. ---------------------------
  596.  
  597. >From dubois@uakari.primate.wisc.edu (Paul DuBois)
  598. Subject: Detecting Universal Headers?
  599. Date: 13 May 1994 09:59:53 -0500
  600. Organization: Castra Parvulorum
  601.  
  602. Is there a way I can tell whether the universal headers are being
  603. used, e.g., to do this:
  604.  
  605. #if universalheaders
  606.     do this
  607. #else
  608.     do this instead
  609. #endif
  610.  
  611. -- 
  612. Paul DuBois
  613. dubois@primate.wisc.edu
  614.  
  615. +++++++++++++++++++++++++++
  616.  
  617. >From dmg@dcs.ed.ac.uk (Dominik Gamble)
  618. Date: Mon, 16 May 1994 13:58:08 GMT
  619. Organization: Department of Computer Science, University of Edinburgh
  620.  
  621. In article <2r04l9INN1r9@uakari.primate.wisc.edu>, dubois@uakari.primate.wisc.edu (Paul DuBois) writes:
  622. > Is there a way I can tell whether the universal headers are being
  623. > used, e.g., to do this:
  624. > #if universalheaders
  625. >     do this
  626. > #else
  627. >     do this instead
  628. > #endif
  629.  
  630. As far as I know,
  631.  
  632. #ifdef USES68KINLINES
  633.     /* universal headers present */
  634. #else
  635.     /* universal headers absent */
  636. #endif
  637.  
  638. should work. (At least as far as you know you are compiling
  639. for a 680x0).
  640.  
  641.  
  642. +++++++++++++++++++++++++++
  643.  
  644. >From dean@genmagic.com (Dean Yu)
  645. Date: 18 May 1994 18:01:57 GMT
  646. Organization: General Magic, Inc.
  647.  
  648. In article <CpwEsx.4zz@dcs.ed.ac.uk>, dmg@dcs.ed.ac.uk (Dominik Gamble)
  649. wrote:
  650.  
  651. > In article <2r04l9INN1r9@uakari.primate.wisc.edu>, dubois@uakari.primate.wisc.edu (Paul DuBois) writes:
  652. > > Is there a way I can tell whether the universal headers are being
  653. > > used, e.g., to do this:
  654. > > 
  655. > > #if universalheaders
  656. > >     do this
  657. > > #else
  658. > >     do this instead
  659. > > #endif
  660. > As far as I know,
  661. > #ifdef USES68KINLINES
  662. >     /* universal headers present */
  663. > #else
  664. >     /* universal headers absent */
  665. > #endif
  666.  
  667.   This will work for now, but USES68KINLINES was meant to mean that system
  668. software prototypes are defined using inlined 680x0 instructions (like
  669. A-Traps, and possible some register moving instructions). If Apple ever
  670. moves the system over to shared libraries, then USES68KINLINES would be 0,
  671. even though Universal headers might be present.
  672.   Oh, wait. You used #ifdef, not #if. Never mind.
  673.   At any rate, the Universal Headers comes with a file called
  674. ConditionalMacros.h, which has all the compile time switches that makes the
  675. headers universal. I can't remember if anything specifically about
  676. universal headres was defined in there, but that's the place to look.
  677.  
  678. -- Dean Yu
  679.    Negative Ethnic Role Model
  680.    General Magic, Inc.
  681.  
  682. +++++++++++++++++++++++++++
  683.  
  684. >From tdevon@aol.com (TDevon)
  685. Date: 30 May 1994 04:57:02 -0400
  686. Organization: America Online, Inc. (1-800-827-6364)
  687.  
  688. In article <dean-180594105746@dean_yu.genmagic.com>,
  689. dean@genmagic.com (Dean Yu) writes:
  690.  
  691. I've been using #ifdef's with 'USESROUTINEDESCRIPTORS' but you could
  692. check for '__MIXEDMODE__' as well since that file only exists in the
  693. Universal Headers.  Such a shame that Apple went to all the work in
  694. creating the Universal Headers and they didn't give us defined way to
  695. detect whether they were present or not.  slap, slap!
  696.  
  697. dEVoN
  698.  
  699. ---------------------------
  700.  
  701. >From Adrian C Ruigrok <adrianr@wimsey.com>
  702. Subject: Enumerating messages from PowerTalk
  703. Date: 26 May 1994 23:12:13 GMT
  704. Organization: Ruigrok Innovations Inc.
  705.  
  706. Has anyone figured out how to enumerate AOCE folder?
  707.  
  708. The documentation seems to imply that all you can do
  709. is open a letter that was passed to you when someone 
  710. double clicked on it in the compound mailbox.  You can
  711. also get the next unread letter in the mailbox.
  712.  
  713. But how do you go back the the previous message.  Or
  714. even more involved, how could you show the user a list
  715. of messages in the compound mailbox:  Both the inbox and
  716. the outbox.
  717.  
  718. It looks like the way to do it is with the LetterSpec, but 
  719. the docs say that structure is private and there are no
  720. functions to help you create one.
  721.  
  722. Perhaps the answer is that you should not be creating a list
  723. of letters, but to have to go back the the finder every time 
  724. to browse through your letters is tedious at best.
  725.  
  726. Adrian
  727.  
  728. +++++++++++++++++++++++++++
  729.  
  730. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  731. Date: Fri, 27 May 1994 15:42:17 GMT
  732. Organization: Sexton Software
  733.  
  734. In article <2s3acd$29d@wolfe.wimsey.com> Adrian C Ruigrok,
  735. adrianr@wimsey.com writes:
  736. >Perhaps the answer is that you should not be creating a list
  737. >of letters, but to have to go back the the finder every time 
  738. >to browse through your letters is tedious at best.
  739.  
  740. That seems to be exactly what is intended by Mr. Sidhu. There was a lot
  741. of flak on this particular topic some time back and I've heard no
  742. indication that Apple has changed its position. Sorry I can't provide
  743. useful information (try to hack the external file system?) except to say
  744. that others have reached the same conclusion.
  745. Steve Bryan                       sbryan@maroon.tc.umn.edu
  746. Sexton Software                   CompuServe: 76545,527
  747. Minneapolis, MN                   fax: (612) 929-1799
  748.  
  749. +++++++++++++++++++++++++++
  750.  
  751. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  752. Date: 30 May 94 17:02:26 +1200
  753. Organization: University of Waikato, Hamilton, New Zealand
  754.  
  755. In article <2s3acd$29d@wolfe.wimsey.com>, Adrian C Ruigrok <adrianr@wimsey.com> writes:
  756. > Has anyone figured out how to enumerate AOCE folder?
  757. >
  758. > The documentation seems to imply that all you can do
  759. > is open a letter that was passed to you when someone
  760. > double clicked on it in the compound mailbox.  You can
  761. > also get the next unread letter in the mailbox.
  762. >
  763. > But how do you go back the the previous message.  Or
  764. > even more involved, how could you show the user a list
  765. > of messages in the compound mailbox:  Both the inbox and
  766. > the outbox.
  767. >
  768. > It looks like the way to do it is with the LetterSpec, but
  769. > the docs say that structure is private and there are no
  770. > functions to help you create one.
  771. >
  772. > Perhaps the answer is that you should not be creating a list
  773. > of letters, but to have to go back the the finder every time
  774. > to browse through your letters is tedious at best.
  775.  
  776. I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  777. He said there *is* a mail API that would allow you to do all this, but it
  778. wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  779. it public. He promised that they would do so in a future version.
  780.  
  781. In the meantime, you could try asking DTS if they'll give you information about
  782. the unsupported API. I understand some vendors are already working with this.
  783.  
  784. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  785. Info & Tech Services Division              fax: +64-7-838-4066
  786. University of Waikato            electric mail: ldo@waikato.ac.nz
  787. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  788.  
  789. +++++++++++++++++++++++++++
  790.  
  791. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  792. Date: 30 May 1994 10:46:04 GMT
  793. Organization: Microplex Pty Ltd
  794.  
  795. Lawrence D'Oliveiro, Waikato University (ldo@waikato.ac.nz) wrote:
  796. : In article <2s3acd$29d@wolfe.wimsey.com>, Adrian C Ruigrok <adrianr@wimsey.com> writes:
  797. : > Has anyone figured out how to enumerate AOCE folder?
  798. : >
  799. : > The documentation seems to imply that all you can do
  800. : > is open a letter that was passed to you when someone
  801. : > double clicked on it in the compound mailbox.  You can
  802. : > also get the next unread letter in the mailbox.
  803. : >
  804. : > But how do you go back the the previous message.  Or
  805. : > even more involved, how could you show the user a list
  806. : > of messages in the compound mailbox:  Both the inbox and
  807. : > the outbox.
  808. : >
  809. : > It looks like the way to do it is with the LetterSpec, but
  810. : > the docs say that structure is private and there are no
  811. : > functions to help you create one.
  812. : >
  813. : > Perhaps the answer is that you should not be creating a list
  814. : > of letters, but to have to go back the the finder every time
  815. : > to browse through your letters is tedious at best.
  816.  
  817. : I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  818. : He said there *is* a mail API that would allow you to do all this, but it
  819. : wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  820. : it public. He promised that they would do so in a future version.
  821.  
  822. : In the meantime, you could try asking DTS if they'll give you information about
  823. : the unsupported API. I understand some vendors are already working with this.
  824.  
  825. I also have heard the same story. However, I have "discovered" that the 
  826. in tray can be enumerated at a low level using the IPM calls. The queue 
  827. to access is called In_Tray or something (I can't remember the exact 
  828. name, the code is at work and I'm at home at present). You can read mail 
  829. this way, but you can't mark it as read, or tell whether it was read 
  830. before. Also, the mail MUST be present on the local machine. If it is on 
  831. a server, you will have to discover the queue name and address for yourself!
  832.  
  833. In the meantime, we have an oustanding DTS request for the private API. 
  834. Unfortunately, I expect this to be subject to an NDA :(
  835.  
  836. If anyone needs more details on the above I can probably post it from 
  837. work tomorrow.
  838.  
  839. - ---
  840. Steve Coy
  841. Resolve Software (WA) Pty Ltd
  842.  
  843.  
  844. +++++++++++++++++++++++++++
  845.  
  846. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  847. Date: Tue, 31 May 1994 19:24:17 GMT
  848. Organization: Apple Computer
  849.  
  850. Lawrence D'Oliveiro, ldo@waikato.ac.nz writes:
  851. > I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  852. > He said there *is* a mail API that would allow you to do all this, but it
  853. > wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  854. > it public. He promised that they would do so in a future version.
  855. > In the meantime, you could try asking DTS if they'll give you information
  856. about
  857. > the unsupported API. I understand some vendors are already working with
  858. this.
  859.  
  860. Beyond's "PowerRules" provides a suite of events for accessing the In Tray.
  861. You can enumerate the letters, examine info like senders or date sent, all
  862. from Apple events. This implies that they're using this private API, and also
  863. that other apps could get this functionality by talking to PowerRules.
  864.  
  865. Unfortunately I have to say that the version I used (1.0D, I think) was
  866. really buggy. Their Apple Event support seems flaky in the extreme, and it
  867. was only with difficulty that I could get anything to work; even then, most
  868. of the time it either ignored incoming mail or returned mysterious error
  869. codes when running my agent scripts. If they could only make the thing more
  870. solid it'd be terrific.
  871.  
  872. --Jens Alfke
  873.   jens_alfke@powertalk              Rebel girl, rebel girl,
  874.             .apple.com              Rebel girl you are the queen of my world
  875.  
  876. ---------------------------
  877.  
  878. >From hoyer@cc.Helsinki.FI (Paul Hoyer)
  879. Subject: MicroSeconds trap # and arguments?
  880. Date: 25 May 1994 22:43:14 +0300
  881. Organization: University of Helsinki
  882.  
  883. I know there was a thread a while ago concerning the MicroSeconds trap,
  884. but I didn't follow c.s.m.p closely enough then... So sorry if I'm
  885. asking for information I might have got from that thread!
  886.  
  887. I'd like to use the MicroSeconds() trap to measure the speed of my code,
  888. but since Think C v5.0 doesn't seem to know about the trap I need the
  889. trap number and how to call if from assembly. I assume the trap is
  890. implemented in Sys. 7.1?
  891.  
  892. It's probably documented in IM-6 somewhere, but since I don't own it
  893. (I'm just a poor student), I'd appreciate it if somebody could simply
  894. e-mail me the info.
  895.  
  896. Thanks in advance!!!
  897.  
  898. -P. Hoyer <hoyer@cc.helsinki.fi>
  899.  
  900. +++++++++++++++++++++++++++
  901.  
  902. >From olmsted@cs.ucdavis.edu (Bret Olmsted)
  903. Date: Wed, 25 May 1994 20:15:23 GMT
  904. Organization: University of California, Davis
  905.  
  906. Paul Hoyer (hoyer@cc.Helsinki.FI) wrote:
  907. : I'd like to use the MicroSeconds() trap to measure the speed of my code,
  908. : but since Think C v5.0 doesn't seem to know about the trap I need the
  909. : trap number and how to call if from assembly. I assume the trap is
  910. : implemented in Sys. 7.1?
  911.  
  912. Here is some code that does just the job:
  913.  
  914. TMTask             task;
  915.  
  916. static void start_timer(void)        /* Start measuring elapsed time. */
  917.   {
  918.     task.qLink = NULL;
  919.     task.qType = 0;
  920.     task.tmAddr = 0;
  921.     task.tmCount = 0;
  922.     InsTime((QElemPtr) &task);
  923.     PrimeTime((QElemPtr) &task, 0x80000000);
  924.   }
  925.  
  926. static long stop_timer(void)        /* Stop measuring elapsed time. */
  927.   {
  928.     RmvTime((QElemPtr) &task);
  929.     return task.tmCount - 0x80000000;    /* return time elapsed. */
  930.   }
  931.  
  932.  
  933. Hope that helps.
  934.  
  935. Bret Olmsted
  936. olmsted@cs.ucdavis.edu
  937.  
  938.  
  939. u
  940.  
  941.  
  942. +++++++++++++++++++++++++++
  943.  
  944. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  945. Date: 31 May 94 10:36:01 +1200
  946. Organization: University of Waikato, Hamilton, New Zealand
  947.  
  948. In article <2s09oi$4ga@kruuna.Helsinki.FI>, hoyer@cc.Helsinki.FI (Paul Hoyer) writes:
  949. >
  950. > I'd like to use the MicroSeconds() trap to measure the speed of my code,
  951. > but since Think C v5.0 doesn't seem to know about the trap I need the
  952. > trap number and how to call if from assembly. I assume the trap is
  953. > implemented in Sys. 7.1?
  954. >
  955. > It's probably documented in IM-6 somewhere...
  956.  
  957. No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  958. I gather it has since worked its way into Apple's standard interfaces. Here's
  959. one way you can call it:
  960.  
  961.     PROCEDURE MicroSeconds64
  962.       (
  963.     VAR Result : Comp
  964.       );
  965.       (* returns the full 64 bits of a microsecond clock. *)
  966.  
  967.     CODE
  968.         0A193H,        (* _MicroSeconds *)
  969.         0225FH,        (* move.l (sp)+, a1 *)
  970.         022C8H,        (* move.l a0, (a1)+ *)
  971.         022C0H;        (* move.l d0, (a1)+ *)
  972.  
  973. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  974. Info & Tech Services Division              fax: +64-7-838-4066
  975. University of Waikato            electric mail: ldo@waikato.ac.nz
  976. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  977.  
  978. +++++++++++++++++++++++++++
  979.  
  980. >From sobiloff (Blake Sobiloff)
  981. Date: Tue, 31 May 1994 11:36:26 -0400
  982. Organization: Lab for Automation Psychology
  983.  
  984. In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  985. (Lawrence D'Oliveiro, Waikato University) wrote:
  986.  
  987. > No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  988. > I gather it has since worked its way into Apple's standard interfaces. Here's
  989. > one way you can call it:
  990. [...]
  991.  
  992. Or, if you have the Universal Headers, its trap is included in <Traps.h>.
  993. -- 
  994. Blake Sobiloff <sobiloff@mail.lap.umd.edu> | University of Maryland
  995. Laboratory for Automation Psychology       | College Park, MD  20742-4411
  996. Department of Psychology                   | 301/405-5936 (Voice)
  997.               Ayrton Senna de Silva, RIP. (May 1, 1994)
  998.  
  999. +++++++++++++++++++++++++++
  1000.  
  1001. >From afcjlloyd@aol.com (AFC JLloyd)
  1002. Date: 31 May 1994 18:36:01 -0400
  1003. Organization: America Online, Inc. (1-800-827-6364)
  1004.  
  1005. In article <sobiloff-310594113627@dataranch.lap.umd.edu>, sobiloff
  1006. (Blake Sobiloff) writes:
  1007.  
  1008. >In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  1009. >(Lawrence D'Oliveiro, Waikato University) wrote:
  1010. >
  1011. >> No, it's not. It first turned up in some Sound Manager 3.0 sample
  1012. code, and
  1013. >> I gather it has since worked its way into Apple's standard
  1014. interfaces. Here's
  1015. >> one way you can call it:
  1016. >[...]
  1017. >
  1018. >Or, if you have the Universal Headers, its trap is included in
  1019. <Traps.h>.
  1020.  
  1021. Or even better, if you have the Universal Headers it is defined in
  1022. <Timer.h>:
  1023.  
  1024. extern pascal void Microseconds(UnsignedWide *microTickCount)
  1025.  FOURWORDINLINE(0xA193, 0x225F, 0x22C8, 0x2280);
  1026.  
  1027. I have done some experimenting with this trap today and noticed that
  1028. it seems to be true microseconds.  From various documentation that I
  1029. have seen the Time Manager is based on a VIA timer that operates at
  1030. 783360 hz, but the values returned by Microseconds are clearly much
  1031. closer to 1000000 hz.  Perhaps this has been mentioned earlier in
  1032. this thread and I missed it, but I assume this trap is not supported
  1033. on all configurations of hardware/software.  I believe it was
  1034. mentioned earlier that QuickTime relies on this trap.  Can I assume
  1035. that any configuration of hardware/software that supports QuickTime
  1036. will support this trap?
  1037.  
  1038. Jim Lloyd
  1039. afcjlloyd@aol.com
  1040.  
  1041.  
  1042. +++++++++++++++++++++++++++
  1043.  
  1044. >From dean@genmagic.com (Dean Yu)
  1045. Date: 1 Jun 1994 03:16:08 GMT
  1046. Organization: General Magic, Inc.
  1047.  
  1048. In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  1049. (Lawrence D'Oliveiro, Waikato University) wrote:
  1050.  
  1051. > In article <2s09oi$4ga@kruuna.Helsinki.FI>, hoyer@cc.Helsinki.FI (Paul Hoyer) writes:
  1052. > >
  1053. > > I'd like to use the MicroSeconds() trap to measure the speed of my code,
  1054. > > but since Think C v5.0 doesn't seem to know about the trap I need the
  1055. > > trap number and how to call if from assembly. I assume the trap is
  1056. > > implemented in Sys. 7.1?
  1057. > >
  1058. > > It's probably documented in IM-6 somewhere...
  1059. > No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  1060. > I gather it has since worked its way into Apple's standard interfaces. Here's
  1061. > one way you can call it:
  1062.  
  1063.   Actually, I believe it first came out with QuickTime. I seem to recall
  1064. fixing a bug in 7.1 where the value returned by Microseconds would drift
  1065. after a while, so it's been around for at least that long. Whether it's
  1066. been public since then is a different story...
  1067.  
  1068. -- Dean Yu
  1069.    Negative Ethnic Role Model
  1070.    General Magic, Inc.
  1071.  
  1072. ---------------------------
  1073.  
  1074. >From st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith)
  1075. Subject: Ok, where's my Quickdraw globals?  (Help!)
  1076. Date: Sat, 21 May 1994 06:01:36 GMT
  1077. Organization: Drexel University
  1078.  
  1079.    We just got our copy of CodeWarrior Gold today, and I've been feverishly
  1080. working to port a few thousand lines of C++ code from Symantec C++.
  1081.  
  1082.    For the most part, converting to the PPC seems to have been easy.  I was
  1083. able to get everything to compile and link after some fooling around.
  1084.  
  1085.    But I'm having a problem, and I'm familiar with it, and know it's been
  1086. raised before, but never paid too much attention.
  1087.  
  1088.    I specifically use some QuickDraw globals such as "thePort" and
  1089. "screenBits."  That's never been a problem with Symantec C++.
  1090.  
  1091.    But CodeWarrior doesn't like them.
  1092.  
  1093. I note the following structure (defined in good ol' Quickdraw.h):
  1094.  
  1095. - --
  1096. struct QDGlobals {
  1097.     char                        privates[76];
  1098.     long                        randSeed;
  1099.     BitMap                    screenBits;
  1100.     Cursor                    arrow;
  1101.     Pattern                    dkGray;
  1102.     Pattern                    ltGray;
  1103.     Pattern                    gray;
  1104.     Pattern                    black;
  1105.     Pattern                    white;
  1106.     GrafPtr                    thePort;
  1107. };
  1108. #if defined(powerc) || defined(__powerc)
  1109. #pragma options align=reset
  1110. #endif
  1111.  
  1112. typedef struct QDGlobals QDGlobals;
  1113. - --
  1114.  
  1115.    Obviously, this is what I'm looking for.  First question: is this the
  1116. method we're supposed to use now to get at things such as thePort?
  1117.  
  1118.    And the most important question: HOW DO I FILL THIS STRUCTURE?  I'm
  1119. assuming there must be an easy way; I can't find it, and I can't find any
  1120. useful mention of it in docs anywhere.
  1121.  
  1122.    I feel like I've been sleeping and missed the boat on this one.
  1123. I know some yechy ways of getting at screenBits and thePort, but would like
  1124. to avoid that, since I'm assuming there's a much easier way.
  1125.  
  1126.    Any help would be appreciated.
  1127.  
  1128.    Other than that, so far I'm pleased with CodeWarrior.  Neat About
  1129. boxes.  :)  I'd have to echo another poster's comments on the docs, though:
  1130. I hate Apple's DocViewer.  I love Think Reference.
  1131.  
  1132.    Also, the editor seems sluggish.  I assume this is because of its added
  1133. "functionality" such as colorizing different types of text.  (Then again,
  1134. I'm running on an old, slow IIfx..  Sigh.)
  1135.  
  1136. Thanks in advance for (prompt) help..  I'd like to get this thing ported by
  1137. Sunday for an Open House we're having.
  1138.  
  1139. - Scott
  1140.  
  1141. - -
  1142. M. Scott Smith  (umsmith@mcs.drexel.edu)
  1143.  
  1144.   Math and Computer Science, Drexel University
  1145.  
  1146.   Mac developer.  Student.  Ski bum.  (But all the snow melted..  Sniff.)
  1147.  
  1148.  
  1149. +++++++++++++++++++++++++++
  1150.  
  1151. >From dan694356@aol.com (Dan 694356)
  1152. Date: 21 May 1994 03:03:14 -0400
  1153. Organization: America Online, Inc. (1-800-827-6364)
  1154.  
  1155. You need to allocate storage for qd...
  1156.  
  1157. #ifdef powerc
  1158. QDGlobals qd;
  1159. #endif
  1160.  
  1161. ... somewhere in your code, it's not in the PPC libraries (don't know
  1162. why, Apple just left it out).  If you've gotten used to doing just
  1163. 'thePort' or 'screenBits' rather than 'qd.thePort' and
  1164. 'qd.screenBits', now's as good a time as any to get out of that
  1165. habit, since it doesn't work in the new compilers either. :-)
  1166.  
  1167. - Dan
  1168.  
  1169. +++++++++++++++++++++++++++
  1170.  
  1171. >From mwron@aol.com (MW Ron)
  1172. Date: 21 May 1994 12:22:14 -0400
  1173. Organization: America Online, Inc. (1-800-827-6364)
  1174.  
  1175. In article <Cq522o.CKz@Dunx1.OCS.Drexel.Edu>,
  1176. st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith) writes:
  1177.  
  1178. >> I specifically use some QuickDraw globals such as "thePort" and
  1179. "screenBits."  That's never been a problem with Symantec C++.
  1180.  
  1181.   This is not a Symantec vs CW item, it is a change Apple made to
  1182. minimaze global namespace cluttering.  A few years ago Apple decided
  1183. to encapsulate the variables called the QuickDraw globals that are
  1184. referenced from A5 and include thePort and screenBits in a structure
  1185. called qd. You can find them listed in the QuickDraw.h header file.
  1186. This new way also allows the compiler to handle quickdraw globals
  1187. without any special code on non-68k Macs.
  1188.     To access your global QuickDraw Variables, simply use
  1189. qd.<variableName> to access them as a structure member.
  1190.  
  1191. Ron Liechty
  1192. mwron@aol.com
  1193. Metrowerks Inc.
  1194.  
  1195. +++++++++++++++++++++++++++
  1196.  
  1197. >From mxmora@unix.sri.com (Matt Mora)
  1198. Date: 23 May 1994 10:30:07 -0700
  1199. Organization: SRI International, Menlo Park, CA
  1200.  
  1201. In article <Cq522o.CKz@Dunx1.OCS.Drexel.Edu> st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith) writes:
  1202. >   We just got our copy of CodeWarrior Gold today, and I've been feverishly
  1203. >working to port a few thousand lines of C++ code from Symantec C++.
  1204. >
  1205. >   For the most part, converting to the PPC seems to have been easy.  I was
  1206. >able to get everything to compile and link after some fooling around.
  1207. >
  1208. >   But I'm having a problem, and I'm familiar with it, and know it's been
  1209. >raised before, but never paid too much attention.
  1210. >
  1211. >   I specifically use some QuickDraw globals such as "thePort" and
  1212. >"screenBits."  That's never been a problem with Symantec C++.
  1213.  
  1214. >struct QDGlobals {
  1215.  
  1216. You need to add
  1217.  
  1218.  
  1219. QDGlobals qd;
  1220.  
  1221. to your code to create the global variable. the you call InitGraf
  1222. passing the global &qd.thePort to Initgraf.
  1223.  
  1224. Xavier
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230. -- 
  1231. ___________________________________________________________
  1232. Matthew Xavier Mora                       Matt_Mora@sri.com
  1233. SRI International                       mxmora@unix.sri.com
  1234. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  1235.  
  1236. +++++++++++++++++++++++++++
  1237.  
  1238. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1239. Date: Thu, 26 May 1994 22:43:37 GMT
  1240. Organization: Apple Computer
  1241.  
  1242. Matt Mora, mxmora@unix.sri.com writes:
  1243. > You need to add
  1244. > QDGlobals qd;
  1245. > to your code to create the global variable. the you call InitGraf
  1246. > passing the global &qd.thePort to Initgraf.
  1247.  
  1248. Huh? In CodeWarrior? I've never needed to do this. As far as I can tell, qd
  1249. is automatic; it's defined in the runtime library or somewhere like that.
  1250.  
  1251. --Jens Alfke
  1252.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1253.             .apple.com              Rebel girl you are the queen of my world
  1254.  
  1255. +++++++++++++++++++++++++++
  1256.  
  1257. >From paulw@crl.com (Paul Winterrowd)
  1258. Date: 27 May 1994 09:32:12 -0700
  1259. Organization: CRL Dialup Internet Access    (415) 705-6060  [login: guest]
  1260.  
  1261. Jens Alfke (jens_alfke@powertalk.apple.com) wrote:
  1262. : Matt Mora, mxmora@unix.sri.com writes:
  1263. : > You need to add
  1264. : > QDGlobals qd;
  1265. : > to your code to create the global variable. the you call InitGraf
  1266. : > passing the global &qd.thePort to Initgraf.
  1267.  
  1268. : Huh? In CodeWarrior? I've never needed to do this. As far as I can tell, qd
  1269. : is automatic; it's defined in the runtime library or somewhere like that.
  1270.  
  1271. : --Jens Alfke
  1272. :   jens_alfke@powertalk              Rebel girl, rebel girl,
  1273. :             .apple.com              Rebel girl you are the queen of my world
  1274.  
  1275. Check out the file MacHeaderPPC (or MacHeader68K if you are compiling 68k code)
  1276. and I believe that's where it is defined.  The really nice part about it is
  1277. you can change the precompiled header!  
  1278.  
  1279. paulw@crl.com
  1280. -- 
  1281. - ---------------------------------------------------------------
  1282. I only speak for myself.  
  1283.  
  1284.  
  1285. +++++++++++++++++++++++++++
  1286.  
  1287. >From bell@apple.com (Mike Bell)
  1288. Date: Tue, 31 May 1994 18:09:32 GMT
  1289. Organization: Apple Computer, Inc.
  1290.  
  1291. In article <2s57ac$eap@crl.crl.com>, paulw@crl.com (Paul Winterrowd) writes:
  1292. > Path: gallant.apple.com!murky.apple.com!apple.com!olivea!decwrl!nntp.
  1293. > crl.com!crl.crl.com!not-for-mail From: paulw@crl.com (Paul Winterrowd) 
  1294. > Newsgroups: comp.sys.mac.programmer 
  1295. > Subject: Re: Ok, where's my Quickdraw globals?  (Help!) 
  1296. > Date: 27 May 1994 09:32:12 -0700 
  1297. > Organization: CRL Dialup Internet Access    (415) 705-6060  [login: 
  1298. > guest] Lines: 23 
  1299. > Message-ID: <2s57ac$eap@crl.crl.com> 
  1300. > References: <Cq522o.CKz@Dunx1.OCS.Drexel.Edu> <2rqp6v$1oe@unix.sri.
  1301. > com> <1994May26.224337.8856@gallant.apple.com> NNTP-Posting-Host: crl.
  1302. > com 
  1303. > X-Newsreader: TIN [version 1.2 PL2] 
  1304. > Jens Alfke (jens_alfke@powertalk.apple.com) wrote: 
  1305. > : Matt Mora, mxmora@unix.sri.com writes: 
  1306. > : > You need to add 
  1307. > : > QDGlobals qd; 
  1308. > : > to your code to create the global variable. the you call 
  1309. > InitGraf : > passing the global &qd.thePort to Initgraf. 
  1310. > : Huh? In CodeWarrior? I've never needed to do this. As far as I can 
  1311. > tell, qd : is automatic; it's defined in the runtime library or 
  1312. > somewhere like that. 
  1313. > : --Jens Alfke 
  1314. > :   jens_alfke@powertalk              Rebel girl, rebel girl, 
  1315. > :             .apple.com              Rebel girl you are the queen of 
  1316. > my world 
  1317. > Check out the file MacHeaderPPC (or MacHeader68K if you are 
  1318. > compiling 68k code) and I believe that's where it is defined.  The 
  1319. > really nice part about it is you can change the precompiled header!  
  1320. > paulw@crl.com 
  1321. > -- 
  1322. > ----------------------------------------------------------------- 
  1323. > I only speak for myself.  
  1324. >  
  1325.  
  1326.  
  1327. As Matt mentioned, you need to define your own QuickDraw globals if you are 
  1328. using the Apple PowerMacintosh development tools.  The CodeWarrior stuff 
  1329. defines it for you, but this is build system dependent.
  1330.  
  1331.     -Mike
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339. ---------------------------
  1340.  
  1341. >From timmyd@netcom.com (Tim DeBenedictis)
  1342. Subject: Symantec C++ 7.0- any good?
  1343. Date: Sun, 29 May 1994 18:04:06 GMT
  1344. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1345.  
  1346. I'm trying to decide between upgrading from THINK C 5.0.4 to Symantec C++
  1347. 7.0 or CodeWarrior.  Given that I've got a lot of code committed to THINK/
  1348. Symantec, is it worth switching to MetroWerks?  I've heard that Sym C++ 6.0
  1349. was so buggy as to be practically useless.  Is 7.0 decent?  Also, can I
  1350. compile native PPC apps with Symantec?  (I don't have a PPC yet, but I
  1351. may in the not so distant future.)  I also don't want to give up 50
  1352. megs of hard drive space to a compiler... which package is smaller?
  1353.  
  1354.  
  1355. Any comments greatly appreciated,
  1356.  
  1357. Tim DeBenedictis
  1358.  
  1359. PS please send e-mail, since I don't read this group often.
  1360.  
  1361.  
  1362. +++++++++++++++++++++++++++
  1363.  
  1364. >From nick@pitt.edu ( nick.c )
  1365. Date: Mon, 30 May 94 12:29:40 GMT
  1366. Organization: University of Pittsburgh
  1367.  
  1368. In Article <timmydCqKsuv.6vw@netcom.com>, timmyd@netcom.com (Tim
  1369. DeBenedictis) wrote:
  1370.  
  1371. >I'm trying to decide between upgrading from THINK C 5.0.4 to Symantec C++
  1372. >7.0 or CodeWarrior.  Given that I've got a lot of code committed to THINK/
  1373. >Symantec, is it worth switching to MetroWerks?  I've heard that Sym C++ 6.0
  1374. >was so buggy as to be practically useless.  Is 7.0 decent?  Also, can I
  1375. >compile native PPC apps with Symantec?  (I don't have a PPC yet, but I
  1376. >may in the not so distant future.)  I also don't want to give up 50
  1377. >megs of hard drive space to a compiler... which package is smaller?
  1378.  
  1379.  
  1380.    I haven't tried CodeWarrior yet (have thought about it), but 
  1381.      SC++ 7.02 seems pretty stable to me.  Here's some info I think 
  1382.      is important:
  1383.  
  1384.     - SC++ takes up about 17 MB HD space (full installation + 7.02 updated),
  1385.        while CodeWarrior takes up 6 MB for C/C++ (with another 8 MB for
  1386.        class library: total 14 MB) - ie both seem to be about the same.
  1387.  
  1388.     - With SC++ you have to pay extra to get a "cross platform" kit 
  1389.        from symantec - and I'm not really clear if this includes a PPC 
  1390.        compiler.  I don't think it does.  CodeWarrior gold includes 
  1391.        a PPC compiler and runs native.  No version of SC++ runs native yet.
  1392.  
  1393.     - If your code doesn't use TCL it should be portable to CodeWarrrior.
  1394.       
  1395.     - MetroWerks seems to have the best customer support.  They don't
  1396.        charge you for it (Symantec does after 30 days or so), they give you
  1397.        three free updates (Symantec has started something like this, but
  1398.        again you have to subscrivbe - ie pay - for it), and their guys
  1399.        seem to pay more attention to this newsgroup (no slight intended 
  1400.        to those folks from symantec who are here).
  1401.  
  1402.     - CodeWarrior is only available on CD.  For me this is a plus (I like
  1403.        CD's) - but if you don't have a drive yet this will be an issue.
  1404.  
  1405.     - TPM w/out VA can run in about 2.5 MB of ram.  I don't know how much
  1406.        CodeWarrior wants.
  1407.   
  1408.     - Both are compatible with other development tools like Think Reference
  1409.        (a must have in my book), Object Master (something I'm really
  1410.        getting addicted to), Alpha or BBedit, etc.
  1411.  
  1412.     - There is an established base of literature and example code out there
  1413.        specific for symantec. (eg. Dave Mark's Books, Sydow's Book,
  1414.        and guestimate >70% of shareware was written with Symantec's stuff). 
  1415.  
  1416.  
  1417.     I'm kind of new to all this (been at it about a year), so for me the
  1418.       last point is pretty important.  CodeWarrior is coming on strong,
  1419.       and I don't doubt that in another year there will be a wealth of
  1420.       software and literature out there written in/for CodeWarrior.
  1421.       For now, I'm going to stick with Symantec, and if other folks are
  1422.       just getting started I'd recommend same.  If you're familiar with
  1423.       the toolbox, have C or C++ down, and are generally a mature developer
  1424.       CodeWarrior seems to be the best deal.  I figure by the time I get
  1425.       there I'll be able to switch over fairly easy, or perhaps Symantec
  1426.       will come back strong with a packaged PPC compiler, a native
  1427.       environment, maybe a faster compiler, and (on my wish list) better
  1428.       documentation of TCL (sorry guys - I still can't make heads or 
  1429.       tails out of it... still trying).  Anyway, hope the info helps and 
  1430.       take the opinions with a grain of salt - both are good products.
  1431.  
  1432.                                                 -- nick
  1433.  
  1434.  
  1435.    BTW - has someone put together a SC++ vs CodeWarrior FAQ yet?  Seems
  1436.       like we need one...
  1437.  
  1438.  
  1439.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  1440.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  1441.  _/ _/_/  _/  _/       _/ _/
  1442. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  1443.  
  1444.  
  1445. ---------------------------
  1446.  
  1447. >From rmah@panix.com (Robert S. Mah)
  1448. Subject: Thread Mgr for blocking I-O
  1449. Date: Sat, 21 May 1994 03:14:19 -0500
  1450. Organization: One Step Beyond
  1451.  
  1452. I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1453. as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1454. was wondering if anyone else has tried this.
  1455.  
  1456. For example, while the article recomends putting the I/O thread to sleep,
  1457. and using a wake up thread which is triggered by the completion routine,
  1458. I was wondering how much less efficient a simpler solutio would be.
  1459.  
  1460. That is, instead of...
  1461.  
  1462.    I/O Thread
  1463.       Create WakeUp thread in stopped state
  1464.       Async call with completion routine
  1465.       Sleep this thread
  1466.       Handle results
  1467.  
  1468.    WakeUp Thread
  1469.       Wakeup the I/O thread
  1470.  
  1471.    Completion Routine
  1472.       Wakeup the WakeUp thread
  1473.  
  1474. How about...
  1475.  
  1476.    I/O Thread
  1477.       Async call without completion routine
  1478.       while ioResult not done
  1479.          Yield
  1480.       Handle results
  1481.  
  1482. So, while the I/O thread is always running, and does not sleep, thereby
  1483. hogging resources, does this incur _that_ much overhead?  I have a 
  1484. suspician that this would be more efficient than calling WaitNextEvent
  1485. (i.e. in a single threaded app) instead of Yield.  Or would it?
  1486.  
  1487. Cheers,
  1488. Rob
  1489. ___________________________________________________________________________
  1490. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1491.  
  1492. +++++++++++++++++++++++++++
  1493.  
  1494. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1495. Date: 22 May 1994 02:06:41 GMT
  1496. Organization: Microplex Pty Ltd
  1497.  
  1498. Robert S. Mah (rmah@panix.com) wrote:
  1499. : I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1500. : as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1501. : was wondering if anyone else has tried this.
  1502.  
  1503. : For example, while the article recomends putting the I/O thread to sleep,
  1504. : and using a wake up thread which is triggered by the completion routine,
  1505. : I was wondering how much less efficient a simpler solutio would be.
  1506.  
  1507. : That is, instead of...
  1508.  
  1509. :    I/O Thread
  1510. :       Create WakeUp thread in stopped state
  1511. :       Async call with completion routine
  1512. :       Sleep this thread
  1513. :       Handle results
  1514.  
  1515. :    WakeUp Thread
  1516. :       Wakeup the I/O thread
  1517.  
  1518. :    Completion Routine
  1519. :       Wakeup the WakeUp thread
  1520.  
  1521. : How about...
  1522.  
  1523. :    I/O Thread
  1524. :       Async call without completion routine
  1525. :       while ioResult not done
  1526. :          Yield
  1527. :       Handle results
  1528.  
  1529. : So, while the I/O thread is always running, and does not sleep, thereby
  1530. : hogging resources, does this incur _that_ much overhead?  I have a 
  1531. : suspician that this would be more efficient than calling WaitNextEvent
  1532. : (i.e. in a single threaded app) instead of Yield.  Or would it?
  1533.  
  1534. I have been using the second method you described above for some time 
  1535. now, both with the original threads package and the new stuff. Sure, you 
  1536. get a lot of thread swapping, but this is pretty cheap these days.
  1537.  
  1538. The technique described in Develop seems like a lot of trouble to me. I 
  1539. would love to see someone justify it. (That is, I want to know the 
  1540. technical reasons why it should be done that way.)
  1541.  
  1542. : Cheers,
  1543. : Rob
  1544. : ___________________________________________________________________________
  1545. : Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1546.  
  1547. Steve Coy
  1548. Resolve Software (WA) Pty Ltd
  1549.  
  1550.  
  1551. +++++++++++++++++++++++++++
  1552.  
  1553. >From qmot@cs.mcgill.ca (Thomas PUSHPATHADAM)
  1554. Date: 22 May 1994 08:33:37 GMT
  1555. Organization: SOCS, McGill University, Montreal, Canada
  1556.  
  1557. Path: NewsWatcher!user
  1558. Date: Sun, 22 May 1994 04:16:58 -0400
  1559. From: paul@architecture.mcgill.ca (Paul Lalonde)
  1560. Newsgroups: comp.sys.mac.programmer
  1561. Followup-To: comp.sys.mac.programmer
  1562. Subject: Re: Thread Mgr for blocking I/O
  1563. Message-ID: <paul-220594041658@132.206.27.50>
  1564. References: <rmah-210594031419@rmah.dialup.access.net>
  1565. Organization: McGill University School of Architecture
  1566.  
  1567. In article <rmah-210594031419@rmah.dialup.access.net>, rmah@panix.com (Robert S. Mah) wrote:
  1568.  
  1569. > I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1570. > as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1571. > was wondering if anyone else has tried this.
  1572.  
  1573. [stuff deleted]
  1574.  
  1575. > So, while the I/O thread is always running, and does not sleep, thereby
  1576. > hogging resources, does this incur _that_ much overhead?  I have a 
  1577. > suspician that this would be more efficient than calling WaitNextEvent
  1578. > (i.e. in a single threaded app) instead of Yield.  Or would it?
  1579.  
  1580. Well, if you have several threads that are looping like the example above 
  1581. (the technical term is "busy-waiting"), you may spend a lot of time just 
  1582. switching contexts for no reason.  The technique illustrated in develop 17, 
  1583. although quite a bit more complicated, has the advantage of not having any 
  1584. busy-waiting threads.
  1585.  
  1586. If you have CodeWarrior, DR/3 includes some PowerPlant classes for 
  1587. implementing threads.  They let you do thread-blocking I/O relatively 
  1588. painlessly.  You also get some semaphore classes and a class for inter-
  1589. thread communication.
  1590.  
  1591. Paul Lalonde
  1592. paul@architecture.mcgill.ca
  1593.  
  1594. +++++++++++++++++++++++++++
  1595.  
  1596. >From rmah@panix.com (Robert S. Mah)
  1597. Date: Sun, 22 May 1994 22:42:45 -0500
  1598. Organization: One Step Beyond
  1599.  
  1600. qmot@cs.mcgill.ca (Thomas PUSHPATHADAM) wrote:
  1601.  
  1602. > rmah@panix.com (Robert S. Mah) wrote:
  1603. > > I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1604. > > as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1605. > > was wondering if anyone else has tried this.
  1606. > [stuff deleted]
  1607. > > So, while the I/O thread is always running, and does not sleep, thereby
  1608. > > hogging resources, does this incur _that_ much overhead?  I have a 
  1609. > > suspician that this would be more efficient than calling WaitNextEvent
  1610. > > (i.e. in a single threaded app) instead of Yield.  Or would it?
  1611. > Well, if you have several threads that are looping like the example above 
  1612. > (the technical term is "busy-waiting"), you may spend a lot of time just 
  1613. > switching contexts for no reason.  The technique illustrated in develop 17, 
  1614. > although quite a bit more complicated, has the advantage of not having any 
  1615. > busy-waiting threads.
  1616. > If you have CodeWarrior, DR/3 includes some PowerPlant classes for 
  1617. > implementing threads.  They let you do thread-blocking I/O relatively 
  1618. > painlessly.  You also get some semaphore classes and a class for inter-
  1619. > thread communication.
  1620.  
  1621. Ohhh, I can't wait for DR/3 to get to my hot little hands!
  1622.  
  1623. But...back to the theory.  What I've done currently is the following...
  1624.  
  1625. I/O Thread
  1626.   Async Call with FrontProcess completion
  1627.   while not finished
  1628.     YieldToAnyTask
  1629.   Do my stuff
  1630.  
  1631. FrontProcess completion
  1632.   SetFrontProcess to my process
  1633.  
  1634. This gives me very good throughput, but seems to be, like you said, hogging
  1635. lot's of CPU time -- well more than chained async I/O calls anyway.  .
  1636.  
  1637. Are there any other techniques?  Why can't one just do the following...
  1638.  
  1639. I/O Thread
  1640.   Async Call with no completion
  1641.   if doneFlag is true
  1642.      Sleep this thread
  1643.   Do my stuff
  1644.  
  1645. Wakeup completion
  1646.   Wakeup completion thread
  1647.   set doneFlag to true
  1648.  
  1649. Can one get a deadlock situation with this?  I don't see how.  Or is it 
  1650. really bad to wakeup a thread that isn't asleep?
  1651.  
  1652. Cheers,
  1653. Rob
  1654. ___________________________________________________________________________
  1655. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1656.  
  1657. +++++++++++++++++++++++++++
  1658.  
  1659. >From Manuel Veloso <veloso@netcom.com>
  1660. Date: Mon, 23 May 1994 03:01:44 GMT
  1661. Organization: Ibex Productions
  1662.  
  1663. In article <2rmenh$8bt@inferno.mpx.com.au> Stephen F Coy, stevec@jolt.mpx.com.au writes:
  1664. >I have been using the second method you described above for some time 
  1665. >now, both with the original threads package and the new stuff. Sure, you 
  1666. >get a lot of thread swapping, but this is pretty cheap these days.
  1667. >
  1668. >The technique described in Develop seems like a lot of trouble to me. I 
  1669. >would love to see someone justify it. (That is, I want to know the 
  1670. >technical reasons why it should be done that way.)
  1671.  
  1672. Maybe it's one of those examples that's a bit too complicated, but illustrated
  1673. the point of sleep/wake. If the routine in question required that there
  1674. be some kind of completion routine (like ADSP or MacTCP) for handling
  1675. callbacks/parameters, the yield() method wouldn't work. Maybe also
  1676. if you were doing a socket listener, etc.
  1677.  
  1678. Still, for async IO that doesn't require a completion routine, way #2
  1679. is a whole lot easier.
  1680.  
  1681. +++++++++++++++++++++++++++
  1682.  
  1683. >From rmah@panix.com (Robert S. Mah)
  1684. Date: Mon, 23 May 1994 07:04:10 -0500
  1685. Organization: One Step Beyond
  1686.  
  1687. Manuel Veloso <veloso@netcom.com> wrote:
  1688.  
  1689. > Maybe it's one of those examples that's a bit too complicated, but illustrated
  1690. > the point of sleep/wake. If the routine in question required that there
  1691. > be some kind of completion routine (like ADSP or MacTCP) for handling
  1692. > callbacks/parameters, the yield() method wouldn't work. Maybe also
  1693. > if you were doing a socket listener, etc.
  1694. > Still, for async IO that doesn't require a completion routine, way #2
  1695. > is a whole lot easier.
  1696.  
  1697. Oh, the develop example isn't so much because of a completion routine
  1698. requirement as much as a problem with trying to sleep a thread after the
  1699. async routine completes.
  1700.  
  1701. The basic idea behind the develop article is to...
  1702.  
  1703. 1. Start the async routine
  1704. 2. Sleep this thread
  1705. ...
  1706. 3. Wake the thread from the completion routine.
  1707.  
  1708. Note, that, as Anderson & Post put it, "there is a window of misfortune 
  1709. after the thread makes the asynchronous call and before it completes the
  1710. sleep call"  I.e. you're completion can fire off between #1 and #2.  So 
  1711. you wake, then you sleep and never awake.
  1712.  
  1713. Cheers,
  1714. Rob
  1715. ___________________________________________________________________________
  1716. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1717.  
  1718. +++++++++++++++++++++++++++
  1719.  
  1720. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1721. Date: 23 May 1994 13:54:54 GMT
  1722. Organization: Microplex Pty Ltd
  1723.  
  1724. Manuel Veloso (veloso@netcom.com) wrote:
  1725. : In article <2rmenh$8bt@inferno.mpx.com.au> Stephen F Coy, stevec@jolt.mpx.com.au writes:
  1726. : >I have been using the second method you described above for some time 
  1727. : >now, both with the original threads package and the new stuff. Sure, you 
  1728. : >get a lot of thread swapping, but this is pretty cheap these days.
  1729. : >
  1730. : >The technique described in Develop seems like a lot of trouble to me. I 
  1731. : >would love to see someone justify it. (That is, I want to know the 
  1732. : >technical reasons why it should be done that way.)
  1733.  
  1734. : Maybe it's one of those examples that's a bit too complicated, but illustrated
  1735. : the point of sleep/wake. If the routine in question required that there
  1736. : be some kind of completion routine (like ADSP or MacTCP) for handling
  1737. : callbacks/parameters, the yield() method wouldn't work. Maybe also
  1738. : if you were doing a socket listener, etc.
  1739.  
  1740. But these are the exact places that I have been using the yield technique!
  1741. I can't think of ANY part of the Mac OS that REQUIRES a completion 
  1742. routine to perform async I/O. (I am of course willing to be corrected 
  1743. here :) ).
  1744.  
  1745. Typically, the yield loop polls the ioresult field of the parameter block 
  1746. until it is not 1.
  1747.  
  1748.  
  1749. : Still, for async IO that doesn't require a completion routine, way #2
  1750. : is a whole lot easier.
  1751.  
  1752. - ----
  1753. Steve Coy
  1754.  
  1755.  
  1756. +++++++++++++++++++++++++++
  1757.  
  1758. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1759. Date: Wed, 25 May 1994 19:20:09 GMT
  1760. Organization: Apple Computer
  1761.  
  1762. In article <rmah-210594031419@rmah.dialup.access.net> Robert S. Mah,
  1763. rmah@panix.com writes:
  1764. > So, while the I/O thread is always running, and does not sleep, thereby
  1765. > hogging resources, does this incur _that_ much overhead?
  1766.  
  1767. Isn't 50% of your CPU time spent in pre-emptive threads, if any are ready to
  1768. run? This implies that the Thread Manager will make sure your app spends
  1769. exactly 50% of its time in that little wait loop. (Disclaimer: I have not
  1770. used the Thread Manager, but I've read the documentation closely...)
  1771.  
  1772. --Jens Alfke
  1773.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1774.             .apple.com              Rebel girl you are the queen of my world
  1775.  
  1776. +++++++++++++++++++++++++++
  1777.  
  1778. >From rmah@panix.com (Robert S. Mah)
  1779. Date: Wed, 25 May 1994 20:13:31 -0500
  1780. Organization: One Step Beyond
  1781.  
  1782. Jens Alfke <jens_alfke@powertalk.apple.com> wrote:
  1783.  
  1784. > Robert S. Mah, rmah@panix.com writes:
  1785. > > So, while the I/O thread is always running, and does not sleep, 
  1786. > > thereby hogging resources, does this incur _that_ much overhead?
  1787. > Isn't 50% of your CPU time spent in pre-emptive threads, if any are 
  1788. > ready to run? This implies that the Thread Manager will make sure your  
  1789. > app spends exactly 50% of its time in that little wait loop. 
  1790. > (Disclaimer: I have not used the Thread Manager, but I've read the
  1791. > documentation closely...)
  1792.  
  1793. I'm not using pre-emptive threads since they don't work on the PowerMac's.
  1794. And you're _almost_ right.  Pre-emptive threads get 50% of you're
  1795. application's timeslice, not 50% of the CPU since the "pre-emptive" threads
  1796. only pre-empt when your app is awake.  Or did you mean that and I'm read-
  1797. ing you wrong...hmm...
  1798.  
  1799. Anyway, my main thing now is a search for good a profiling tool that 
  1800. measures the load on the system by each process.  This will help my quest
  1801. for multi-threaded efficiency immeasurably.
  1802.  
  1803. Cheers,
  1804. Rob
  1805. ___________________________________________________________________________
  1806. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1807.  
  1808. +++++++++++++++++++++++++++
  1809.  
  1810. >From jlscott@tigr.org (John L. Scott)
  1811. Date: Tue, 31 May 1994 14:41:07 GMT
  1812. Organization: Self
  1813.  
  1814. In article <rmah-220594224245@rmah.dialup.access.net>, rmah@panix.com
  1815. (Robert S. Mah) wrote:
  1816.  
  1817. > qmot@cs.mcgill.ca (Thomas PUSHPATHADAM) wrote:
  1818. > Are there any other techniques?  Why can't one just do the following...
  1819. > I/O Thread
  1820. >   Async Call with no completion
  1821. >   if doneFlag is true
  1822. >      Sleep this thread
  1823. >   Do my stuff
  1824. > Wakeup completion
  1825. >   Wakeup completion thread
  1826. >   set doneFlag to true
  1827. > Can one get a deadlock situation with this?  I don't see how.  Or is it 
  1828. > really bad to wakeup a thread that isn't asleep?
  1829.  
  1830.  
  1831. Welcome to the headachy world of concurrent programming.  If it can
  1832. preempt, it will preempt.
  1833.  
  1834.  Async Call WITH completion
  1835.  if doneFlag is FALSE
  1836.                                   <---- Completion routine happens here
  1837.    Sleep this thread
  1838.  Do my stuff
  1839.  
  1840. If your code is interrupted AFTER the conditional but BEFORE the sleep
  1841. call, you will sleep forever.  That is a very small window of opportunity,
  1842. but it will eventually happen.  As far as I know, there are no other
  1843. solutions other than busy-waiting or using a second thread as in Develop
  1844. 17.
  1845.  
  1846. --John L. Scott
  1847.  
  1848. +++++++++++++++++++++++++++
  1849.  
  1850. >From eastman@bnr.ca (Gordon Eastman)
  1851. Date: Tue, 31 May 1994 21:36:53 GMT
  1852. Organization: Bell-Northern Research
  1853.  
  1854. In article <jlscott-310594094108@jlscott.tigr.org>, jlscott@tigr.org (John
  1855. L. Scott) wrote:
  1856.  
  1857. > Welcome to the headachy world of concurrent programming.  If it can
  1858. > preempt, it will preempt.
  1859. >  Async Call WITH completion
  1860. >  if doneFlag is FALSE
  1861. >                                   <---- Completion routine happens here
  1862. >    Sleep this thread
  1863. >  Do my stuff
  1864. > If your code is interrupted AFTER the conditional but BEFORE the sleep
  1865. > call, you will sleep forever.  That is a very small window of opportunity,
  1866. > but it will eventually happen.  As far as I know, there are no other
  1867. > solutions other than busy-waiting or using a second thread as in Develop
  1868. > 17.
  1869. > --John L. Scott
  1870.  
  1871. Here is another solution. 
  1872.  
  1873. >From the completion routine, check the state of the thread. If it is
  1874. sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1875. install a time manager task that triggers in a bit and try again.
  1876.  
  1877. I have done this successfully, and see with my Code Warrior DR/3 CD that
  1878. arrived today that the PowerPlant thread class library also uses this
  1879. technique.
  1880.  
  1881. -- Gord
  1882.  
  1883. +++++++++++++++++++++++++++
  1884.  
  1885. >From rmah@panix.com (Robert S. Mah)
  1886. Date: Wed, 01 Jun 1994 10:25:27 -0500
  1887. Organization: One Step Beyond
  1888.  
  1889. eastman@bnr.ca (Gordon Eastman) wrote:
  1890.  
  1891. > From the completion routine, check the state of the thread. If it is
  1892. > sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1893. > install a time manager task that triggers in a bit and try again.
  1894. > I have done this successfully, and see with my Code Warrior DR/3 CD that
  1895. > arrived today that the PowerPlant thread class library also uses this
  1896. > technique.
  1897.  
  1898. Better be careful there.  If I understand you correctly, you're saying
  1899. do this...
  1900.  
  1901. I/O Thread
  1902.   Async call with completion
  1903.   Sleep this thread
  1904.  
  1905. Completion
  1906.   if I/O Thread is asleap
  1907.     Wake I/O Thread
  1908.  
  1909. Potentially, the completion routine could fire before you sleep the I/O
  1910. thread.  This means that the I/O thread will sleep forever!  Not much 
  1911. chance, but it could happen.  This was precisely the problem that the
  1912. example in develop 17 (the one that uses a wake up thread) was supposed
  1913. to solve.
  1914.  
  1915. Cheers,
  1916. Rob
  1917. ___________________________________________________________________________
  1918. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1919.  
  1920. +++++++++++++++++++++++++++
  1921.  
  1922. >From qmot@cs.mcgill.ca (Thomas PUSHPATHADAM)
  1923. Date: 1 Jun 1994 16:50:26 GMT
  1924. Organization: SOCS, McGill University, Montreal, Canada
  1925.  
  1926. (*** Posting from borrowed account ***)
  1927.  
  1928. rmah@panix.com (Robert S. Mah) wrote:
  1929.  
  1930. > eastman@bnr.ca (Gordon Eastman) wrote:
  1931.  
  1932. > > From the completion routine, check the state of the thread. If it is
  1933. > > sleeping, wake it. Otherwise you hit that small window of misfortune,
  1934. > > so
  1935. > > install a time manager task that triggers in a bit and try again.
  1936. > >
  1937. > > I have done this successfully, and see with my Code Warrior DR/3 CD
  1938. > > that
  1939. > > arrived today that the PowerPlant thread class library also uses this
  1940. > > technique.
  1941.   
  1942. > Better be careful there.  If I understand you correctly, you're saying
  1943. > do this...
  1944.    
  1945. >  I/O Thread
  1946. >    Async call with completion
  1947. >    Sleep this thread
  1948. >
  1949. >  Completion
  1950. >    if I/O Thread is asleap
  1951. >      Wake I/O Thread
  1952. > Potentially, the completion routine could fire before you sleep the I/O
  1953. > thread.  This means that the I/O thread will sleep forever!  Not much
  1954. > chance, but it could happen.  This was precisely the problem that the
  1955. > example in develop 17 (the one that uses a wake up thread) was supposed
  1956. > to solve.
  1957.  
  1958. Actually, I think he meant to do this:
  1959.  
  1960. I/O thread
  1961.   async call with completion
  1962.   sleep thread
  1963.  
  1964. Completion routine
  1965.   if I/O thread is asleep
  1966.     wake I/O thread
  1967.   else
  1968.     install time manager task with same completion routine
  1969.  
  1970. In this way, if the completion routine executes before the I/O thread
  1971. has been put to sleep, the completion routine just arranged to regain 
  1972. control after a small delay.  This is precisely the method used in the 
  1973. threads classes in PowerPlant.
  1974.  
  1975. Strictly speaking, this is a form of busy waiting.  However, the time 
  1976. window within which the busy waiting occurs is very small, assuming 
  1977. you don't something like call WaitNextEvent between the async call 
  1978. and the sleep call.
  1979.  
  1980. Cheers,
  1981. Paul Lalonde
  1982. paul@architecure.mcgill.ca
  1983.  
  1984.  
  1985. +++++++++++++++++++++++++++
  1986.  
  1987. >From eastman@bnr.ca (Gord Eastman)
  1988. Date: Wed, 1 Jun 1994 16:23:21 GMT
  1989. Organization: Bell-Northern Research
  1990.  
  1991. In article <rmah-010694102527@rmah.dialup.access.net>, rmah@panix.com
  1992. (Robert S. Mah) wrote:
  1993.  
  1994. > eastman@bnr.ca (Gordon Eastman) wrote:
  1995. > > From the completion routine, check the state of the thread. If it is
  1996. > > sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1997. > > install a time manager task that triggers in a bit and try again.
  1998. > > 
  1999. > > I have done this successfully, and see with my Code Warrior DR/3 CD that
  2000. > > arrived today that the PowerPlant thread class library also uses this
  2001. > > technique.
  2002. > Better be careful there.  If I understand you correctly, you're saying
  2003. > do this...
  2004. > I/O Thread
  2005. >   Async call with completion
  2006. >   Sleep this thread
  2007. > Completion
  2008. >   if I/O Thread is asleap
  2009. >     Wake I/O Thread
  2010. > Potentially, the completion routine could fire before you sleep the I/O
  2011. > thread.  This means that the I/O thread will sleep forever!  Not much 
  2012. > chance, but it could happen.  This was precisely the problem that the
  2013. > example in develop 17 (the one that uses a wake up thread) was supposed
  2014. > to solve.
  2015.  
  2016. And the precise problem that the time manager task solves. You seem to have
  2017. missed the "Otherwise" sentence of my post.The completion routine would be:
  2018.  
  2019. if I/O Thread is asleep
  2020.   Wake I/O Thread
  2021. else
  2022.   Install Time Manager task
  2023.  
  2024. When the Time Manager task fires,
  2025. if I/O Thread is asleep
  2026.   Wake I/O Thread
  2027. else
  2028.   reinstall Time Manager task
  2029.  
  2030. -- Gord
  2031.  
  2032.     
  2033.  
  2034. +++++++++++++++++++++++++++
  2035.  
  2036. >From rmah@panix.com (Robert S. Mah)
  2037. Date: Wed, 01 Jun 1994 19:47:34 -0500
  2038. Organization: One Step Beyond
  2039.  
  2040. eastman@bnr.ca (Gord Eastman) wrote:
  2041.  
  2042. > And the precise problem that the time manager task solves. You seem to have
  2043. > missed the "Otherwise" sentence of my post.The completion routine would be:
  2044.  
  2045. Oops...sorry about that.  I'll endevour to be more attentive next time :-)
  2046.  
  2047. Cheers,
  2048. Rob
  2049. ___________________________________________________________________________
  2050. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  2051.  
  2052. ---------------------------
  2053.  
  2054. End of C.S.M.P. Digest
  2055. **********************
  2056.  
  2057.  
  2058.