sdkcreationmw/sdkruntimes/wsock/inc/WinsockSelectThread.h
changeset 0 b26acd06ea60
child 1 ac50fd48361b
equal deleted inserted replaced
-1:000000000000 0:b26acd06ea60
       
     1 /*
       
     2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _WSOCK_READ_THREAD_H_
       
    20 #define _WSOCK_READ_THREAD_H_
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 enum TSelectMask
       
    25 {
       
    26     ESelectRead  = 0x0001,
       
    27     ESelectWrite = 0x0002,
       
    28     ESelectError = 0x0004
       
    29 };
       
    30 
       
    31 class MSelectRequest
       
    32 {
       
    33 public:
       
    34     virtual TUint Socket() = 0;
       
    35     virtual TInt SelectMask() = 0;
       
    36     virtual void SelectComplete(TInt aMask) = 0;
       
    37 };
       
    38 
       
    39 class CWinsockSelectThread : public CBase
       
    40 {
       
    41 private:
       
    42     RCriticalSection iCriticalSection;
       
    43     RThread iThread;
       
    44     TBool iCriticalSectionCreated;
       
    45     RPointerArray<MSelectRequest> iRequests;
       
    46     TUint iUnblockSocket;
       
    47     struct timeval* iTimeout;
       
    48     union {
       
    49         struct sockaddr* iSockAddr;
       
    50         struct sockaddr_in* iSockAddrIn;
       
    51     } iAddr;
       
    52 
       
    53 public:
       
    54     static CWinsockSelectThread* Static();
       
    55     static CWinsockSelectThread& StaticL();
       
    56 
       
    57     TInt Submit(MSelectRequest* aRequest);
       
    58     TBool Cancel(MSelectRequest* aRequest);
       
    59 private:
       
    60     static CWinsockSelectThread* NewL();
       
    61     CWinsockSelectThread();
       
    62     virtual ~CWinsockSelectThread();
       
    63     void ConstructL();
       
    64     static TInt Run(TAny *aPtr);
       
    65     void RunL();
       
    66     TBool Wakeup();
       
    67 };
       
    68 
       
    69 #endif // _WSOCK_READ_THREAD_H_