MCPcopy Create free account
hub / github.com/beefytech/Beef / ThreadProc

Method ThreadProc

BeefySysLib/util/BeefPerf.cpp:897–1382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895}
896
897void BpManager::ThreadProc()
898{
899 BfpThread_SetName(NULL, "BeefPerf", NULL);
900
901 if (!Connect())
902 {
903 mConnectState = BpConnectState_Failed;
904 LostConnection();
905 FinishWorkThread();
906 return;
907 }
908
909 Buffer threadBuffer;
910 String tempStr;
911 CircularBuffer::View outView;
912
913 timeval timeout;
914 timeout.tv_sec = 0;
915 timeout.tv_usec = 20 * 1000; // 20ms
916
917 uint32 gLastMsgTick = BFTickCount();
918
919 DWORD lastTimeTick = 0;
920
921 while (mConnectState != BpConnectState_NotConnected)
922 {
923 bool wantsExit = mShutdownEvent.WaitFor(0);
924
925 FD_SET socketReadSet;
926 FD_ZERO(&socketReadSet);
927 FD_SET(mSocket, &socketReadSet);
928
929 FD_SET socketWriteSet;
930 FD_ZERO(&socketWriteSet);
931 if (mOutBuffer.GetSize() > 0)
932 FD_SET(mSocket, &socketWriteSet);
933
934 FD_SET socketErrorSet;
935 FD_ZERO(&socketErrorSet);
936 FD_SET(mSocket, &socketErrorSet);
937
938 int selResult = select((int)mSocket + 1, &socketReadSet, &socketWriteSet, &socketErrorSet, &timeout);
939 if (FD_ISSET(mSocket, &socketWriteSet))
940 {
941 TrySendData();
942 //continue;
943 }
944 if (FD_ISSET(mSocket, &socketReadSet))
945 {
946 // Just eat the data
947 uint8 data[4096];
948 int len = recv(mSocket, (char*)data, 4096, 0);
949 int b = 0;
950 }
951 if (FD_ISSET(mSocket, &socketErrorSet))
952 {
953#ifdef BF_PLATFORM_WINDOWS
954 int err = WSAGetLastError();

Callers 1

ThreadProcThunkMethod · 0.45

Calls 15

GetTimestampFunction · 0.85
WaitForMethod · 0.80
MapViewMethod · 0.80
KeepAliveMethod · 0.80
EncodeSLEB128Function · 0.70
BfpThread_SetNameFunction · 0.50
BfpSystem_GetCPUTickFreqFunction · 0.50
GetSizeMethod · 0.45
GrowMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected