OpenBarnyard
 
Loading...
Searching...
No Matches
Toshi::T2NamedPipeServerThread Class Reference

#include <T2NamedPipeServer_Win.h>

Inheritance diagram for Toshi::T2NamedPipeServerThread:
TThread T2GenericDList::Node

Public Member Functions

 T2NamedPipeServerThread (T2NamedPipeServer *a_pServer)
 
virtual void Main () override
 
- Public Member Functions inherited from TThread
virtual ~TThread ()
 
TBOOL Create (size_t a_iStackSize, PRIORITY a_ePriority, TUINT8 a_eFlags)
 
TBOOL Destroy ()
 
- Public Member Functions inherited from T2GenericDList::Node
constexpr Node ()
 
 ~Node ()
 
TBOOL IsLinked () const
 
void InsertBefore (Node *pInsertBefore)
 
void InsertAfter (Node *pInsertAfter)
 
void Remove ()
 
NodeNext () const
 
NodePrev () const
 

Additional Inherited Members

- Public Types inherited from TThread
enum  PRIORITY_ : PRIORITY {
  THREAD_MODE_BACKGROUND_BEGIN = 0x00010000 , THREAD_MODE_BACKGROUND_END = 0x00020000 , THREAD_PRIORITY_ABOVE_NORMAL = 1 , THREAD_PRIORITY_BELOW_NORMAL = -1 ,
  THREAD_PRIORITY_HIGHEST = 2 , THREAD_PRIORITY_IDLE = -15 , THREAD_PRIORITY_LOWEST = -2 , THREAD_PRIORITY_NORMAL = 0 ,
  THREAD_PRIORITY_TIME_CRITICAL = 15
}
 
typedef TINT PRIORITY
 
- Static Public Member Functions inherited from TThread
static TBOOL GetPriority (void *a_hThreadHnd, PRIORITY &a_ePriority)
 
static TBOOL SetPriority (void *a_hThreadHnd, PRIORITY a_ePriority)
 
static void Exit (TThread *a_pThread)
 
- Public Attributes inherited from TThread
void * m_hThreadHnd
 
unsigned long m_iThreadID
 
- Protected Attributes inherited from T2GenericDList::Node
friend T2GenericDList
 

Detailed Description

Definition at line 11 of file T2NamedPipeServer_Win.h.

Constructor & Destructor Documentation

◆ T2NamedPipeServerThread()

Toshi::T2NamedPipeServerThread::T2NamedPipeServerThread ( T2NamedPipeServer * a_pServer)

Definition at line 14 of file T2NamedPipeServer_Win.cpp.

15 : m_pServer( a_pServer )
16{
17}

Member Function Documentation

◆ Main()

void Toshi::T2NamedPipeServerThread::Main ( )
overridevirtual

Implements TThread.

Definition at line 19 of file T2NamedPipeServer_Win.cpp.

20{
21 while ( TTRUE )
22 {
23 TBOOL bHasClient = TTRUE;
24
25 if ( ConnectNamedPipe( m_pServer->m_hPipe, NULL ) == FALSE )
26 {
27 auto iErr = GetLastError();
28
29 if ( iErr == ERROR_NO_DATA )
30 {
31 DisconnectNamedPipe( m_pServer->m_hPipe );
32 TTRACE( "A client has disconnected from the '%s' named pipe\n", m_pServer->m_szName );
33 m_pServer->m_bHasClient = TFALSE;
34 bHasClient = TFALSE;
35 }
36 else if ( iErr != ERROR_PIPE_CONNECTED )
37 {
38 TASSERT( TFALSE, "Failed ConnectNamedPipe" );
39 bHasClient = TFALSE;
40 }
41 }
42
43 if ( bHasClient )
44 {
45 if ( m_pServer->m_bHasClient == TFALSE )
46 {
47 TTRACE( "A client has connected to the '%s' named pipe\n", m_pServer->m_szName );
48 m_pServer->m_bHasClient = TTRUE;
49 }
50
51 if ( m_pServer->m_fnUpdateStream )
52 {
53 m_pServer->m_fnUpdateStream( m_pServer->m_pMemory, m_pServer->m_uiMemorySize, m_pServer->m_pUserData );
54 }
55
56 if ( m_pServer->m_pMemory && m_pServer->m_uiMemorySize > 0 )
57 {
58 WriteFile(
59 m_pServer->m_hPipe,
60 m_pServer->m_pMemory,
61 m_pServer->m_uiMemorySize,
62 NULL,
63 NULL
64 );
65 }
66 }
67
68 ThreadSleep( m_pServer->m_uiSendInterval );
69 }
70}
#define TASSERT(X,...)
Definition Defines.h:138
#define TTRACE(...)
Definition Defines.h:155
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
void ThreadSleep(TUINT dwMilliseconds)

The documentation for this class was generated from the following files: