inline iWARPEM_Status_t FlushSendBuffer()
    {
        int wlen = 0;
        mNeedsBufferFlush = false;

        pthread_spin_lock( &mAccessLock );
        size_t DataLen = mSendBuffer->GetDataLen();
        if( DataLen == 0)
        {
            BegLogLine( FXLOG_IT_API_O_SOCKETS_MULTIPLEX_LOG )
                    << "Buffer is empty. Nothing to send."
                    << EndLogLine;
            pthread_spin_unlock( &mAccessLock );
            return IWARPEM_SUCCESS;
        }
        iWARPEM_Status_t status = mSendBuffer->FlushToSocket( mRouterConnFd, &wlen );
        BegLogLine( FXLOG_IT_API_O_SOCKETS_MULTIPLEX_LOG )
                << "Sent " << (int)(wlen)
                << " payload: " << mSendBuffer->GetDataLen()
                << " socket: " << mRouterConnFd
                << EndLogLine;

#ifdef MULTIPLEX_STATISTICS
        mFlushCount++;
        mMsgAvg = (mMsgAvg * 0.9997) + (mMsgCount * 0.0003);
        BegLogLine( ( (mFlushCount & 0xfff) == 0 ) )
                << "average message count per send buffer:" << mMsgAvg
                << EndLogLine;

#endif
        ResetSendBuffer();
        pthread_spin_unlock( &mAccessLock );

        return status;
    }
    iWARPEM_Multiplexed_Endpoint_t( int aRouterFd = 0,
                                    int aMaxClientCount = IT_API_MULTIPLEX_MAX_PER_SOCKET,
                                    iWARPEM_Object_Accept_t *aListenerCtx = NULL )
        : mClientCount(0), mRouterConnFd( aRouterFd ), mMaxClientCount( aMaxClientCount ),
          mReceiveDataLen( 0 ), mPendingRequests( 0 ), mNeedsBufferFlush( false )
    {
        bzero( &mRouterInfo, sizeof( iWARPEM_Router_Info_t ));

        mClientEPs = new MultiplexedConnectionType*[ aMaxClientCount ];
        bzero( mClientEPs, sizeof( MultiplexedConnectionType*) * aMaxClientCount );

        pthread_spin_init( &mAccessLock, PTHREAD_PROCESS_PRIVATE );
        mListenerContext = aListenerCtx;
        mSendBuffer = new SocketBufferType();
        mReceiveBuffer = new ReceiveBufferType();
        mReceiveBuffer->ConfigureAsReceiveBuffer();

        ResetSendBuffer();
        ResetRecvBuffer();

        BegLogLine( FXLOG_IT_API_O_SOCKETS_MULTIPLEX_LOG )
                << "Creating multiplexed router endpoint..."
                << " socket: " << mRouterConnFd
                << " maxClients: " << aMaxClientCount
                << " BufferSizes: " << IT_API_MULTIPLEX_SOCKET_BUFFER_SIZE
                << " Recv: @" << (void*)mReceiveBuffer
                << " Send: @" << (void*)mSendBuffer
                << EndLogLine;
#ifdef MULTIPLEX_STATISTICS
        mMsgCount = 0;
        mFlushCount = 0;
        mMsgAvg = 1.0;
#endif
    }
Exemple #3
0
void XInstrument::ShowComStatus() {
	gotoxy(55,15);textattr(0x05);cprintf("LSR=%2X",lsr);
	gotoxy(55,16);textattr(0x06);cprintf("MSR=%2X",msr);
	gotoxy(55,17);
	if((msr&DSR)==0) {
		textattr(0x84);
		ResetSendBuffer();
		ResetCommandBuffer();
		//RenewError();
		cprintf("Disconnected!");
	}
	else {
		textattr(0x02);
		cprintf("Connected!   ");
	}
}