casynthr.h
Upload User: dangjiwu
Upload Date: 2013-07-19
Package Size: 42019k
Code Size: 5k
Category:

Symbian

Development Platform:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: casynthr.h,v 1.1.1.1.50.3 2004/07/09 01:46:56 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #if !defined( __CASYNNETTHREAD_H )
  50. #define __CASYNNETTHREAD_H 
  51. class CHXMapPtrToPtr;
  52. class ThreadedConn;
  53. class HXMutex;
  54. class CAsyncNetThread 
  55. {
  56. public:
  57.     static CAsyncNetThread* GetCAsyncNetThreadNotifier(HINSTANCE hInst, 
  58.       BOOL Create = FALSE);
  59.     HX_RESULT AttachSocket(ThreadedConn* pSocket);
  60.     HX_RESULT DetachSocket(ThreadedConn* pSocket);
  61.     HWND GetWindowHandle(void) {return m_hWnd;};
  62. protected:
  63.     static ULONG32  GetSession();
  64.     CAsyncNetThread(HINSTANCE hInst);
  65.     BOOL     Create();
  66.     ~CAsyncNetThread();
  67.     BOOL IsValid()   {return m_bValid;};
  68.     void DecrementSocketsClientCount()
  69.     {
  70. if (m_nNumSocketsClients > 0)
  71. {
  72.     m_nNumSocketsClients--;
  73. }
  74.     }
  75.     void IncrementSocketsClientCount()
  76.     {
  77. m_nNumSocketsClients++;
  78.     }
  79.     // WndProc for our notifier
  80.     static LRESULT HXEXPORT AsyncNotifyProc(HWND hWnd, UINT msg, 
  81.     WPARAM wParam, LPARAM lParam);
  82.     LRESULT OnAsyncDNS(WPARAM wParam, LPARAM lParam);
  83.     LRESULT OnAsyncConnect(WPARAM wParam, LPARAM lParam);
  84.     LRESULT OnAsyncRead(WPARAM wParam, LPARAM lParam);
  85.     LRESULT OnAsyncWrite(WPARAM wParam, LPARAM lParam);
  86.     LRESULT OnAsyncAccept(WPARAM wParam, LPARAM lParam);
  87.     // cleanup if class is not used by any clients
  88.     LRESULT CheckClients();
  89.     // Linked list of US management functions
  90.     // Inserts us at the head of the list
  91.     static void LinkUs(CAsyncNetThread* pUs);
  92.     // Removes us from the list
  93.     static void UnlinkUs(CAsyncNetThread* pUs);
  94.     // Finds a notifier for the current thread in the linked list
  95.     static CAsyncNetThread* FindNetThreadNotifier();
  96.     /*
  97.      * Class private data members
  98.      */
  99.     // Don't try to register multiple times
  100.     static BOOL zm_bClassRegistered;
  101.     static CAsyncNetThread* zm_pSockNotifiers;
  102.     // Store the link in a nonstatic member
  103.     CAsyncNetThread* m_pNextNotifier;
  104.     HWND m_hWnd;
  105.     BOOL m_bValid;
  106.     // Win32 this is the thread ID, Win16 this is the current task
  107.     ULONG32 m_ulSession;
  108.     HINSTANCE m_hInst;
  109.     // Map that holds our client objects mapped from Socket Handles
  110.     CHXMapPtrToPtr* m_ClientSocketsMap;
  111.     UINT16 m_nNumSocketsClients;
  112.     BOOL m_bInCancelMode;
  113.     HXMutex* m_pThreadEngineMutex;
  114. private:
  115. #ifdef _WIN32
  116.     static UINT zm_uDestroyMessage;
  117. #endif
  118. };
  119. #endif /*__CASYNNETTHREAD_H */