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

Method WorkerProc

BeefySysLib/platform/win/Platform.cpp:823–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821 }
822
823 void WorkerProc()
824 {
825 while (true)
826 {
827 DWORD numBytes;
828 ULONG_PTR completionKey;
829 OVERLAPPED* overlapped;
830 int error = 0;
831 if (!::GetQueuedCompletionStatus(mIOCompletionPort, &numBytes, &completionKey, &overlapped, INFINITE))
832 {
833 error = GetLastError();
834 if ((error == ERROR_INVALID_HANDLE) || (error == ERROR_ABANDONED_WAIT_0))
835 break;
836 continue;
837 }
838
839 int32 keyFlags = (int32)completionKey & 3;
840 BfpOverlapped* bfpOverlapped = (BfpOverlapped*)(completionKey & ~3);
841
842 if (keyFlags == 0) // Normal
843 {
844 // Check to see if we have released this
845 {
846 AutoCrit autoCrit(mCritSect);
847 if (bfpOverlapped->mHandle == NULL)
848 continue;
849 }
850
851 if (numBytes == 0)
852 {
853 if (bfpOverlapped->mKind == BfpOverlappedKind_FileWatcher)
854 {
855 auto fileWatcher = (BfpFileWatcher*)bfpOverlapped;
856 if (fileWatcher->mHandle != NULL)
857 fileWatcher->Restart();
858 else
859 Kill(fileWatcher);
860 }
861 continue;
862 }
863
864 bfpOverlapped->Completed(error, numBytes, overlapped);
865 }
866 else if (keyFlags == 1)
867 {
868 if (bfpOverlapped == NULL)
869 break; // Normal shutdown
870
871 if (bfpOverlapped->mKind == BfpOverlappedKind_FileWatcher)
872 Kill((BfpFileWatcher*)bfpOverlapped);
873 }
874 }
875 }
876
877 static DWORD __stdcall WorkerProcThunk(void* _this)
878 {

Callers 1

WorkerProcThunkMethod · 0.45

Calls 2

RestartMethod · 0.80
CompletedMethod · 0.45

Tested by

no test coverage detected