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


C++ MutexType::Unlock方法代码示例

本文整理汇总了C++中MutexType::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ MutexType::Unlock方法的具体用法?C++ MutexType::Unlock怎么用?C++ MutexType::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MutexType的用法示例。


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

示例1: SDL_AudioCallbackX

static void SDL_AudioCallbackX(void *, Uint8 *stream, int len)
{
    SDL_LockAudio();
    //short *target = (short *) stream;
    g_audioBuffer_lock.Lock();
    unsigned ate = len; // number of bytes
    if(ate > g_audioBuffer.size())
        ate = (unsigned)g_audioBuffer.size();
    for(unsigned a = 0; a < ate; ++a)
        stream[a] = g_audioBuffer[a];
    g_audioBuffer.erase(g_audioBuffer.begin(), g_audioBuffer.begin() + ate);
    g_audioBuffer_lock.Unlock();
    SDL_UnlockAudio();
}
开发者ID:kode54,项目名称:libADLMIDI,代码行数:14,代码来源:adlmidiplay.cpp

示例2: main

int main( int nArgs, const char * const args[] )
{
	if( nArgs != 2 )
	{
		printf("%s: <image>\n", args[0] );
		return 1;
	}
	const char * infile = args[1];

	std::vector<uint8_t> fbuf;
	{
		std::ifstream f( infile, std::ios::binary | std::ios::ate );
		if( !f.is_open() )
		{
			printf("Unable to open %s\n",infile);
			return 2;
		}
		fbuf.resize( f.tellg() );
		f.seekg(0);
		f.read( (char*)&fbuf[0], fbuf.size() );
		if( f.gcount() != fbuf.size() )
		{
			printf("Unable to fully read %s\n",infile);
			return 3;
		}
	}

	printf( "Scanning binary for strings...\n" );
	stable str_table = get_strings( fbuf );
	printf( "Total strings found: %d\n", str_table.size() );

	printf( "Scanning binary for pointers...\n" );
	ptable ptr_table = get_pointers( fbuf );
	printf( "Total pointers found: %d\n", ptr_table.size() );

//    signal.signal(signal.SIGINT, high_scores)

	MutexType mutex; //protects next few variables
	unsigned top_score = 0;
	scorecard scores;

	#ifdef _OPENMP
		#pragma omp parallel for
	#endif
	for( offset_t base = 0; base < 0xf0000000UL; base += 0x1000 )
	{
		#ifndef _OPENMP
			//Turn off status display when using OpenMP
			//otherwise the numbers will be scrabled
			if( base % 0x10000 == 0 )
				printf( "Trying base address 0x%x\n", base );
		#endif
		unsigned score = 0;
		for(ptable::iterator iter = ptr_table.begin(); iter != ptr_table.end(); ++iter)
		{
			offset_t ptr = iter->first;
			if( ptr < base )
				continue;
			if( ptr >= (base + fbuf.size()) )
				continue;
			unsigned offset = ptr - base;
			if( str_table.find(offset) != str_table.end() )
				score += iter->second;
		}
		if( score )
		{
			mutex.Lock();
			scores.push_back( std::make_pair( score, base ) );
			if( score > top_score )
			{
				top_score = score;
				printf( "New highest score, 0x%x: %d\n", base, score );
			}
			mutex.Unlock();
		}
	}
	std::sort(scores.begin(),scores.end() );
	high_scores( scores );
}
开发者ID:bcebere,项目名称:ws30,代码行数:79,代码来源:basefind.cpp

示例3: main


//.........这里部分代码省略.........
            if(got <= 0)
                break;
#   endif

#   ifdef DEBUG_TRACE_ALL_CHANNELS
            enum { TerminalColumns = 80 };
            char channelText[TerminalColumns + 1];
            char channelAttr[TerminalColumns + 1];
            adl_describeChannels(myDevice, channelText, channelAttr, sizeof(channelText));
            std::fprintf(stdout, "%*s\r", TerminalColumns, "");  // erase the line
            std::fprintf(stdout, "%s\n", channelText);
#   endif

#   ifndef DEBUG_TRACE_ALL_EVENTS
            double time_pos = adl_positionTell(myDevice);
            std::fprintf(stdout, "                                               \r");
            uint64_t milliseconds = static_cast<uint64_t>(time_pos * 1000.0);
            if(milliseconds != milliseconds_prev)
            {
                secondsToHMSM(time_pos, posHMS, 25);
                std::fprintf(stdout, "                                               \r");
                std::fprintf(stdout, "Time position: %s / %s\r", posHMS, totalHMS);
                flushout(stdout);
                milliseconds_prev = milliseconds;
            }
#   endif

#   ifndef HARDWARE_OPL3
            g_audioBuffer_lock.Lock();
            size_t pos = g_audioBuffer.size();
            g_audioBuffer.resize(pos + got);
            for(size_t p = 0; p < got; ++p)
                g_audioBuffer[pos + p] = buff[p];
            g_audioBuffer_lock.Unlock();

            const SDL_AudioSpec &spec = obtained;
            while(g_audioBuffer.size() > static_cast<size_t>(spec.samples + (spec.freq * g_audioFormat.sampleOffset) * OurHeadRoomLength))
            {
                SDL_Delay(1);
            }

#       ifdef DEBUG_SEEKING_TEST
            if(delayBeforeSeek-- <= 0)
            {
                delayBeforeSeek = rand() % 50;
                double seekTo = double((rand() % int(adl_totalTimeLength(myDevice)) - delayBeforeSeek - 1 ));
                adl_positionSeek(myDevice, seekTo);
            }
#       endif

#   else//HARDWARE_OPL3
            const double mindelay = 1.0 / NewTimerFreq;

            //__asm__ volatile("sti\nhlt");
            //usleep(10000);
            #ifdef __DJGPP__
            __dpmi_yield();
            #endif
            #ifdef __WATCOMC__
            //dpmi_dos_yield();
            mch_delay((unsigned int)(tick_delay * 1000.0));
            #endif
            static unsigned long PrevTimer = BIOStimer;
            const unsigned long CurTimer = BIOStimer;
            const double eat_delay = (CurTimer - PrevTimer) / (double)NewTimerFreq;
            PrevTimer = CurTimer;
开发者ID:kode54,项目名称:libADLMIDI,代码行数:67,代码来源:adlmidiplay.cpp


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