当前位置: 首页>>代码示例>>C++>>正文


C++ InitializeCriticalSectionAndSpinCount函数代码示例

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


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

示例1: transport_new

rdpTransport* transport_new(rdpContext* context)
{
	rdpTransport* transport;

	transport = (rdpTransport*) calloc(1, sizeof(rdpTransport));

	if (!transport)
		return NULL;

	transport->context = context;
	transport->settings = context->settings;

	transport->ReceivePool = StreamPool_New(TRUE, BUFFER_SIZE);

	if (!transport->ReceivePool)
		goto out_free_transport;

	/* receive buffer for non-blocking read. */
	transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0);

	if (!transport->ReceiveBuffer)
		goto out_free_receivepool;

	transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

	if (!transport->connectedEvent || transport->connectedEvent == INVALID_HANDLE_VALUE)
		goto out_free_receivebuffer;

	transport->blocking = TRUE;
	transport->GatewayEnabled = FALSE;
	transport->layer = TRANSPORT_LAYER_TCP;

	if (!InitializeCriticalSectionAndSpinCount(&(transport->ReadLock), 4000))
		goto out_free_connectedEvent;

	if (!InitializeCriticalSectionAndSpinCount(&(transport->WriteLock), 4000))
		goto out_free_readlock;

	return transport;
out_free_readlock:
	DeleteCriticalSection(&(transport->ReadLock));
out_free_connectedEvent:
	CloseHandle(transport->connectedEvent);
out_free_receivebuffer:
	StreamPool_Return(transport->ReceivePool, transport->ReceiveBuffer);
out_free_receivepool:
	StreamPool_Free(transport->ReceivePool);
out_free_transport:
	free(transport);
	return NULL;
}
开发者ID:Graf3x,项目名称:FreeRDP,代码行数:51,代码来源:transport.c

示例2: NewKeyer

DttSP_EXP void
NewKeyer (REAL freq, BOOLEAN niambic, REAL gain, REAL ramp, REAL wpm,
	  REAL SampleRate)
{
	BOOL out;
	kl = newKeyerLogic ();
	ks = newKeyerState ();
	ks->flag.iambic = niambic;
	ks->flag.revpdl = TRUE;	// depends on port wiring
	ks->flag.autospace.khar = ks->flag.autospace.word = FALSE;
	ks->flag.mdlmdB = TRUE;
	ks->flag.memory.dah = TRUE;
	ks->flag.memory.dit = TRUE;
	ks->debounce = 1;		// could be more if sampled faster
	ks->mode = MODE_B;
	ks->weight = 50;
	ks->wpm = wpm;
	iambic = niambic;
	cs_cw = &CS_CW;
	out = InitializeCriticalSectionAndSpinCount (cs_cw, 0x00000080);
	update_ok = &UPDATE_OK;
	out = InitializeCriticalSectionAndSpinCount (update_ok, 0x00000080);
#ifndef INTERLEAVED
	lring = ringb_float_create (RING_SIZE);
	rring = ringb_float_create (RING_SIZE);
#else
	lring = ringb_float_create (2 * RING_SIZE);
#endif
	sem_init (&clock_fired, 0, 0);
	sem_init (&poll_fired, 0, 0);
	sem_init (&keyer_started, 0, 0);
	if (HiPerformance)
	{
		key_poll_period = 1;
		TONE_SIZE = 48 * (int) (uni[0].samplerate / 48000.0);
	}
	else
	{
		key_poll_period = 5;
		TONE_SIZE = 240 * (int) (uni[0].samplerate / 48000.0);
	}
	//------------------------------------------------------------
	SAMP_RATE = SampleRate;
	delCWToneGen(gen);
	gen = newCWToneGen (gain, freq, ramp, ramp, TONE_SIZE, SampleRate);

	//------------------------------------------------------------
	//  if (timeSetEvent(5,1,(LPTIMECALLBACK)timer_callback,(DWORD_PTR)NULL,TIME_PERIODIC) == (MMRESULT)NULL) {
	//        fprintf(stderr,"Timer failed\n"),fflush(stderr);
	//  }
}
开发者ID:Excalibur201010,项目名称:powersdr-iq,代码行数:51,代码来源:keyd.c

示例3: NowInit

