void main() { int i; struct job j[60]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&j[i].id); scanf("%d",&j[i].profit); scanf("%d",&j[i].deadline); } JobSchedule(j); }
void IocpConstructor::ThreadFunction() { SOCKET sock; HANDLE hComPort = this->ComPort; ClientHandle tempHandle; Packet ReceivePacket; int Ty, DataSize, index; bool hasJob = false; while (1){ hasJob = GetQueuedCompletionStatus(hComPort, &(tempHandle.bytesTrans), (LPDWORD)&tempHandle.handleinfo, (LPOVERLAPPED*)&(tempHandle.ioinfo), 30); if (hasJob){ sock = tempHandle.handleinfo->ClntSock; index = IocpConstructor::Object_Manager->FIND_USER(sock); //if (index == -1) 예외처리하기 std::shared_ptr<USER> User = std::static_pointer_cast<USER>(IocpConstructor::Object_Manager->FIND(index)); if (tempHandle.ioinfo->rwMode == READ) { //접속종료에 대한 완료 통지 if (tempHandle.bytesTrans == 0) { User->ChangeState(USER::state::DISCONNECT); delete tempHandle.handleinfo; delete tempHandle.ioinfo; closeSocket(sock); /*TimerJob disConnectJob; disConnectJob.exectime = GetTickCount(); disConnectJob.func = std::bind(&IocpConstructor::closeSocket, this, sock); LOCKING(&this->queueLock) { this->jobs.push_back(disConnectJob); } User->ChangeState(USER::state::DISCONNECT);*/ continue; } ReceivePacket.PacketSeperate(tempHandle.ioinfo->wsaBuf.buf, tempHandle.bytesTrans, sock); delete tempHandle.ioinfo; tempHandle.ReadMode(); this->RecvMessage(tempHandle); } else if (tempHandle.ioinfo->rwMode == WRITE) { if (tempHandle.ioinfo->wsaBuf.len == tempHandle.bytesTrans) { delete tempHandle.ioinfo; } else{ printf("비정상 삭제\n"); } // //비정상으로 인지하고 종료함.. // else // { // sock = tempHandle.handleinfo->ClntSock; // index = IocpConstructor::Object_Manager->FIND_USER(sock); // //inf(index == -1) 예외처리하기 // std::shared_ptr<USER> User = std::static_pointer_cast<USER>(IocpConstructor::Object_Manager->FIND(index)); // TimerJob disConnectJob; // disConnectJob.exectime = GetTickCount(); // disConnectJob.func = std::bind(&IocpConstructor::closeSocket, this, sock); // LOCKING(this->queueLock) // { // this->jobs.push_back(disConnectJob); // } // User->ChangeState(USER::state::DISCONNECT); // } // } //} } } else { JobSchedule(); } } return; }