本文整理汇总了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;
}
示例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);
// }
}
示例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;
}
示例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;
}
示例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);
}
示例6: currWhoTurn
CRoom::CRoom(int roomNumber)
:roomNum(roomNumber),
currWhoTurn(-1),
roomState(ROOM_STATE::WAIT)
{
InitializeCriticalSectionAndSpinCount(&playerLock, 4000);
}
示例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;
}
示例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
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}