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

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

?? posix.cc

?? 編譯工具
?? CC
?? 第 1 頁 / 共 2 頁
字號:
//				Package : omnithread// omnithread/posix.cc		Created : 7/94 tjr////    Copyright (C) 1994-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 posix threads//// The source below tests for the definition of the macros://     PthreadDraftVersion//     PthreadSupportThreadPriority//     NoNanoSleep//     NeedPthreadInit//// As different draft versions of the pthread standard P1003.4a/P1003.1c// define slightly different APIs, the macro 'PthreadDraftVersion'// identifies the draft version supported by this particular platform.//// Some unix variants do not support thread priority unless a real-time// kernel option is installed. The macro 'PthreadSupportThreadPriority',// if defined, enables the use of thread priority. If it is not defined,// setting or changing thread priority will be silently ignored.//// nanosleep() is defined in Posix P1003.4 since Draft 9 (?).// Not all platforms support this standard. The macro 'NoNanoSleep'// identifies platform that don't.//#ifdef __VMS# define pthread_attr_destroy PTHREAD_ATTR_DESTROY# define pthread_attr_init PTHREAD_ATTR_INIT# define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM# define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE# define pthread_cond_broadcast PTHREAD_COND_BROADCAST# define pthread_cond_destroy PTHREAD_COND_DESTROY# define pthread_cond_init PTHREAD_COND_INIT# define pthread_cond_signal PTHREAD_COND_SIGNAL# define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT# define pthread_cond_wait PTHREAD_COND_WAIT# define pthread_create PTHREAD_CREATE# define pthread_delay_np PTHREAD_DELAY_NP# define pthread_detach PTHREAD_DETACH# define pthread_exit PTHREAD_EXIT# define pthread_get_expiration_np PTHREAD_GET_EXPIRATION_NP# define pthread_getspecific PTHREAD_GETSPECIFIC# define pthread_join32 PTHREAD_JOIN32# define pthread_key_create PTHREAD_KEY_CREATE# define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY# define pthread_mutex_init PTHREAD_MUTEX_INIT# define pthread_mutex_lock PTHREAD_MUTEX_LOCK# define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK# define pthread_self PTHREAD_SELF# define pthread_setschedparam PTHREAD_SETSCHEDPARAM# define pthread_setspecific PTHREAD_SETSPECIFIC# define pthread_yield_np PTHREAD_YIELD_NP#endif#include <stdlib.h>#include <errno.h>#include <time.h>#include <omnithread.h>#if (defined(__GLIBC__) && __GLIBC__ >= 2) || defined(__SCO_VERSION__) || defined(__aix__) || defined (__cygwin__) || defined(__darwin__) || defined(__macos__)// typedef of struct timeval and gettimeofday();#include <sys/time.h>#include <unistd.h>#endif#if defined(__linux__) && defined(_MIT_POSIX_THREADS)#include <pthread/mit/sys/timers.h>#endif#if defined(__irix__) && defined(PthreadSupportThreadPriority)#if _POSIX_THREAD_PRIORITY_SCHEDULING#include <sched.h>#endif#endif#define DB(x) // x//#include <iostream.h> or #include <iostream> if DB is on.#if (PthreadDraftVersion <= 6)#define ERRNO(x) (((x) != 0) ? (errno) : 0)#ifdef __VMS// pthread_setprio returns old priority on success (draft version 4:// OpenVms version < 7)#define THROW_ERRORS(x) { if ((x) == -1) throw omni_thread_fatal(errno); }#else#define THROW_ERRORS(x) { if ((x) != 0) throw omni_thread_fatal(errno); }#endif#else#define ERRNO(x) (x)#define THROW_ERRORS(x) { int rc = (x); \			  if (rc != 0) throw omni_thread_fatal(rc); }#endif/////////////////////////////////////////////////////////////////////////////// Mutex/////////////////////////////////////////////////////////////////////////////omni_mutex::omni_mutex(void){#if (PthreadDraftVersion == 4)    THROW_ERRORS(pthread_mutex_init(&posix_mutex, pthread_mutexattr_default));#else    THROW_ERRORS(pthread_mutex_init(&posix_mutex, 0));#endif}omni_mutex::~omni_mutex(void){    THROW_ERRORS(pthread_mutex_destroy(&posix_mutex));}/////////////////////////////////////////////////////////////////////////////// Condition variable/////////////////////////////////////////////////////////////////////////////omni_condition::omni_condition(omni_mutex* m) : mutex(m){#if (PthreadDraftVersion == 4)    THROW_ERRORS(pthread_cond_init(&posix_cond, pthread_condattr_default));#else    THROW_ERRORS(pthread_cond_init(&posix_cond, 0));#endif}omni_condition::~omni_condition(void){    THROW_ERRORS(pthread_cond_destroy(&posix_cond));}voidomni_condition::wait(void){    THROW_ERRORS(pthread_cond_wait(&posix_cond, &mutex->posix_mutex));}intomni_condition::timedwait(unsigned long secs, unsigned long nanosecs){    timespec rqts = { secs, nanosecs };again:    int rc = ERRNO(pthread_cond_timedwait(&posix_cond,					  &mutex->posix_mutex, &rqts));    if (rc == 0)	return 1;#if (PthreadDraftVersion <= 6)    if (rc == EAGAIN)	return 0;#endif    // Some versions of unix produces this errno when the wait was    // interrupted by a unix signal or fork.    // Some versions of the glibc 2.0.x produces this errno when the     // program is debugged under gdb. Straightly speaking this is non-posix    // compliant. We catch this here to make debugging possible.    if (rc == EINTR)      goto again;    if (rc == ETIMEDOUT)	return 0;    throw omni_thread_fatal(rc);#ifdef _MSC_VER    return 0;#endif}voidomni_condition::signal(void){    THROW_ERRORS(pthread_cond_signal(&posix_cond));}voidomni_condition::broadcast(void){    THROW_ERRORS(pthread_cond_broadcast(&posix_cond));}/////////////////////////////////////////////////////////////////////////////// Counting semaphore/////////////////////////////////////////////////////////////////////////////omni_semaphore::omni_semaphore(unsigned int initial) : c(&m){    value = initial;}omni_semaphore::~omni_semaphore(void){}voidomni_semaphore::wait(void){    omni_mutex_lock l(m);    while (value == 0)	c.wait();    value--;}intomni_semaphore::trywait(void){    omni_mutex_lock l(m);    if (value == 0)	return 0;    value--;    return 1;}voidomni_semaphore::post(void){    omni_mutex_lock l(m);    value++;    c.signal();}/////////////////////////////////////////////////////////////////////////////// Thread///////////////////////////////////////////////////////////////////////////////// static variables//omni_mutex* omni_thread::next_id_mutex;int omni_thread::next_id = 0;static pthread_key_t self_key;#ifdef PthreadSupportThreadPrioritystatic int lowest_priority;static int normal_priority;static int highest_priority;#endif#if defined(__osf1__) && defined(__alpha__) || defined(__VMS)// omniORB requires a larger stack size than the default (21120) on OSF/1static size_t stack_size = 32768;#elif defined(__rtems__)static size_t stack_size = ThreadStackSize;#elif defined(__aix__)static size_t stack_size = 262144;#elsestatic size_t stack_size = 0;#endif//// 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: posix 1003.4a/1003.1c (draft "       << PthreadDraftVersion << ") implementation initialising\n");#ifdef NeedPthreadInit    pthread_init();#endif#if (PthreadDraftVersion == 4)    THROW_ERRORS(pthread_keycreate(&self_key, NULL));#else    THROW_ERRORS(pthread_key_create(&self_key, NULL));#endif#ifdef PthreadSupportThreadPriority#if defined(__osf1__) && defined(__alpha__) || defined(__VMS)    lowest_priority = PRI_OTHER_MIN;    highest_priority = PRI_OTHER_MAX;#elif defined(__hpux__)    lowest_priority = PRI_OTHER_MIN;    highest_priority = PRI_OTHER_MAX;#elif defined(__sunos__) && (__OSVERSION__ == 5)    // a bug in pthread_attr_setschedparam means lowest priority is 1 not 0    lowest_priority  = 1;    highest_priority = 3;#else    lowest_priority = sched_get_priority_min(SCHED_FIFO);    highest_priority = sched_get_priority_max(SCHED_FIFO);#endif    switch (highest_priority - lowest_priority) {    case 0:    case 1:	normal_priority = lowest_priority;	break;    default:	normal_priority = lowest_priority + 1;	break;    }#endif   /* PthreadSupportThreadPriority */    next_id_mutex = new omni_mutex;    //    // Create object for this (i.e. initial) thread.    //    omni_thread* t = new omni_thread;    t->_state = STATE_RUNNING;    t->posix_thread = pthread_self ();    DB(cerr << "initial thread " << t->id() << endl);    THROW_ERRORS(pthread_setspecific(self_key, (void*)t));#ifdef PthreadSupportThreadPriority#if (PthreadDraftVersion == 4)    THROW_ERRORS(pthread_setprio(t->posix_thread,				 posix_priority(PRIORITY_NORMAL)));#elif (PthreadDraftVersion == 6)    pthread_attr_t attr;    pthread_attr_init(&attr);    THROW_ERRORS(pthread_attr_setprio(&attr, posix_priority(PRIORITY_NORMAL)));    THROW_ERRORS(pthread_setschedattr(t->posix_thread, attr));#else    struct sched_param sparam;    sparam.sched_priority = posix_priority(PRIORITY_NORMAL);    THROW_ERRORS(pthread_setschedparam(t->posix_thread, SCHED_OTHER, &sparam));#endif   /* PthreadDraftVersion */#endif   /* PthreadSupportThreadPriority */}omni_thread::init_t::~init_t(void){    if (--count() != 0) return;    omni_thread* self = omni_thread::self();    if (!self) return;    pthread_setspecific(self_key, 0);    delete self;    delete next_id_mutex;}//// Wrapper for thread creation.//extern "C" void* omni_thread_wrapper(void* ptr){    omni_thread* me = (omni_thread*)ptr;    DB(cerr << "omni_thread_wrapper: thread " << me->id()       << " started\n");    THROW_ERRORS(pthread_setspecific(self_key, me));    //    // Now invoke the thread function with the given argument.    //    if (me->fn_void != NULL) {	(*me->fn_void)(me->thread_arg);	omni_thread::exit();    }    if (me->fn_ret != NULL) {	void* return_value = (*me->fn_ret)(me->thread_arg);	omni_thread::exit(return_value);    }    if (me->detached) {	me->run(me->thread_arg);	omni_thread::exit();    } else {	void* return_value = me->run_undetached(me->thread_arg);	omni_thread::exit(return_value);    }    // should never get here.    return NULL;}//// Constructors for omni_thread - set up the thread object but don't// start it running.//// construct a detached thread running a given function.omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri){    common_constructor(arg, pri, 1);    fn_void = fn;    fn_ret = NULL;}// construct an undetached thread running a given function.omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri){    common_constructor(arg, pri, 0);    fn_void = NULL;    fn_ret = fn;}// construct a thread which will run either run() or run_undetached().omni_thread::omni_thread(void* arg, priority_t pri){    common_constructor(arg, pri, 1);    fn_void = NULL;    fn_ret = NULL;}// common part of all constructors.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品在线视频观看| 在线中文字幕一区| 亚洲免费观看高清完整版在线观看熊| 欧美性三三影院| 国产福利一区二区三区| 亚洲成人av免费| 国产精品国产a级| 精品久久久三级丝袜| 欧美性受极品xxxx喷水| 成人蜜臀av电影| 极品少妇xxxx精品少妇| 亚洲成人自拍偷拍| 综合精品久久久| 久久久久久久久免费| 日韩欧美国产三级电影视频| 在线观看日韩精品| 91免费视频观看| 菠萝蜜视频在线观看一区| 捆绑变态av一区二区三区| 亚洲图片欧美色图| 一区二区三区在线视频免费观看| 欧美激情一区在线观看| 久久夜色精品国产噜噜av | 成人精品一区二区三区中文字幕| 喷白浆一区二区| 天堂va蜜桃一区二区三区漫画版| 亚洲欧美日韩电影| 亚洲三级在线播放| 国产精品久久久久影院老司| 久久久久国产一区二区三区四区| 日韩欧美aaaaaa| 日韩视频中午一区| 日韩精品一区在线| 日韩精品资源二区在线| 日韩欧美中文一区二区| 欧美一级黄色大片| 日韩一区二区三区免费看| 精品视频一区二区三区免费| 欧美综合色免费| 欧美亚洲一区二区在线| 欧美午夜精品理论片a级按摩| 99国产精品99久久久久久| 91香蕉视频污| 欧美性猛交xxxx黑人交| 欧美日韩一级片在线观看| 欧美猛男超大videosgay| 欧美一区午夜视频在线观看| 欧美一区二区三区在线看| 欧美高清激情brazzers| 欧美久久久久中文字幕| 日韩一区二区三区免费看| 日韩欧美一区二区不卡| 精品国产三级电影在线观看| 久久久三级国产网站| 国产日韩一级二级三级| 中文字幕一区二区三区不卡在线| 亚洲欧美电影一区二区| 亚洲观看高清完整版在线观看| 亚洲亚洲人成综合网络| 奇米影视一区二区三区小说| 久久激情五月激情| 国产成人精品亚洲777人妖 | 一区二区三区欧美亚洲| 亚洲一区二区三区中文字幕| 日韩国产欧美视频| 精品一区二区三区欧美| 不卡一区二区三区四区| 91福利社在线观看| 欧美一区2区视频在线观看| 日韩精品中文字幕在线不卡尤物| 国产日产欧产精品推荐色| 成人欧美一区二区三区1314| 午夜精品在线视频一区| 国产自产高清不卡| 91热门视频在线观看| 69av一区二区三区| 久久夜色精品一区| 亚洲一区日韩精品中文字幕| 精品一区二区三区av| 92国产精品观看| 日韩欧美一二三区| 中文字幕亚洲电影| 日本不卡中文字幕| 不卡欧美aaaaa| 欧美一区二区三区免费| 中文字幕av资源一区| 亚洲成精国产精品女| 国产a精品视频| 5858s免费视频成人| 国产精品理论在线观看| 美脚の诱脚舐め脚责91| 99re这里都是精品| 26uuu欧美日本| 亚洲成年人影院| voyeur盗摄精品| 精品理论电影在线观看| 亚洲国产一区二区a毛片| 国产精品一区专区| 91精品国产综合久久久久久漫画| 国产精品免费久久| 久久超碰97人人做人人爱| 91看片淫黄大片一级| 久久嫩草精品久久久久| 日韩中文字幕av电影| av在线不卡电影| 亚洲精品一区二区三区福利| 亚洲午夜久久久| 99在线精品一区二区三区| 精品国产不卡一区二区三区| 亚洲高清免费观看| av一区二区久久| 国产亚洲自拍一区| 美脚の诱脚舐め脚责91| 欧美日韩极品在线观看一区| 亚洲视频一区二区在线| 国产aⅴ综合色| 久久先锋影音av鲁色资源| 喷水一区二区三区| 69堂国产成人免费视频| 午夜久久久久久| 欧美日本在线看| 一区二区免费看| 91欧美一区二区| 亚洲人成影院在线观看| 成人91在线观看| 中文字幕高清一区| 国产精品夜夜嗨| 久久久一区二区三区| 国内不卡的二区三区中文字幕 | 精品少妇一区二区三区免费观看 | eeuss国产一区二区三区| 国产亚洲污的网站| 国产综合成人久久大片91| 欧美zozozo| 极品美女销魂一区二区三区| 日韩欧美三级在线| 美腿丝袜亚洲三区| 欧美一区二区三区免费大片| 美腿丝袜亚洲一区| 精品日韩av一区二区| 极品美女销魂一区二区三区免费| 日韩女优视频免费观看| 韩国毛片一区二区三区| 久久精品男人天堂av| 福利一区福利二区| 成人欧美一区二区三区白人| 色综合色狠狠综合色| 亚洲国产精品久久人人爱| 欧美日本一区二区在线观看| 日日摸夜夜添夜夜添精品视频| 欧美日韩精品一区二区天天拍小说| 亚洲福利国产精品| 日韩一级黄色片| 国产成人av电影在线观看| 中文字幕高清一区| 欧洲视频一区二区| 日本强好片久久久久久aaa| 久久夜色精品国产噜噜av| 丰满放荡岳乱妇91ww| 亚洲视频精选在线| 欧美日韩激情在线| 精品一区二区在线视频| 国产精品欧美久久久久一区二区| 99久久精品国产精品久久| www.欧美.com| 国产精品久久久久久久第一福利 | 国产成人av一区二区三区在线| 国产精品久久久久aaaa| 在线观看精品一区| 婷婷综合五月天| 久久嫩草精品久久久久| 色婷婷久久综合| 日本aⅴ精品一区二区三区| 国产日产欧美一区| 欧美性猛交xxxx黑人交| 国产乱码精品一区二区三区忘忧草| 18欧美亚洲精品| 欧美一级生活片| 成人免费三级在线| 性感美女久久精品| 国产精品情趣视频| 91麻豆精品91久久久久同性| 国产成人综合在线观看| 亚洲国产精品视频| 国产女主播视频一区二区| 欧美午夜电影一区| 国产91清纯白嫩初高中在线观看| 亚洲国产成人va在线观看天堂| 久久久久国色av免费看影院| 欧美性色黄大片| 成人禁用看黄a在线| 日本午夜精品视频在线观看| 国产精品美女久久久久久2018| 欧美高清视频一二三区| 91小视频免费看| 国产精品一区二区三区乱码| 五月婷婷久久综合| 中文字幕一区二区三区四区| 久久久久久综合| 91精品国产综合久久精品|