home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oclsrc15.zip / OCL / Include / OThread.hpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  4KB  |  122 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OThread.hpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30. // $Header: W:/Projects/OCL/Include/rcs/OThread.hpp 1.50 1996/08/11 23:47:33 B.STEIN Release $
  31.  
  32. #ifndef OTHREAD_INCLUDED
  33.   #define OTHREAD_INCLUDED
  34.  
  35. #ifndef OTHREADBASE_INCLUDED
  36.   #include <OThreadBase.hpp>
  37. #endif
  38.  
  39.  
  40. #ifdef __IBMCPP__
  41.   typedef VOID (_Optlink OThread_mbrfn)(PVOID);
  42. #elif __BCPLUSPLUS__
  43.   typedef VOID (_USERENTRY OThread_mbrfn)(PVOID);
  44. #elif __WATCOM_CPLUSPLUS__
  45.   typedef VOID (OThread_mbrfn)(PVOID);
  46. #elif __HIGHC__
  47.   typedef VOID (OThread_mbrfn)(PVOID);
  48. #elif __EMX__
  49.   typedef VOID (OThread_mbrfn)(PVOID);
  50. #endif
  51.  
  52.  
  53. #ifdef __WATCOM_CPLUSPLUS__
  54.   #define _WPPCAST_ __CPP_EXPORT__
  55. #else
  56.   #define _WPPCAST_
  57. #endif 
  58.  
  59.   
  60. #ifdef __IBMCPP__
  61.   typedef void ( _Optlink *OptlinkFnPtr ) ( void * );
  62. #endif
  63.  
  64.  
  65. typedef OThread_mbrfn     *pOThread_mbrfn;
  66. typedef class OThreadBase *pOThreadBase;
  67.  
  68.  
  69. template <class T>
  70. class OThread
  71.   : public OThreadBase
  72. {
  73.  private:
  74.  
  75.    void             (_WPPCAST_ T::*member)();
  76.    T*               object;
  77.    PFNTHREAD        threadFunc;
  78.    PVOID            pArgs;
  79.  
  80.  public:
  81.    OThread         (T* obj,                      // pointer to object
  82.                     void(_WPPCAST_ T::*mem)(),   // pointer to member-fn to detach
  83.                     ULONG stackSize = USHRT_MAX, // stacksize for thread
  84.                     BOOL  forPM = TRUE);         // initialize PM?
  85.  
  86.    OThread         (T& obj,                      // reference to object
  87.                     void(_WPPCAST_ T::*mem)(),   // pointer to member-fn to detach
  88.                     ULONG stackSize = USHRT_MAX, // stacksize for thread
  89.                     BOOL  forPM     = TRUE);     // initialize PM?
  90.  
  91.    OThread         (PFNTHREAD aFunction,
  92.                     ULONG stackSize = USHRT_MAX,
  93.                     BOOL  forPM     = TRUE,
  94.                     PVOID pvData    = NULL);
  95.  
  96.                     #ifdef __IBMCPP__
  97.    OThread         (OptlinkFnPtr aFunction,
  98.                     ULONG stackSize = USHRT_MAX,
  99.                     BOOL  forPM     = TRUE,
  100.                     PVOID pvData    = NULL);
  101.                     #endif
  102.  
  103.    virtual
  104.       ~OThread     ();
  105.  
  106.    virtual
  107.       PSZ isOfType () const;
  108.  
  109.    void async      ();
  110. };
  111.  
  112.  
  113. #ifdef __OCL_RESOLVE_TEMPLATES__
  114.   #include <OThread.inl>
  115. #endif
  116.  
  117.  
  118. #endif // OTHREAD_INCLUDED
  119.  
  120.  
  121. // end of source
  122.