home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / Chapt_04 / Diver / Stack.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  1.6 KB  |  43 lines

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : stack.h                                                             //
  12. //  Description: Multithread-safe shared stack                                       //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KStack
  17. {
  18. #define MAXSTACKSIZE 256
  19. #define MAXTHREADNO  32
  20.  
  21.     int          nFree;
  22.     int          FreeCell;
  23.     KRoutineInfo Cell[MAXSTACKSIZE];
  24.  
  25.     CRITICAL_SECTION  cs;
  26.  
  27.     int          nThread;
  28.     
  29.     unsigned     Thread[MAXTHREADNO];
  30.     int          Tos   [MAXTHREADNO];
  31.     int          Depth [MAXTHREADNO];
  32.  
  33. public:
  34.     KStack();
  35.     ~KStack();
  36.         
  37.     int LookupThread(BOOL addifmissing);
  38.     KRoutineInfo * Push(void);
  39.     KRoutineInfo * Lookup(int & depth);
  40.     void Pop(void);
  41.  
  42. };
  43.