亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ou_thread.cpp

?? 基于omnet++開發的Mf框架下的802.11協議仿真。
?? CPP
字號:
/** ou_thread.cpp
  * implements the Thread class
  * Author: Vijay Mathew Pandyalakal
  * Date: 13-OCT-2003
**/

/* Copyright 2000 - 2005 Vijay Mathew Pandyalakal.  All rights reserved.
 *
 * This software may be used or modified for any purpose, personal or
 * commercial.  Open Source redistributions are permitted.  
 *
 * Redistributions qualify as "Open Source" under  one of the following terms:
 *   
 *    Redistributions are made at no charge beyond the reasonable cost of
 *    materials and delivery.
 *
 *    Redistributions are accompanied by a copy of the Source Code or by an
 *    irrevocable offer to provide a copy of the Source Code for up to three
 *    years at the cost of materials and delivery.  Such redistributions
 *    must allow further use, modification, and redistribution of the Source
 *    Code under substantially the same terms as this license.
 *
 * Redistributions of source code must retain the copyright notices as they
 * appear in each source code file, these license terms, and the
 * disclaimer/limitation of liability set forth as paragraph 6 below.
 *
 * Redistributions in binary form must reproduce this Copyright Notice,
 * these license terms, and the disclaimer/limitation of liability set
 * forth as paragraph 6 below, in the documentation and/or other materials
 * provided with the distribution.
 *
 * The Software is provided on an "AS IS" basis.  No warranty is
 * provided that the Software is free of defects, or fit for a
 * particular purpose.  
 *
 * Limitation of Liability. The Author shall not be liable
 * for any damages suffered by the Licensee or any third party resulting
 * from use of the Software.
 */

#include <string>
using namespace std;

#include <windows.h>

#include "ou_thread.h"
using namespace openutils;

const int Thread::P_ABOVE_NORMAL = THREAD_PRIORITY_ABOVE_NORMAL;
const int Thread::P_BELOW_NORMAL = THREAD_PRIORITY_BELOW_NORMAL;
const int Thread::P_HIGHEST = THREAD_PRIORITY_HIGHEST;
const int Thread::P_IDLE = THREAD_PRIORITY_IDLE;
const int Thread::P_LOWEST = THREAD_PRIORITY_LOWEST;
const int Thread::P_NORMAL = THREAD_PRIORITY_NORMAL;
const int Thread::P_CRITICAL = THREAD_PRIORITY_TIME_CRITICAL;

/**@ The Thread class implementation
**@/

/** Thread()
  * default constructor
**/  
Thread::Thread() {
	m_hThread = NULL;
	m_strName = "null";
}

/** Thread(const char* nm)
  * overloaded constructor
  * creates a Thread object identified by "nm"
**/  
Thread::Thread(const char* nm) {
	m_hThread = NULL;
	m_strName = nm;
}

Thread::~Thread() {
	if(m_hThread != NULL) {
		stop();
	}
}

/** setName(const char* nm)
  * sets the Thread object's name to "nm"
**/  
void Thread::setName(const char* nm) {	
	m_strName = nm;
}

/** getName()
  * return the Thread object's name as a string
**/  
string Thread::getName() const {	
	return m_strName;
}

/** run()
  * called by the thread callback _ou_thread_proc()
  * to be overridden by child classes of Thread
**/ 
void Thread::run() {
	// Base run
}

/** sleep(long ms)
  * holds back the thread's execution for
  * "ms" milliseconds
**/ 
void Thread::sleep(long ms) {
	Sleep(ms);
}

/** start()
  * creates a low-level thread object and calls the
  * run() function
**/ 
void Thread::start() {
	DWORD tid = 0;	
	m_hThread = (unsigned long*)CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)_ou_thread_proc,(Thread*)this,0,&tid);
	if(m_hThread == NULL) {
		throw ThreadException("Failed to create thread");
	}else {
		setPriority(Thread::P_NORMAL);
	}
}

/** stop()
  * stops the running thread and frees the thread handle
**/ 
void Thread::stop() {
	if(m_hThread == NULL) return;	
	WaitForSingleObject(m_hThread,INFINITE);
	CloseHandle(m_hThread);
	m_hThread = NULL;
}

/** setPriority(int tp)
  * sets the priority of the thread to "tp"
  * "tp" must be a valid priority defined in the
  * Thread class
**/ 
void Thread::setPriority(int tp) {
	if(m_hThread == NULL) {
		throw ThreadException("Thread object is null");
	}else {
		if(SetThreadPriority(m_hThread,tp) == 0) {
			throw ThreadException("Failed to set priority");
		}
	}
}

/** suspend()  
  * suspends the thread
**/ 
void Thread::suspend() {
	if(m_hThread == NULL) {
		throw ThreadException("Thread object is null");
	}else {
		if(SuspendThread(m_hThread) < 0) {
			throw ThreadException("Failed to suspend thread");
		}
	}
}

