void FreeQueue(Queue** ApQ) { ClearQueue(*ApQ); free(*ApQ); *ApQ = NULL; }
McuMessageHandler::~McuMessageHandler() { DestroyTimer(m_retryTimer); if(m_passengerRecord) { for(int i = 0; i < m_pos_num; i ++) { DestroyTimer(m_passengerRecord[i].posPassengerRecordTimer); } } delete []m_passengerRecord; ClearQueue(); ClearRxPacket(); pthread_mutex_lock(&m_dealRecordMutex); if(m_record_fd >= 0) { close(m_record_fd); m_record_fd = -1; } pthread_mutex_unlock(&m_dealRecordMutex); pthread_mutex_lock(&m_candataMutex); if(m_can_fd >= 0) { close(m_can_fd); m_can_fd = -1; } pthread_mutex_unlock(&m_candataMutex); pthread_mutex_destroy(&m_queueMutex); pthread_mutex_destroy(&m_packetMutex); pthread_mutex_destroy(&m_dealRecordMutex); pthread_mutex_destroy(&m_candataMutex); }
void Missile::Spawn(Vector2 pos) { transform->position = pos; mPoints.clear(); ClearQueue(); mT = 0; float dist = (Input::mousePosition - pos).Magnitude(); // Set path points mPath.push(pos); for (int i = 0; i < 2; ++i) { float randX = rand() % (int)(dist * 0.5f) - dist * 0.25f; float randY = (float)(rand() % (int)(dist * 0.5f)); Vector2 p = Vector2(randX, randY) + pos; mPath.push(p); } mPath.push(Input::mousePosition); for (int i = 0; i < 4; ++i) { mPoints.push_back(mPath.front()); mPath.pop(); } mDist = Math::GetBezierDistance(mPoints); SetActive(true); }
void CSounds::OnInit() { // setup sound channels m_MapSoundVolume = g_Config.m_SndMapSoundVolume/100.0f; Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f); Sound()->SetChannel(CSounds::CHN_MUSIC, 1.0f, 0.0f); Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f); Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f); Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f); Sound()->SetListenerPos(0.0f, 0.0f); ClearQueue(); // load sounds if(g_Config.m_ClThreadsoundloading) { m_pSoundJob = std::make_shared<CSoundLoading>(m_pClient, false); m_pClient->Engine()->AddJob(m_pSoundJob); m_WaitForSoundJob = true; } else { CSoundLoading(m_pClient, true).Run(); m_WaitForSoundJob = false; } }
CScriptQueueManager::~CScriptQueueManager() { ClearQueue() ; if(m_pNowCommand!=NULL) delete m_pNowCommand ; }
void main() { int i; QElemType d; LinkQueue q; InitQueue(&q); printf("成功地构造了一个空队列!\n"); printf("是否空队列?%d(1:空 0:否) ",QueueEmpty(q)); printf("队列的长度为%d\n",QueueLength(q)); EnQueue(&q,-5); EnQueue(&q,5); EnQueue(&q,10); printf("插入3个元素(-5,5,10)后,队列的长度为%d\n",QueueLength(q)); printf("是否空队列?%d(1:空 0:否) ",QueueEmpty(q)); printf("队列的元素依次为:"); QueueTraverse(q,print); i=GetHead_Q(q,&d); if(i==OK) printf("队头元素是:%d\n",d); DeQueue(&q,&d); printf("删除了队头元素%d\n",d); i=GetHead_Q(q,&d); if(i==OK) printf("新的队头元素是:%d\n",d); ClearQueue(&q); printf("清空队列后,q.front=%u q.rear=%u q.front->next=%u\n",q.front,q.rear,q.front->next); DestroyQueue(&q); printf("销毁队列后,q.front=%u q.rear=%u\n",q.front, q.rear); }
bool CTsNetworkSender::Close() { if (m_hSendThread) { m_EndSendingEvent.Set(); if (::WaitForSingleObject(m_hSendThread, 10000) == WAIT_TIMEOUT) { Trace(CTracer::TYPE_WARNING, TEXT("ネットワーク送信スレッドが応答しないため強制終了します。")); ::TerminateThread(m_hSendThread, -1); } ::CloseHandle(m_hSendThread); m_hSendThread=NULL; } m_EndSendingEvent.Close(); CBlockLock Lock(&m_DecoderLock); ClearQueue(); m_bEnableQueueing = false; for (auto i = m_SockList.begin(); i != m_SockList.end(); ++i) { if (i->Event != WSA_INVALID_EVENT) { if (i->sock != INVALID_SOCKET) ::WSAEventSelect(i->sock, NULL, 0); ::WSACloseEvent(i->Event); } if (i->sock != INVALID_SOCKET) { ::shutdown(i->sock, SD_BOTH); ::closesocket(i->sock); } ::FreeAddrInfo(i->AddrList); } m_SockList.clear(); return true; }
int main() { SeQueue Q; int data = 3, value; //0. Init InitQueue(Q); PrintQueue(Q); //1. Enter Queue printf("\n"); PrintQueue(Q); printf("EnQueue = %d\n", data); EnQueue(Q, data); PrintQueue(Q); //2. DeQueue printf("\n"); PrintQueue(Q); value = Front(Q); DeQueue(Q); printf("DeQueue value = %d\n", value); PrintQueue(Q); //3. Clear printf("\n"); PrintQueue(Q); printf("Clear Queue\n"); ClearQueue(Q); PrintQueue(Q); return 0; }
void CSounds::OnInit() { // setup sound channels Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f); Sound()->SetChannel(CSounds::CHN_MUSIC, 1.0f, 0.0f); Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f); Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f); Sound()->SetListenerPos(0.0f, 0.0f); ClearQueue(); // load sounds if(g_Config.m_ClThreadsoundloading) { g_UserData.m_pGameClient = m_pClient; g_UserData.m_Render = false; m_pClient->Engine()->AddJob(&m_SoundJob, LoadSoundsThread, &g_UserData); m_WaitForSoundJob = true; } else { g_UserData.m_pGameClient = m_pClient; g_UserData.m_Render = true; LoadSoundsThread(&g_UserData); m_WaitForSoundJob = false; } }
virtual ~ModuleSQLite3() { ClearQueue(); ClearAllConnections(); ServerInstance->SE->DelFd(listener); ServerInstance->BufferedSocketCull(); if (QueueFD >= 0) { shutdown(QueueFD, 2); close(QueueFD); } if (notifier) { ServerInstance->SE->DelFd(notifier); notifier->Close(); ServerInstance->BufferedSocketCull(); } ServerInstance->Modules->UnpublishInterface("SQL", this); ServerInstance->Modules->UnpublishFeature("SQL"); ServerInstance->Modules->DoneWithInterface("SQLutils"); }
void CSounds::OnReset() { if(Client()->State() >= IClient::STATE_ONLINE) { Sound()->StopAll(); ClearQueue(); } }
arp_entry::~arp_entry() { // make sure there is no active timer left for us sStackModule->cancel_timer(&timer); sStackModule->wait_for_timer(&timer); ClearQueue(); }
void arp_entry::MarkFailed() { TRACE(("ARP entry %p Marked as FAILED\n", this)); flags = (flags & ~ARP_FLAG_VALID) | ARP_FLAG_REJECT; ClearQueue(); }
void InfoPrinter::Print() { printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); for (unsigned int i = 0; i < queue.size(); i++) printf("%s", queue[i].c_str()); ClearQueue(); }
TEST_F(TestBufferQueue, testClearQueue) { for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) { SLuint32 numBuffers = validNumBuffers[i]; PrepareValidBuffer(numBuffers); EnqueueMaxBuffer(numBuffers); ClearQueue(); DestroyPlayer(); } }
void GSourceVoice::Stop() { if (_iscreated) { _source_voice->Stop(); _source_voice->FlushSourceBuffers(); ClearQueue(); } }
int main() { Status j; int i=0, l; QElemType d; SqQueue Q; InitQueue(&Q); printf("初始化队列后 队列是否为空%d 1:空 0:非空 \n", QueueEmpty(Q)); printf("请输入整型队列元素(不超过%d个), -1为提前结束标识符 \n", MAXSIZE-1); do { scanf("%d", &d); if (d == -1) break; EnQueue(&Q, d); i++; }while(i < MAXSIZE-1); printf("队列长度为: %d \n", QueueLength(Q)); printf("队列是否为空%d 1:空 0:非空 \n", QueueEmpty(Q)); printf("连续%d次从队首删除元素, 从队尾插入元素: \n", MAXSIZE); for(l = 1; l <= MAXSIZE; l++) { DeQueue(&Q, &d); printf("删除的元素是: %d 插入的元素是 %d \n", d, l+100); d = l + 100; EnQueue(&Q, d); } printf("现在队列中的元素为: \n"); QueueTraverse(Q); printf("共向队尾插入了 %d 个元素 \n", i+MAXSIZE); l = QueueLength(Q); if (l-2 > 0) printf("现在由队头开始删除 %d 个元素\n", l-2); while(QueueLength(Q) > 2) { DeQueue(&Q, &d); printf("删除的元素为 %d \n", d); } j = GetHead(Q, &d); if (j) printf("现在队首的元素为 %d \n", d); ClearQueue(&Q); printf("清空队列后队列是否为空%d 1:空 0:非空 \n", QueueEmpty(Q)); return 0; }
MHIContext::~MHIContext() { StopEngine(); delete(m_engine); delete(m_dsmcc); if (m_face_loaded) FT_Done_Face(m_face); ClearDisplay(); ClearQueue(); }
DMPAPI(void) usb_FlushTxQueue(void *vusb) { USB_Device *usb = (USB_Device *)vusb; if (usb == NULL) { err_print((char*)"%s: USB device is null.\n", __FUNCTION__); return; } io_DisableINT(); { ClearQueue(usb->xmit); } io_RestoreINT(); }
void sig_handle(int signum) { DEBUG_printf("receive signal :%d\n",signum); //SIGUSR1:pause;SIGUSR2:start; if(signum == SIGUSR1) { set_time(6000000,6000000); r_connect = 0; close(sockfd); ClearQueue(&Q_cmd);//clear the comdmand queue. ClearQueue(&Q_respond); } else if(signum == SIGUSR2) { ClearQueue(&Q_cmd);//clear the comdmand queue. ClearQueue(&Q_respond); set_time(30,30); tcp_state(); } }
void vSoundStreamProperties::Clear() { ClearQueue(); DefaultVolume(); DefaultEnabled(); DefaultWantedState(); DefaultState(); DefaultFormat(); DefaultFrequency(); DefaultLooping(); };
int main() { Status j; int i=0,l; QElemType d; SqQueue Q; InitQueue(&Q); printf("初始化队列后,队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("请输入整型队列元素(不超过%d个),-1为提前结束符: ",MAXSIZE-1); do { /* scanf("%d",&d); */ d=i+100; if(d==-1) break; i++; EnQueue(&Q,d); }while(i<MAXSIZE-1); printf("队列长度为: %d\n",QueueLength(Q)); printf("现在队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("连续%d次由队头删除元素,队尾插入元素:\n",MAXSIZE); for(l=1;l<=MAXSIZE;l++) { DeQueue(&Q,&d); printf("删除的元素是%d,插入的元素:%d \n",d,l+1000); /* scanf("%d",&d); */ d=l+1000; EnQueue(&Q,d); } l=QueueLength(Q); printf("现在队列中的元素为: \n"); QueueTraverse(Q); printf("共向队尾插入了%d个元素\n",i+MAXSIZE); if(l-2>0) printf("现在由队头删除%d个元素:\n",l-2); while(QueueLength(Q)>2) { DeQueue(&Q,&d); printf("删除的元素值为%d\n",d); } j=GetHead(Q,&d); if(j) printf("现在队头元素为: %d\n",d); ClearQueue(&Q); printf("清空队列后, 队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); return 0; }
JNIEXPORT void JNICALL Java_org_adblockplus_android_JSEngine_nativeRelease (JNIEnv *pEnv, jobject, jlong pContext) { D(D_WARN, "nativeRelease()"); ClearQueue(); if (pContext) { v8::Persistent<v8::Context> context((v8::Context *) pContext); context.Dispose(); } pEnv->DeleteGlobalRef(jniCallback); jniCallback = NULL; globalJvm = NULL; }
FTP::~FTP() { if(hConnect) { delete hConnect; hConnect = NULL; } FP_PeriodDestroy(KeepAlivePeriod); LongBeepEnd(TRUE); FP_Info->Control(this,FCTL_SETVIEWMODE,&StartViewMode); DeleteFromBackup(); ClearQueue(); }
void CContentDecoder::Close() { g_Log->Info( "Closing..." ); Stop(); ClearQueue(); Destroy(); m_spPlaylist = NULL; g_Log->Info( "closed..." ); }
int McuMessageHandler::ConnectionEventHandler(ENUM_SERIAL_CONNECTION_EVENT state) { LogUtility::Log(LOG_LEVEL_DEBUG, "McuMessageHandler::ConnectionEventHandler state %x.", (int)state); switch(state) { case ENUM_CONNECTION_STATE_OPENED: SendHandshake(); break; case ENUM_CONNECTION_STATE_BROKEN: StopTimer(m_retryTimer); ClearQueue(); ClearRxPacket(); m_handshake = false; break; default: break; } return 0; }
int main(int argc, char** argv) { int i,e,n; LinkQueue Q; printf("------------------------------------------------------\n"); printf("1.构造队列 2.插入元素\n"); printf("3.get队头元素 4.删除队头元素\n"); printf("5.清空队列 6.销毁队列\n"); printf("7.判断是否为空 8.退出程序\n"); printf("------------------------------------------------------\n"); while(1==1){ printf("请选择:"); scanf("%d",&i); switch(i){ case 1:InitQueue(Q); break; case 2:printf("请输入个数:"); scanf("%d",&n); printf("请输入数据:\n"); for(i=0;i<n;i++){ scanf("%d",&e); EnQueue(Q,e); } break; case 3:GetHead(Q,e); printf("队头元素是:%d\n",e); break; case 4:DeQueue(Q,e); printf("被删除的队头元素是:%d\n",e); break; case 5:ClearQueue(Q); break; case 6:DestoryQueue(Q); break; case 7:printf("若为空,则为1,否则为0\nresult=%d\n",QueueEmpty(Q)); break; case 8:exit(0); } } return 0; }
void main() { Status j; int i=0,m; QElemType d; SqQueue Q; InitQueue(Q); printf("初始化队列后,队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("请输入整型队列元素(不超过%d个),-1为提前结束符:",MAX_QSIZE-1); do { scanf("%d",&d); if(d==-1) break; i++; EnQueue(Q,d); } while(i<MAX_QSIZE-1); printf("队列长度为%d,",QueueLength(Q)); printf("现在队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("连续%d次由队头删除元素,队尾插入元素:\n",MAX_QSIZE); for(m=1; m<=MAX_QSIZE; m++) { DeQueue(Q,d); printf("删除的元素是%d,请输入待插入的元素:",d); scanf("%d",&d); EnQueue(Q,d); } m=QueueLength(Q); printf("现在队列中的元素为"); QueueTraverse(Q,print); printf("共向队尾插入了%d个元素。",i+MAX_QSIZE); if(m-2>0) printf("现在由队头删除%d个元素,",m-2); while(QueueLength(Q)>2) { DeQueue(Q,d); printf("删除的元素值为%d,",d); } j=GetHead(Q,d); if(j) printf("现在队头元素为%d\n",d); ClearQueue(Q); printf("清空队列后,队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); DestroyQueue(Q); }
void main() { Status j; int i,n; QElemType d; SqQueue Q; InitQueue(Q); printf("初始化队列后,队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("队列长度为:%d\n",QueueLength(Q)); printf("请输入队列元素个数n: "); scanf("%d",&n); printf("请输入%d个整型队列元素:\n",n); for(i=0;i<n;i++) { scanf("%d",&d); EnQueue(Q,d); } printf("队列长度为:%d\n",QueueLength(Q)); printf("现在队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); printf("现在队列中的元素为: \n"); QueueTraverse(Q,visit); DeQueue(Q,d); printf("删除队头元素%d\n",d); printf("队列中的元素为: \n"); QueueTraverse(Q,visit); j=GetHead(Q,d); if(j) printf("队头元素为: %d\n",d); else printf("无队头元素(空队列)\n"); ClearQueue(Q); printf("清空队列后, 队列空否?%u(1:空 0:否)\n",QueueEmpty(Q)); j=GetHead(Q,d); if(j) printf("队头元素为: %d\n",d); else printf("无队头元素(空队列)\n"); DestroyQueue(Q); }
already_AddRefed<MediaRawData> MediaCodecDataDecoder::PeekNextSample() { MonitorAutoLock lock(mMonitor); if (State() == kFlushing) { mDecoder->Flush(); ClearQueue(); State(kDecoding); lock.Notify(); return nullptr; } if (mQueue.empty()) { if (State() == kDrainQueue) { State(kDrainDecoder); } return nullptr; } // We're not stopping or flushing, so try to get a sample. return RefPtr<MediaRawData>(mQueue.front()).forget(); }