• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ InitializeConditionVariable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中InitializeConditionVariable函数的典型用法代码示例。如果您正苦于以下问题:C++ InitializeConditionVariable函数的具体用法?C++ InitializeConditionVariable怎么用?C++ InitializeConditionVariable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了InitializeConditionVariable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(void)
{
	InitializeConditionVariable(&BufferNotEmpty);
	InitializeConditionVariable(&BufferNotFull);
	InitializeCriticalSection(&BufferLock);

	DWORD id;
	HANDLE hProducer1 = CreateThread(NULL, 0, ProducerThreadProc, (PVOID)1, 0, &id);
	HANDLE hConsumer1 = CreateThread(NULL, 0, ConsumerThreadProc, (PVOID)1, 0, &id);
	HANDLE hConsumer2 = CreateThread(NULL, 0, ConsumerThreadProc, (PVOID)2, 0, &id);
	puts("Press enter to stop...");
	getchar();
	EnterCriticalSection(&BufferLock);
	StopRequested = TRUE;
	LeaveCriticalSection(&BufferLock);

	WakeAllConditionVariable(&BufferNotFull);
	WakeAllConditionVariable(&BufferNotEmpty);

	WaitForSingleObject(hProducer1, INFINITE);
	WaitForSingleObject(hConsumer1, INFINITE);
	WaitForSingleObject(hConsumer2, INFINITE);
	printf("TotalItemsProduced: %u, TotalItemsConsumed: %u\r\n", TotalItemsProduced, TotalItemsConsumed);


	CloseHandle(hProducer1);
	CloseHandle(hConsumer1);
	CloseHandle(hConsumer2);


	system("pause");
	return 0;
}
开发者ID:chengguixing,项目名称:iArt,代码行数:33,代码来源:main.cpp


示例2: Dlg_OnInitDialog

BOOL Dlg_OnInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) {

   chSETDLGICONS(hWnd, IDI_QUEUE);

   g_hWnd = hWnd; // Used by client/server threads to show status

   // Prepare the SRWLock to be used
   InitializeSRWLock(&g_srwLock);

   // Prepare the condition variables to be used
   InitializeConditionVariable(&g_cvReadyToConsume);
   InitializeConditionVariable(&g_cvReadyToProduce);

   // Will be set to TRUE in order to end threads
   g_fShutdown = FALSE;

   // Create the writer threads
   DWORD dwThreadID;
   for (int x = 0; x < 4; x++)
      g_hThreads[g_nNumThreads++] = 
         chBEGINTHREADEX(NULL, 0, WriterThread, (PVOID) (INT_PTR) x, 
            0, &dwThreadID);

   // Create the reader threads
   for (int x = 0; x < 2; x++)
      g_hThreads[g_nNumThreads++] = 
         chBEGINTHREADEX(NULL, 0, ReaderThread, (PVOID) (INT_PTR) x, 
            0, &dwThreadID);

   return(TRUE);
}
开发者ID:Jeanhwea,项目名称:WindowsViaCPP,代码行数:31,代码来源:Queue.cpp


示例3: QueueInitialize

DWORD QueueInitialize (QUEUE_OBJECT *q, DWORD msize, DWORD nmsgs)
{
    /* Initialize queue, including its mutex and events */
    /* Allocate storage for all messages. */

    if ((q->msgArray = calloc (nmsgs, msize)) == NULL) return 1;
    q->qFirst = q->qLast = 0;
    q->qSize = nmsgs;

    InitializeSRWLock(&q->qGuard);
    InitializeConditionVariable(&q->qNe);
    InitializeConditionVariable(&q->qNf);
    return 0; /* No error */
}
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:14,代码来源:QueueObjCV.c


示例4: InitializeConditionVariable

Error Cond::create(Cond **returnValue)
{
    Cond *cond = new Cond;
    InitializeConditionVariable(&cond->mNativeCond);
    *returnValue = cond;
    return Error(0);
}
开发者ID:Cincinesh,项目名称:angle,代码行数:7,代码来源:synchronization_win32.cpp


示例5: _nThreads