/** resume()  
  * resumes a suspended thread
**/ 
void Thread::resume() {
	if(m_hThread == NULL) {
		throw ThreadException("Thread object is null");
	}else {
		if(ResumeThread(m_hThread) < 0) {
			throw ThreadException("Failed to resume thread");
		}
	}
}

/** wait(const char* m,long ms)  
  * makes the thread suspend execution until the
  * mutex represented by "m" is released by another thread.
  * "ms" specifies a time-out for the wait operation.
  * "ms" defaults to 5000 milli-seconds
**/ 
bool Thread::wait(const char* m,long ms) {
	HANDLE h = OpenMutex(MUTEX_ALL_ACCESS,FALSE,m);
	if(h == NULL) {
		throw ThreadException("Mutex not found");
	}
	DWORD d = WaitForSingleObject(h,ms);
	switch(d) {
	case WAIT_ABANDONED:
		throw ThreadException("Mutex not signaled");
		break;
	case WAIT_OBJECT_0:
		return true;
	case WAIT_TIMEOUT:
		throw ThreadException("Wait timed out");
		break;
	}
	return false;
}

/** release(const char* m)  
  * releases the mutex "m" and makes it 
  * available for other threads
**/ 
void Thread::release(const char* m) {
	HANDLE h = OpenMutex(MUTEX_ALL_ACCESS,FALSE,m);
	if(h == NULL) {
		throw ThreadException("Invalid mutex handle");
	}
	if(ReleaseMutex(h) == 0) {
		throw ThreadException("Failed to release mutex");
	}
}

/**@ The Mutex class implementation
**@/

/** Mutex()
  * default constructor
**/  
Mutex::Mutex() {
	m_hMutex = NULL;
	m_strName = "";
}

/** Mutex(const char* nm)
  * overloaded constructor
  * creates a Mutex object identified by "nm"
**/  
Mutex::Mutex(const char* nm) {	
	m_strName = nm;	
	m_hMutex = (unsigned long*)CreateMutex(NULL,FALSE,nm);
	if(m_hMutex == NULL) {
		throw ThreadException("Failed to create mutex");
	}
}

/** create(const char* nm)
  * frees the current mutex handle.
  * creates a Mutex object identified by "nm"
**/  
void Mutex::create(const char* nm) {
	if(m_hMutex != NULL) {
		CloseHandle(m_hMutex);
		m_hMutex = NULL;
	}
	m_strName = nm;
	m_hMutex = (unsigned long*)CreateMutex(NULL,FALSE,nm);
	if(m_hMutex == NULL) {
		throw ThreadException("Failed to create mutex");
	}
}
/** getMutexHandle()
  * returns the handle of the low-level mutex object
**/  
unsigned long* Mutex::getMutexHandle() {
	return m_hMutex;
}

/** getName()
  * returns the name of the mutex
**/ 
string Mutex::getName() {
	return m_strName;
}

void Mutex::release() {
	if(m_hMutex != NULL) {
		CloseHandle(m_hMutex);
	}
}

Mutex::~Mutex() {
	/*if(m_hMutex != NULL) {
		CloseHandle(m_hMutex);
	}*/
}

// ThreadException
ThreadException::ThreadException(const char* m) {
	msg = m;
}

string ThreadException::getMessage() const {
	return msg;
}