static PRStatus
NowInit(void)
{
    memset(&calibration, 0, sizeof(calibration));
    NowCalibrate();
#ifdef WINCE
    InitializeCriticalSection(&calibration.calibration_lock);
    InitializeCriticalSection(&calibration.data_lock);
#else
    InitializeCriticalSectionAndSpinCount(&calibration.calibration_lock, CALIBRATIONLOCK_SPINCOUNT);
    InitializeCriticalSectionAndSpinCount(&calibration.data_lock, DATALOCK_SPINCOUNT);
#endif
    return PR_SUCCESS;
}
开发者ID:sunshineMaria,项目名称:cordyshtml5,代码行数:14,代码来源:prmjtime.cpp

示例4: malloc0

PORT
ANB create_anb	(
	int run,
	int buffsize,
	float* in,
	float* out,
	float samplerate,
	float tau,
	float hangtime,
	float advtime,
	float backtau,
	float threshold
				)
{
	ANB a;
	a = (ANB) malloc0 (sizeof(anb));
	a->run = run;
	a->buffsize = buffsize;
	a->in = in;
	a->out = out;
	a->samplerate = samplerate;
	a->tau = tau;
	a->hangtime = hangtime;
	a->advtime = advtime;
	a->backtau = backtau;
	a->threshold = threshold;
	a->wave = (float *) malloc0 (((int)(MAX_SAMPLERATE * MAX_TAU) + 1) * sizeof(float));
	a->dline_size = (int)((MAX_TAU + MAX_ADVTIME) * MAX_SAMPLERATE) + 1;
	a->dline = (float *) malloc0 (a->dline_size * sizeof(complex));
	InitializeCriticalSectionAndSpinCount (&a->cs_update, 2500);
	initBlanker(a);
	a->legacy = (float *) malloc0 (2048 * sizeof (complex));														/////////////// legacy interface - remove
	return a;
}
开发者ID:Mogwaikin,项目名称:MiniTRX,代码行数:34,代码来源:nob.c

示例5: cowInit

/* global init function */
void cowInit(void) {
    int j;
    redisLog(REDIS_NOTICE, "cowInit");
    server.isBackgroundSaving = 0;
    server.cowDictCopied = NULL;
    server.cowDictConverted = NULL;
    server.cowSaveDbExt = (bkgdDbExt *)zmalloc(sizeof(bkgdDbExt)*server.dbnum);
    server.cowSaveDb = (redisDb *)zmalloc(sizeof(redisDb)*server.dbnum);

    deferSdsDelete = listCreate();
    deferObjDelete = listCreate();

    for (j = 0; j < server.dbnum; j++) {
        server.cowSaveDb[j].dict = NULL;
        server.cowSaveDb[j].expires = NULL;
        server.cowSaveDb[j].blocking_keys = NULL;
        server.cowSaveDb[j].watched_keys = NULL;
        server.cowSaveDb[j].id = j;
        server.cowSaveDbExt[j].savedType = NULL;
        server.cowSaveDbExt[j].cowType = &dbDeferDictType;
        server.cowSaveDbExt[j].readonlyType = &dbDeferDictType;
        server.cowSaveDbExt[j].dictArray = NULL;
        server.cowSaveDbExt[j].id = j;
    }

    server.cowCurIters.curDbDictIter = NULL;
    server.cowCurIters.curObjDictIter = NULL;
    server.cowCurIters.curObjListIter = NULL;
    server.cowCurIters.curObjZDictIter = NULL;
    InitializeCriticalSectionAndSpinCount(&server.cowCurIters.csMigrate, 500);

}
开发者ID:lrascao,项目名称:redis,代码行数:33,代码来源:win32_cow.c

示例6: currWhoTurn

CRoom::CRoom(int roomNumber)
:roomNum(roomNumber),
 currWhoTurn(-1),
 roomState(ROOM_STATE::WAIT)
{
	InitializeCriticalSectionAndSpinCount(&playerLock, 4000);
}
开发者ID:433intern,项目名称:433Baseball,代码行数:7,代码来源:Room.cpp

示例7: _mutex_initialize

static void
_mutex_initialize(mutex_t* mutex, const char* name, size_t length) {
	mutex->name = string_to_const(string_copy(mutex->name_buffer, 32, name, length));

#if FOUNDATION_PLATFORM_WINDOWS
	InitializeCriticalSectionAndSpinCount((CRITICAL_SECTION*)mutex->csection, 4000);
	mutex->event = CreateEvent(0, TRUE, FALSE, 0);
	atomic_store32(&mutex->waiting, 0);
#elif FOUNDATION_PLATFORM_POSIX || FOUNDATION_PLATFORM_PNACL
	mutex->pending = false;

	pthread_mutexattr_t attr;
	pthread_mutexattr_init(&attr);
	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);

	pthread_cond_init(&mutex->cond, 0);
	pthread_mutex_init(&mutex->mutex, &attr);

	pthread_mutexattr_destroy(&attr);