// Constructor
drwnThreadPool::drwnThreadPool(const unsigned size) :
    _nThreads(0), _threads(NULL), _args(NULL)
{
#ifdef DRWN_USE_PTHREADS
    _nThreads = (size > MAX_THREADS) ? MAX_THREADS : size;
    if (_nThreads > 0) {
        _threads = new pthread_t[_nThreads];
        _args = new drwnThreadArgs[_nThreads];
    }
    pthread_mutex_init(&_mutex, NULL);
    pthread_cond_init(&_cond, NULL);
    _bQuit = true;

    _bProfilerEnabled = drwnCodeProfiler::enabled;
#endif

#ifdef DRWN_USE_WIN32THREADS
    _nThreads = (size > MAX_THREADS) ? MAX_THREADS : size;
    if (_nThreads > 0) {
        _threads = new HANDLE[_nThreads];
        _args = new drwnThreadArgs[_nThreads];
    }

    InitializeConditionVariable(&_cond);
    InitializeCriticalSection(&_mutex);

    _bQuit = true;

    _bProfilerEnabled = drwnCodeProfiler::enabled;
#endif
}
开发者ID:MLDL,项目名称:drwn,代码行数:32,代码来源:drwnThreadPool.cpp


示例6: YabThreadStart

int YabThreadStart(unsigned int id, void (*func)(void *), void *arg) 
{ 
   if (!hnd_key_once)
   {
      hnd_key=TlsAlloc();
      hnd_key_once = 1;
   }

   if (thread_handle[id].running)
   {
      fprintf(stderr, "YabThreadStart: thread %u is already started!\n", id);
      return -1;
   }
   
   // Create CS and condition variable for thread
   InitializeCriticalSection(&thread_handle[id].mutex);
   InitializeConditionVariable(&thread_handle[id].cond);

   thread_handle[id].func = func;
   thread_handle[id].arg = arg;

   if ((thread_handle[id].thd = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)wrapper, &thread_handle[id], 0, NULL)) == NULL)
   {
      perror("CreateThread");
      return -1;
   }
   
   thread_handle[id].running = 1;

   return 0; 
}
开发者ID:em4pixeleen,项目名称:yabause,代码行数:31,代码来源:thr-windows.c


示例7: session_alloc

/* session creation */
static int session_alloc(
    IN nfs41_client *client,
    OUT nfs41_session **session_out)
{
    nfs41_session *session;
    int status = NO_ERROR;

    session = calloc(1, sizeof(nfs41_session));
    if (session == NULL) {
        status = GetLastError();
        goto out;
    }
    session->client = client;
    session->renew_thread = INVALID_HANDLE_VALUE;
    session->isValidState = FALSE;

    InitializeCriticalSection(&session->table.lock);
    InitializeConditionVariable(&session->table.cond);

    init_slot_table(&session->table);

    //initialize session lock
    InitializeSRWLock(&client->session_lock);

    /* initialize the back channel */
    nfs41_callback_session_init(session);

    *session_out = session;
out:
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:32,代码来源:nfs41_session.c


示例8: pthread_cond_init

/**
@Status Caveat
@Notes Ignores Error codes, ignores error cases
*/
extern "C" int pthread_cond_init(pthread_cond_t* condvar, const pthread_condattr_t* attr) {
    CONDITION_VARIABLE* cond = new CONDITION_VARIABLE();
    memset(cond, 0, sizeof(CONDITION_VARIABLE));
    InitializeConditionVariable(cond);
    *condvar = (pthread_cond*)cond;
    return 0;
}
开发者ID:CoderMessi,项目名称:WinObjC,代码行数:11,代码来源:pthread.cpp


示例9: barrier_init

void barrier_init(barrier_t *barrier, int value)
{
    InitializeConditionVariable(&barrier->cond);
    InitializeCriticalSection(&barrier->mutex);
    barrier->value = value;
    barrier->counter = 0;
}
开发者ID:GMAC-lib,项目名称:gmac,代码行数:7,代码来源:barrier.c


示例10: tMPI_Thread_barrier_init

int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int n)
{
    if(barrier==NULL)
    {
        return EINVAL;
    }

    barrier->barrierp=(struct tMPI_Thread_barrier*)
              tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1);

#if 0
 /* use this once Vista is the oldest supported windows version: */
    InitializeCriticalSection(&(barrier->barrierp->cs));
    InitializeConditionVariable(&(barrier->barrierp->cv));
#else
    tMPI_Thread_mutex_init(&(barrier->barrierp->cs));
    tMPI_Thread_cond_init(&(barrier->barrierp->cv));
#endif

    barrier->threshold = n;
    barrier->count     = n;
    barrier->cycle     = 0;

    return 0;
}
开发者ID:chenleo,项目名称:gromacs453pf,代码行数:25,代码来源:winthreads.c


示例11: ThreadCVImpl