// global thread caallback
unsigned int _ou_thread_proc(void* param) {
	Thread* tp = (Thread*)param;
	tp->run();
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日夜夜免费精品| 亚洲成人黄色小说| 久久久久久久久久电影| 精品久久久久久最新网址| 欧美一三区三区四区免费在线看| 欧美性猛片aaaaaaa做受| 欧美性感一区二区三区| 在线电影一区二区三区| 欧美成人精精品一区二区频| 日韩欧美国产综合在线一区二区三区| 欧美精品久久天天躁| 日韩视频一区在线观看| 精品成人佐山爱一区二区| 欧美精品一区二区三区在线播放| 久久在线免费观看| 国产精品久久久爽爽爽麻豆色哟哟| 337p日本欧洲亚洲大胆精品| 欧美国产日韩a欧美在线观看 | 亚洲r级在线视频| 午夜伦欧美伦电影理论片| 欧美a级理论片| 国产精品2024| av综合在线播放| 欧美三级视频在线| 精品精品国产高清a毛片牛牛| 久久精品视频在线免费观看| 亚洲免费观看高清| 日韩精品每日更新| 国产成人精品影院| 欧美日韩中文国产| 久久伊人中文字幕| 亚洲一区电影777| 韩国女主播成人在线| 成人免费视频国产在线观看| 欧美日本韩国一区二区三区视频 | 久久久久久97三级| 亚洲乱码中文字幕| 精品一区二区日韩| 色av一区二区| 精品国产成人系列| 亚洲男人的天堂av| 国产在线播放一区| 精品视频免费在线| 国产精品日日摸夜夜摸av| 石原莉奈在线亚洲二区| 91亚洲精品久久久蜜桃网站| 欧美videofree性高清杂交| 成人欧美一区二区三区小说| 黑人巨大精品欧美黑白配亚洲| 色哟哟一区二区| 久久久国产午夜精品| 男男视频亚洲欧美| 欧美亚洲禁片免费| 国产精品乱码一区二区三区软件| 日本在线不卡视频一二三区| 91免费国产在线| 久久影院视频免费| 蜜臀av在线播放一区二区三区| 色拍拍在线精品视频8848| 久久精品男人天堂av| 蜜桃91丨九色丨蝌蚪91桃色| 欧美午夜精品久久久久久孕妇| 中文字幕免费在线观看视频一区| 久久99精品国产麻豆婷婷| 欧美四级电影网| 亚洲精品视频免费看| 成人av免费观看| 国产精品久久久久四虎| 极品少妇xxxx精品少妇偷拍| 日韩一区二区不卡| 美女在线观看视频一区二区| 欧美日韩一区三区| 亚洲一区在线看| 欧美在线影院一区二区| 亚洲免费观看高清完整版在线观看| 成人在线综合网站| 国产精品热久久久久夜色精品三区| 黄页网站大全一区二区| 久久免费视频色| 国产成人综合网| 中文一区一区三区高中清不卡| 粉嫩aⅴ一区二区三区四区五区| 欧美精品一区二区三区蜜桃| 国产一区二区精品久久91| 久久精品欧美日韩| 成人黄色在线视频| 亚洲男人的天堂在线aⅴ视频| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲天堂2016| 欧美人妇做爰xxxⅹ性高电影| 美女视频网站黄色亚洲| 国产亚洲短视频| jlzzjlzz亚洲女人18| 亚洲一二三专区| 欧美一区二区福利在线| 国产成人精品一区二| 亚洲美女偷拍久久| 欧美一区二区三区视频在线 | 石原莉奈一区二区三区在线观看 | 亚洲欧洲成人精品av97| 在线视频中文字幕一区二区| 免费在线观看成人| 中文字幕不卡的av| 在线精品亚洲一区二区不卡| 日韩成人精品视频| 中文字幕av不卡| 欧美色精品在线视频| 国产专区欧美精品| 亚洲三级在线观看| 日韩欧美不卡在线观看视频| 成人免费毛片app| 日本三级亚洲精品| 国产精品国产三级国产aⅴ入口| 在线视频国内一区二区| 国产精品综合网| 午夜日韩在线电影| 亚洲欧洲日产国产综合网| 欧美一级夜夜爽| 一本到不卡免费一区二区| 麻豆精品国产传媒mv男同| 日韩毛片视频在线看| 日韩免费一区二区| 在线观看av一区| 99九九99九九九视频精品| 七七婷婷婷婷精品国产| 亚洲综合色自拍一区| 国产精品不卡一区| 日韩欧美在线1卡| 欧美日本精品一区二区三区| 99视频一区二区| 国产精品资源站在线| 日韩电影在线一区二区三区| 亚洲精品伦理在线| 中文字幕亚洲区| 欧美激情艳妇裸体舞| 精品国产亚洲一区二区三区在线观看 | 亚洲高清免费在线| 亚洲欧洲av在线| 中文字幕av一区 二区| 久久色.com| 337p粉嫩大胆色噜噜噜噜亚洲| 欧美酷刑日本凌虐凌虐| 色天天综合久久久久综合片| 成人激情av网| 成人av资源下载| 97国产一区二区| 成人app在线| av电影在线观看完整版一区二区 | 欧美高清在线一区二区| 精品88久久久久88久久久| 欧美一区二区三区白人| 欧美疯狂做受xxxx富婆| 欧美高清视频一二三区 | 91网上在线视频| 99久久99久久免费精品蜜臀| 成人激情黄色小说| 92精品国产成人观看免费| av网站一区二区三区| 91浏览器入口在线观看| 色狠狠色狠狠综合| 欧美少妇一区二区| 91麻豆精品国产91久久久资源速度 | 在线观看视频欧美| 精品视频在线视频| 欧美日本不卡视频| 日韩视频一区二区在线观看| 精品成a人在线观看| 欧美激情一区二区三区不卡| 中文字幕在线不卡视频| 亚洲乱码国产乱码精品精可以看 | 欧美性大战久久久| 欧美一区二区三区视频在线 | 欧美三级电影在线看| 91精品国产欧美日韩| 久久丝袜美腿综合| 亚洲视频免费在线| 亚洲午夜电影在线| 美女视频黄免费的久久| 成人av免费在线播放| 欧美日韩在线直播| 久久久91精品国产一区二区三区| 亚洲欧洲精品一区二区三区不卡| 亚洲成av人片一区二区梦乃| 国产一区二区三区久久久| 99re66热这里只有精品3直播| 宅男噜噜噜66一区二区66| 国产区在线观看成人精品| 亚洲综合一区在线| 国内精品国产成人国产三级粉色| 91丨porny丨首页| 欧美第一区第二区| 国产精品超碰97尤物18| 美国三级日本三级久久99| 91视频观看免费| 日韩欧美一区二区不卡| 1024精品合集| 九九热在线视频观看这里只有精品| aaa欧美色吧激情视频| 日韩一级片网站| 亚洲尤物在线视频观看|