#else
#  error _mutex_initialize not implemented
#endif

	mutex->lockcount = 0;
	mutex->lockedthread = 0;
}
开发者ID:haifenghuang,项目名称:foundation_lib,代码行数:26,代码来源:mutex.c

示例8: pthread_mutex_init

//	===============================Select Server===============================
LSelectServer::LSelectServer()
{
#ifndef WIN32
	pthread_mutex_init(&m_mutexForCloseSessionQueue, NULL);
	pthread_mutex_init(&m_mutexForConnectToServer, NULL);
#else
	InitializeCriticalSectionAndSpinCount(&m_mutexForCloseSessionQueue, 4000);
	InitializeCriticalSectionAndSpinCount(&m_mutexForConnectToServer, 4000);
#endif
#ifdef __EPOLL_TEST_STATISTIC__
	atomic_set(&g_nSelectServerRecvPacketAllocCount, 0);
	atomic_set(&g_nSelectServerRecvPacketFreeCount, 0);
	atomic_set(&g_nSelectServerSendPacketAllocCount, 0);
	atomic_set(&g_nSelectServerSendPacketFreeCount, 0);
#endif
}
开发者ID:MBeanwenshengming,项目名称:linuxgameserver,代码行数:17,代码来源:LSelectServer.cpp

示例9: InitializeCriticalSectionAndSpinCount

CHeartbeatThread::CHeartbeatThread() {
	InitializeCriticalSectionAndSpinCount(&cs_update_in_progress, 4000);
  _heartbeat_counter = 0;
  // Create events
	_m_stop_thread = CreateEvent(0, TRUE, FALSE, 0);
	_m_wait_thread = CreateEvent(0, TRUE, FALSE, 0);
}
开发者ID:fastbreak91,项目名称:openholdembot,代码行数:7,代码来源:CHeartbeatThread.cpp

示例10: QueueCreate