inline WinThreadCVImpl::WinThreadCVImpl ()
    : ThreadCVImpl()
    , m_mutex()
    , m_waiters(0)
    , m_wakeups(0)
{
    InitializeConditionVariable(& m_cond);
}
开发者ID:semenovf,项目名称:cwt-core,代码行数:8,代码来源:threadcv_win.cpp


示例12: InitializeConditionVariable

C_CondVar::C_CondVar()
{
#ifdef _WIN32
    InitializeConditionVariable(&m_Cond);
#else
    pthread_cond_init(&m_Cond,NULL);
#endif
}
开发者ID:Detegr,项目名称:dtglib,代码行数:8,代码来源:Concurrency.cpp


示例13: oskar_condition_init

static void oskar_condition_init(oskar_ConditionVar* var)
{
    oskar_mutex_init(&var->lock);
#if defined(OSKAR_OS_WIN)
    InitializeConditionVariable(&var->var);
#else
    pthread_cond_init(&var->var, NULL);
#endif
}
开发者ID:OxfordSKA,项目名称:OSKAR,代码行数:9,代码来源:oskar_thread.c


示例14: ConditionCreate

inline Condition*
ConditionCreate()
{
    Condition* condition = new Condition;

    InitializeConditionVariable(condition);

    return condition;
}
开发者ID:anyong298,项目名称:BundleFusion,代码行数:9,代码来源:windows-threads.hpp


示例15: __bctbx_WIN_cond_init

int __bctbx_WIN_cond_init(bctbx_cond_t *cond, void *attr)
{
#ifdef BCTBX_WINDOWS_DESKTOP
	*cond=CreateEvent(NULL, FALSE, FALSE, NULL);
#else
	InitializeConditionVariable(cond);
#endif
	return 0;
}
开发者ID:BelledonneCommunications,项目名称:bctoolbox,代码行数:9,代码来源:port.c


示例16: pthread_mutex_init

SkCondVar::SkCondVar() {
#ifdef SK_USE_POSIX_THREADS
    pthread_mutex_init(&fMutex, NULL /* default mutex attr */);
    pthread_cond_init(&fCond, NULL /* default cond attr */);
#elif defined(SK_BUILD_FOR_WIN32)
    InitializeCriticalSection(&fCriticalSection);
    InitializeConditionVariable(&fCondition);
#endif
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:SkCondVar.cpp


示例17: __scrt_initialize_thread_safe_statics_platform_specific

    static void __cdecl __scrt_initialize_thread_safe_statics_platform_specific() throw()
    {
        InitializeCriticalSectionEx(&_Tss_mutex, 4000, 0);

        InitializeConditionVariable(&_Tss_cv);

        //encoded_sleep_condition_variable_cs = __crt_fast_encode_pointer(&SleepConditionVariableCS);
        //encoded_wake_all_condition_variable = __crt_fast_encode_pointer(&WakeAllConditionVariable);
    }
开发者ID:Chuyu-Team,项目名称:VC-LTL,代码行数:9,代码来源:thread_safe_statics.cpp


示例18: defined

	Conditional::Conditional(const String &name) {
		mName = name;
		mConditionVariable = new ConditionVariable;
	#if defined(FastOSWindows)
		InitializeConditionVariable(&mConditionVariable->cv);
	#elif defined(FastOSUnixLike)
		pthread_cond_init(&mConditionVariable->cv, NULL);
	#endif
	}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:9,代码来源:Conditional.cpp


示例19: InitializeConditionVariable

	ConditionVariableImpl::ConditionVariableImpl()
	{
		#if NAZARA_CORE_WINDOWS_VISTA
		InitializeConditionVariable(&m_cv);
		#else
		m_count = 0;
		m_events[BROADCAST] = CreateEvent(nullptr, true, false, nullptr); // manual-reset event
		m_events[SIGNAL] = CreateEvent(nullptr, false, false, nullptr); // auto-reset event
		#endif
	}
开发者ID:GigAnon,项目名称:NazaraEngine,代码行数:10,代码来源:ConditionVariableImpl.cpp


示例20: m_bExtMutex

	CondVar::CondVar(Mutex *m) : m_bExtMutex(true)
	{
		mMutex = m;

#ifdef WIN32
		InitializeConditionVariable(&mCondVar);
#else

#endif
	}
开发者ID:Pragma8123,项目名称:ThreadMax,代码行数:10,代码来源:Mutex.cpp



注:本文中的InitializeConditionVariable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ InitializeCriticalSection函数代码示例发布时间:2022-05-30
下一篇:
C++ InitializeComponents函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap