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

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

?? nt.cc

?? gnuradio軟件無線電源程序.現在的手機多基于軟件無線電
?? CC
?? 第 1 頁 / 共 2 頁
字號:
//				Package : omnithread// omnithread/nt.cc		Created : 6/95 tjr////    Copyright (C) 1995-1999 AT&T Laboratories Cambridge////    This file is part of the omnithread library////    The omnithread library is free software; you can redistribute it and/or//    modify it under the terms of the GNU Library General Public//    License as published by the Free Software Foundation; either//    version 2 of the License, or (at your option) any later version.////    This library is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//    Library General Public License for more details.////    You should have received a copy of the GNU Library General Public//    License along with this library; if not, write to the Free//    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  //    02111-1307, USA////// Implementation of OMNI thread abstraction for NT threads//#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdlib.h>#include <errno.h>#include <omnithread.h>#include <process.h>#define DB(x) // x //#include <iostream.h> or #include <iostream> if DB is on.static void get_time_now(unsigned long* abs_sec, unsigned long* abs_nsec);/////////////////////////////////////////////////////////////////////////////// Mutex/////////////////////////////////////////////////////////////////////////////omni_mutex::omni_mutex(void){    InitializeCriticalSection(&crit);}omni_mutex::~omni_mutex(void){    DeleteCriticalSection(&crit);}/////////////////////////////////////////////////////////////////////////////// Condition variable///////////////////////////////////////////////////////////////////////////////// Condition variables are tricky to implement using NT synchronisation// primitives, since none of them have the atomic "release mutex and wait to be// signalled" which is central to the idea of a condition variable.  To get// around this the solution is to record which threads are waiting and// explicitly wake up those threads.//// Here we implement a condition variable using a list of waiting threads// (protected by a critical section), and a per-thread semaphore (which// actually only needs to be a binary semaphore).//// To wait on the cv, a thread puts itself on the list of waiting threads for// that cv, then releases the mutex and waits on its own personal semaphore.  A// signalling thread simply takes a thread from the head of the list and kicks// that thread's semaphore.  Broadcast is simply implemented by kicking the// semaphore of each waiting thread.//// The only other tricky part comes when a thread gets a timeout from a timed// wait on its semaphore.  Between returning with a timeout from the wait and// entering the critical section, a signalling thread could get in, kick the// waiting thread's semaphore and remove it from the list.  If this happens,// the waiting thread's semaphore is now out of step so it needs resetting, and// the thread should indicate that it was signalled rather than that it timed// out.//// It is possible that the thread calling wait or timedwait is not a// omni_thread. In this case we have to provide a temporary data structure,// i.e. for the duration of the call, for the thread to link itself on the// list of waiting threads. _internal_omni_thread_dummy provides such// a data structure and _internal_omni_thread_helper is a helper class to// deal with this special case for wait() and timedwait(). Once created,// the _internal_omni_thread_dummy is cached for use by the next wait() or// timedwait() call from a non-omni_thread. This is probably worth doing// because creating a Semaphore is quite heavy weight.class _internal_omni_thread_helper;class _internal_omni_thread_dummy : public omni_thread {public:  inline _internal_omni_thread_dummy() : next(0) { }  inline ~_internal_omni_thread_dummy() { }  friend class _internal_omni_thread_helper;private:  _internal_omni_thread_dummy* next;};class _internal_omni_thread_helper {public:  inline _internal_omni_thread_helper()  {     d = 0;    t = omni_thread::self();    if (!t) {      omni_mutex_lock sync(cachelock);      if (cache) {	d = cache;	cache = cache->next;      }      else {	d = new _internal_omni_thread_dummy;      }      t = d;    }  }  inline ~_internal_omni_thread_helper() {     if (d) {      omni_mutex_lock sync(cachelock);      d->next = cache;      cache = d;    }  }  inline operator omni_thread* () { return t; }  inline omni_thread* operator->() { return t; }  static _internal_omni_thread_dummy* cache;  static omni_mutex                   cachelock;private:  _internal_omni_thread_dummy* d;  omni_thread*                 t;};_internal_omni_thread_dummy* _internal_omni_thread_helper::cache = 0;omni_mutex                   _internal_omni_thread_helper::cachelock;omni_condition::omni_condition(omni_mutex* m) : mutex(m){    InitializeCriticalSection(&crit);    waiting_head = waiting_tail = NULL;}omni_condition::~omni_condition(void){    DeleteCriticalSection(&crit);    DB( if (waiting_head != NULL) {	cerr << "omni_condition::~omni_condition: list of waiting threads "	     << "is not empty\n";    } )}voidomni_condition::wait(void){    _internal_omni_thread_helper me;    EnterCriticalSection(&crit);    me->cond_next = NULL;    me->cond_prev = waiting_tail;    if (waiting_head == NULL)	waiting_head = me;    else	waiting_tail->cond_next = me;    waiting_tail = me;    me->cond_waiting = TRUE;    LeaveCriticalSection(&crit);    mutex->unlock();    DWORD result = WaitForSingleObject(me->cond_semaphore, INFINITE);    mutex->lock();    if (result != WAIT_OBJECT_0)	throw omni_thread_fatal(GetLastError());}intomni_condition::timedwait(unsigned long abs_sec, unsigned long abs_nsec){    _internal_omni_thread_helper me;    EnterCriticalSection(&crit);    me->cond_next = NULL;    me->cond_prev = waiting_tail;    if (waiting_head == NULL)	waiting_head = me;    else	waiting_tail->cond_next = me;    waiting_tail = me;    me->cond_waiting = TRUE;    LeaveCriticalSection(&crit);    mutex->unlock();    unsigned long now_sec, now_nsec;    get_time_now(&now_sec, &now_nsec);    DWORD timeout;    if ((abs_sec <= now_sec) && ((abs_sec < now_sec) || (abs_nsec < now_nsec)))      timeout = 0;    else {      timeout = (abs_sec-now_sec) * 1000;      if( abs_nsec < now_nsec )  timeout -= (now_nsec-abs_nsec) / 1000000;      else                       timeout += (abs_nsec-now_nsec) / 1000000;    }    DWORD result = WaitForSingleObject(me->cond_semaphore, timeout);    if (result == WAIT_TIMEOUT) {	EnterCriticalSection(&crit);	if (me->cond_waiting) {	    if (me->cond_prev != NULL)		me->cond_prev->cond_next = me->cond_next;	    else		waiting_head = me->cond_next;	    if (me->cond_next != NULL)		me->cond_next->cond_prev = me->cond_prev;	    else		waiting_tail = me->cond_prev;	    me->cond_waiting = FALSE;	    LeaveCriticalSection(&crit);	    mutex->lock();	    return 0;	}	//	// We timed out but another thread still signalled us.  Wait for	// the semaphore (it _must_ have been signalled) to decrement it	// again.  Return that we were signalled, not that we timed out.	//	LeaveCriticalSection(&crit);	result = WaitForSingleObject(me->cond_semaphore, INFINITE);    }    if (result != WAIT_OBJECT_0)	throw omni_thread_fatal(GetLastError());    mutex->lock();    return 1;}voidomni_condition::signal(void){    EnterCriticalSection(&crit);    if (waiting_head != NULL) {	omni_thread* t = waiting_head;	waiting_head = t->cond_next;	if (waiting_head == NULL)	    waiting_tail = NULL;	else	    waiting_head->cond_prev = NULL;	t->cond_waiting = FALSE;	if (!ReleaseSemaphore(t->cond_semaphore, 1, NULL)) {	    int rc = GetLastError();	    LeaveCriticalSection(&crit);	    throw omni_thread_fatal(rc);	}    }    LeaveCriticalSection(&crit);}voidomni_condition::broadcast(void){    EnterCriticalSection(&crit);    while (waiting_head != NULL) {	omni_thread* t = waiting_head;	waiting_head = t->cond_next;	if (waiting_head == NULL)	    waiting_tail = NULL;	else	    waiting_head->cond_prev = NULL;	t->cond_waiting = FALSE;	if (!ReleaseSemaphore(t->cond_semaphore, 1, NULL)) {	    int rc = GetLastError();	    LeaveCriticalSection(&crit);	    throw omni_thread_fatal(rc);	}    }    LeaveCriticalSection(&crit);}/////////////////////////////////////////////////////////////////////////////// Counting semaphore/////////////////////////////////////////////////////////////////////////////#define SEMAPHORE_MAX 0x7fffffffomni_semaphore::omni_semaphore(unsigned int initial){    nt_sem = CreateSemaphore(NULL, initial, SEMAPHORE_MAX, NULL);    if (nt_sem == NULL) {      DB( cerr << "omni_semaphore::omni_semaphore: CreateSemaphore error "	     << GetLastError() << endl );      throw omni_thread_fatal(GetLastError());    }}omni_semaphore::~omni_semaphore(void){  if (!CloseHandle(nt_sem)) {    DB( cerr << "omni_semaphore::~omni_semaphore: CloseHandle error "	     << GetLastError() << endl );    throw omni_thread_fatal(GetLastError());  }}voidomni_semaphore::wait(void){    if (WaitForSingleObject(nt_sem, INFINITE) != WAIT_OBJECT_0)	throw omni_thread_fatal(GetLastError());}intomni_semaphore::trywait(void){    switch (WaitForSingleObject(nt_sem, 0)) {    case WAIT_OBJECT_0:	return 1;    case WAIT_TIMEOUT:	return 0;    }    throw omni_thread_fatal(GetLastError());    return 0; /* keep msvc++ happy */}voidomni_semaphore::post(void){    if (!ReleaseSemaphore(nt_sem, 1, NULL))	throw omni_thread_fatal(GetLastError());}/////////////////////////////////////////////////////////////////////////////// Thread///////////////////////////////////////////////////////////////////////////////// Static variables//omni_mutex* omni_thread::next_id_mutex;int omni_thread::next_id = 0;static DWORD self_tls_index;static unsigned int stack_size = 0;//// Initialisation function (gets called before any user code).//static int& count() {  static int the_count = 0;  return the_count;}omni_thread::init_t::init_t(void){    if (count()++ != 0)	// only do it once however many objects get created.	return;    DB(cerr << "omni_thread::init: NT implementation initialising\n");    self_tls_index = TlsAlloc();    if (self_tls_index == 0xffffffff)	throw omni_thread_fatal(GetLastError());    next_id_mutex = new omni_mutex;    //    // Create object for this (i.e. initial) thread.    //    omni_thread* t = new omni_thread;    t->_state = STATE_RUNNING;    if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),			 GetCurrentProcess(), &t->handle,			 0, FALSE, DUPLICATE_SAME_ACCESS))	throw omni_thread_fatal(GetLastError());    t->nt_id = GetCurrentThreadId();    DB(cerr << "initial thread " << t->id() << " NT thread id " << t->nt_id       << endl);    if (!TlsSetValue(self_tls_index, (LPVOID)t))	throw omni_thread_fatal(GetLastError());    if (!SetThreadPriority(t->handle, nt_priority(PRIORITY_NORMAL)))	throw omni_thread_fatal(GetLastError());}omni_thread::init_t::~init_t(void){    if (--count() != 0) return;    omni_thread* self = omni_thread::self();    if (!self) return;    TlsSetValue(self_tls_index, (LPVOID)0);    delete self;    delete next_id_mutex;    TlsFree(self_tls_index);}//// Wrapper for thread creation.//extern "C" #ifndef __BCPLUSPLUS__unsigned __stdcall#elsevoid _USERENTRY#endifomni_thread_wrapper(void* ptr){    omni_thread* me = (omni_thread*)ptr;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产一区视频在线观看| 日韩精品专区在线影院重磅| 麻豆成人91精品二区三区| 国产精品污网站| 精品1区2区在线观看| 欧美私人免费视频| 日本精品视频一区二区| 国产成人在线观看免费网站| 激情综合色综合久久| 亚洲免费电影在线| 欧美国产欧美综合| 日本一区二区三区电影| 久久色在线视频| 91精品国产一区二区三区蜜臀 | 国产精品嫩草影院com| 精品国产乱码久久久久久蜜臀| 91久久免费观看| 成人国产电影网| 精品一区二区久久| 久久国产福利国产秒拍| 久色婷婷小香蕉久久| 久久国产日韩欧美精品| 免费成人av资源网| 国产在线看一区| 国产99久久久国产精品潘金| 成人av电影免费在线播放| 国产91露脸合集magnet| 99re这里只有精品6| 欧美影视一区在线| 欧美电影一区二区| 久久久久久日产精品| 日韩理论片中文av| 亚洲444eee在线观看| 免费在线观看不卡| 成人国产精品免费观看动漫| 91豆麻精品91久久久久久| 9久草视频在线视频精品| 成人av在线影院| 欧美性受xxxx黑人xyx性爽| 69堂成人精品免费视频| 日韩欧美成人午夜| 亚洲视频图片小说| 免费成人美女在线观看.| 成人午夜看片网址| 在线综合+亚洲+欧美中文字幕| 久久看人人爽人人| 亚洲综合在线免费观看| 久久99久久99| 91久久精品国产91性色tv | 欧美激情一区二区| 午夜精品视频在线观看| 97精品国产露脸对白| 精品电影一区二区三区| 怡红院av一区二区三区| 国产呦萝稀缺另类资源| 国产成人av电影在线观看| 91免费视频观看| 国产蜜臀av在线一区二区三区| 视频在线观看一区二区三区| 91美女在线观看| 亚洲视频免费在线| 成人午夜大片免费观看| 欧美精品一区二区在线播放| 日韩在线观看一区二区| 欧美午夜免费电影| 五月婷婷综合网| 欧美日韩在线电影| 亚洲第一会所有码转帖| 色综合天天视频在线观看| 国产精品亲子伦对白| 国产·精品毛片| 国产精品午夜久久| 99视频精品在线| 国产精品国产三级国产aⅴ中文| 国产精品一区二区在线播放 | 日韩精品久久久久久| 欧美性xxxxxxxx| 亚洲啪啪综合av一区二区三区| 成人理论电影网| 一区免费观看视频| 欧美日韩国产高清一区二区三区| 天堂资源在线中文精品| 日韩欧美一级特黄在线播放| 国产黄色成人av| 一区二区三区丝袜| 欧美成人激情免费网| 国产jizzjizz一区二区| 一区二区三区在线视频免费| 欧美日韩国产在线观看| 国产乱人伦偷精品视频免下载| 国产精品人妖ts系列视频| 欧洲日韩一区二区三区| 国产真实乱对白精彩久久| 最近日韩中文字幕| 96av麻豆蜜桃一区二区| 国产一区二区成人久久免费影院| 99久久精品免费观看| 天天av天天翘天天综合网 | 亚洲欧洲www| 日韩亚洲欧美在线观看| 日本电影亚洲天堂一区| 国产激情偷乱视频一区二区三区| 亚洲图片欧美一区| 中文字幕精品三区| 日韩欧美一级在线播放| jiyouzz国产精品久久| 久久精品噜噜噜成人88aⅴ| 综合欧美一区二区三区| 久久这里都是精品| 欧美tickle裸体挠脚心vk| 欧美日韩视频在线一区二区| 亚洲自拍与偷拍| 中文字幕一区二区三区在线观看| 久久综合丝袜日本网| aaa亚洲精品| 国产成人免费高清| 激情丁香综合五月| 麻豆视频观看网址久久| 日韩和欧美的一区| 日韩精品视频网| 日韩黄色在线观看| 三级欧美在线一区| 日韩国产在线一| 男人的天堂亚洲一区| 亚洲成a人片在线观看中文| 香蕉影视欧美成人| 免费观看在线综合色| 麻豆91精品91久久久的内涵| 九九热在线视频观看这里只有精品| 天天综合日日夜夜精品| 97精品国产露脸对白| 亚洲一区二三区| 亚洲愉拍自拍另类高清精品| 亚洲国产成人av网| 青青草原综合久久大伊人精品| 日韩电影网1区2区| 国产一区视频网站| 色婷婷av一区| 欧美日韩精品一区二区三区四区 | 福利一区二区在线观看| 色成年激情久久综合| 日韩三级在线免费观看| 国产精品你懂的在线| 亚洲v中文字幕| 成人夜色视频网站在线观看| 91黄色激情网站| 久久久国产一区二区三区四区小说| 国产精品免费视频网站| 免费在线欧美视频| 99久久精品国产网站| 日韩欧美高清dvd碟片| 亚洲精品亚洲人成人网在线播放| 麻豆一区二区三区| 欧美三区在线观看| 国产蜜臀av在线一区二区三区| 亚州成人在线电影| 一本大道久久a久久综合婷婷| 欧美午夜精品久久久| 久久久99久久精品欧美| 亚洲制服丝袜在线| 色婷婷综合视频在线观看| 欧美国产精品久久| 国产在线不卡一卡二卡三卡四卡| 色av成人天堂桃色av| 亚洲三级电影网站| 成人精品小蝌蚪| 亚洲国产成人私人影院tom | 国产美女主播视频一区| 这里只有精品电影| 日韩国产欧美在线播放| 欧美精品少妇一区二区三区| 亚洲国产aⅴ天堂久久| 欧美中文字幕一区| 亚洲在线成人精品| 欧美日韩精品欧美日韩精品一| 樱花影视一区二区| 欧美精品亚洲一区二区在线播放| 日韩综合在线视频| 成人午夜精品在线| 亚洲精品菠萝久久久久久久| 色综合视频在线观看| 国产传媒日韩欧美成人| 日韩欧美在线综合网| 日本不卡一区二区三区| 日韩视频一区二区三区在线播放| 免费看欧美女人艹b| 国产精品免费视频网站| 91成人在线精品| 九九九精品视频| 国产欧美日韩综合精品一区二区| 9l国产精品久久久久麻豆| 亚洲国产裸拍裸体视频在线观看乱了| 91精品国产麻豆| 国产91丝袜在线播放九色| 一区二区在线观看视频| 欧美精品一区二区三区在线| aa级大片欧美| 国产在线精品一区二区不卡了 | 欧美一级片在线看| 欧美在线你懂得|