Queue * QueueCreate(BOOL NoCritSec) {
    Queue * pQueue;

#ifdef DEBUG2
    DbgMsgRecord(TEXT("-> QueueCreate\n"));
#endif

    pQueue = (Queue *)AutoHeapAlloc(sizeof(Queue));

    if (pQueue == NULL) {
        AddToMessageLog(TEXT("QueueCreate: AutoHeapAlloc failed"));
        return NULL;
    }

    pQueue->pFirst = NULL;
    pQueue->pLast = NULL;    

    if (NoCritSec) {
        pQueue->lpCriticalSection = NULL;
    }
    else {
        pQueue->lpCriticalSection = (LPCRITICAL_SECTION) AutoHeapAlloc(sizeof(CRITICAL_SECTION));
        if (InitializeCriticalSectionAndSpinCount(pQueue->lpCriticalSection, 100) == 0) {
            AddToMessageLogProcFailure(TEXT("QueueCreate: InitializeCriticalSectionAndSpinCount"), GetLastError());
            QueueDelete(pQueue);
            return NULL;
        }
    }

#ifdef DEBUG2
    DbgMsgRecord(TEXT("<- QueueCreate\n"));
#endif

    return pQueue;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:35,代码来源:Resources.cpp

示例11: main

void __cdecl main ( )
{
    DWORD dwId=0;
    HANDLE hThread[MAXIMUM_WAIT_OBJECTS];
    DWORD dwRet=0;
    g_refCount=0;

    if(!InitializeCriticalSectionAndSpinCount(&g_cs, 4000))
    {
        return;
    }

    for(int i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
    {
        hThread[i] = CreateThread(NULL, 0, ThreadProc, NULL, 0, &dwId);
        if(!hThread[i])
        {
            for(int j=0;j<i;j++)
            {   
                CloseHandle(hThread[j]);
                hThread[j]=NULL;
            }
            return;
        }
    }

    WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, hThread, TRUE, INFINITE);
    for(int i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
    {
        CloseHandle(hThread[i]);
        hThread[i]=NULL;
    }
}
开发者ID:Junch,项目名称:debug,代码行数:33,代码来源:lockconv.cpp

示例12: StreamPool_New

wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize)
{
	wStreamPool* pool = NULL;

	pool = (wStreamPool*) malloc(sizeof(wStreamPool));

	if (pool)
	{
		ZeroMemory(pool, sizeof(wStreamPool));

		pool->synchronized = synchronized;
		pool->defaultSize = defaultSize;

		InitializeCriticalSectionAndSpinCount(&pool->lock, 4000);

		pool->aSize = 0;
		pool->aCapacity = 32;
		pool->aArray = (wStream**) malloc(sizeof(wStream*) * pool->aCapacity);
		ZeroMemory(pool->aArray, sizeof(wStream*) * pool->aCapacity);

		pool->uSize = 0;
		pool->uCapacity = 32;
		pool->uArray = (wStream**) malloc(sizeof(wStream*) * pool->uCapacity);
		ZeroMemory(pool->uArray, sizeof(wStream*) * pool->uCapacity);
	}

	return pool;
}
开发者ID:AhmadKabakibi,项目名称:FreeRDP,代码行数:28,代码来源:StreamPool.c

示例13: Queue_New

wQueue* Queue_New(BOOL synchronized, int capacity, int growthFactor)
{
	wQueue* queue = NULL;

	queue = (wQueue*) malloc(sizeof(wQueue));

	if (queue)
	{
		queue->head = 0;
		queue->tail = 0;
		queue->size = 0;

		queue->capacity = 32;
		queue->growthFactor = 2;

		queue->synchronized = synchronized;

		if (capacity > 0)
			queue->capacity = capacity;

		if (growthFactor > 0)
			queue->growthFactor = growthFactor;

		queue->array = (void**) malloc(sizeof(void*) * queue->capacity);
		ZeroMemory(queue->array, sizeof(void*) * queue->capacity);

		InitializeCriticalSectionAndSpinCount(&queue->lock, 4000);
		queue->event = CreateEvent(NULL, TRUE, FALSE, NULL);

		ZeroMemory(&queue->object, sizeof(wObject));
	}

	return queue;
}
开发者ID:AhmadKabakibi,项目名称:FreeRDP,代码行数:34,代码来源:Queue.c

示例14: double

void Player::Initialize() {
  if (initialized_ == true)
    return;

  state_ = kStateStopped;
  song_counter_ms = 0;
  auto sample_rate = audio_interface_->wave_format().nSamplesPerSec;

  {
    output_buffer_samples_ = audio_interface_->buffer_size()/sizeof(short); //size in samples
    output_buffer_length_ms_ = output_buffer_samples_ / double(sample_rate*audio_interface_->wave_format().nChannels*0.001); //400.0;//400ms
    output_buffer = new short[output_buffer_samples_]; 
    mix_buffer = new real_t[output_buffer_samples_]; 
  }

  synth_->set_sample_rate(sample_rate);
  synth_->Initialize();

  thread_msg = 0;
  InitializeCriticalSection(&vis_cs);
  InitializeCriticalSectionAndSpinCount(&cs,0x100);
  player_event = CreateEvent(NULL,FALSE,FALSE,NULL);
  thread_handle = CreateThread(nullptr,0,static_cast<LPTHREAD_START_ROUTINE>(PlayThread),this,0,(LPDWORD)&thread_id);//CREATE_SUSPENDED
  if (thread_handle != nullptr) {
    SetThreadPriority(thread_handle,THREAD_PRIORITY_ABOVE_NORMAL);
  }

  initialized_ = true;
}
开发者ID:Noplace,项目名称:DSP,代码行数:29,代码来源:player.cpp

示例15: InitTCPServer

BOOL InitTCPServer(unsigned short nPort)
{
	for(int i=0; i<sizeof(g_csClients)/sizeof(g_csClients[0]); i++) {
		InitializeCriticalSectionAndSpinCount(&g_csClients[i], 0x80000400);
	}

	mem_pool = AllocIoBufferPool(MAX_UP_LEN, 2048, MAX_DOWN_LEN, 1024);
	if(!mem_pool) {
		return(FALSE);
	}

	SOCKADDR_IN sain;
	ZeroMemory(&sain, sizeof(sain));
	sain.sin_family = AF_INET;
	sain.sin_port = htons(nPort);
	TCP_EP_HANDLER conn_handler = {
		OnUserConnect,
		OnUserDisconnect,
		OnUserData,
		NULL
	};
	TCP_OPTION tcpopt;
	GetDefTCPOpt(&tcpopt);
	tcpopt.sndbuf = 0;
	tcpopt.reuse_addr = TRUE;
	tcpopt.keep_alive = TRUE;
	tcpopt.nodelay = TRUE;
	end_point = RegisterTcpEndPoint(&sain, &conn_handler, &tcpopt, mem_pool, NULL);

	return(end_point!=NULL);
}
开发者ID:EmuxEvans,项目名称:sailing,代码行数:31,代码来源:main.cpp


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