home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11590 < prev    next >
Encoding:
Text File  |  1992-07-26  |  1.8 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!mama!greyham
  3. From: greyham@research.canon.oz.au (Graham Stoney)
  4. Subject: Re: How to have a member function as an ISR
  5. Message-ID: <Brv9Ku.25A@research.canon.oz.au>
  6. Sender: news@research.canon.oz.au
  7. Organization: Canon Information Systems Research Australia
  8. References: <emm.711411003@daneel.rdt.monash.edu.au> <1992Jul20.121028.16381@pegasus.com>
  9. Date: Fri, 24 Jul 1992 00:05:17 GMT
  10. Lines: 29
  11.  
  12. sean@pegasus.com (Sean Donovan) writes:
  13. >In article <emm.711411003@daneel.rdt.monash.edu.au> emm@daneel.rdt.monash.edu.au (Wendigo) writes:
  14. >>Does anybody know how to use a member function of a class as an
  15. >>Interrupt Service Routine using Borlanc C/C++ 3.0??
  16.  
  17. >First declare it as type interrupt.
  18.  
  19. >Second, write the equivalent of dos_setvec() for your class acception
  20. >a pointer to a member function of your class to install the vector.
  21.  
  22. >Third, call it.
  23.  
  24. >Optional step, generalize the concept and bubble it up to a base class, so
  25. >that you can reuse it.  This can get tricky with multiple inheritence
  26. >with a virtual base class. (actually it is garunteed to choke bcc 3.0)
  27.  
  28. This is more complex than necessary. The easy answer is: declare the member
  29. function as interrupt static, and just do the set_vect with it. Static
  30. members act just like C functions and hence have no this pointer. This is
  31. logically consistent since interrupt routines have no context. If the ISR
  32. needs to operate on an instance of the class, you must leave a global pointer
  33. around for it to use, and you can encapsulate this pointer in the class by
  34. making it static too. And yes, I've done this several times.
  35.  
  36. Graham
  37. -- 
  38. Graham Stoney                    | "a Perl script is correct if it's halfway
  39. Flip Dibner fan club, "Hi Flip!" |  readable and gets the job done before your
  40. Ph: +61 2 805-2909  Fax: -2929   |  boss fires you." L. Wall & R. Schwartz
  41.