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


C++ poco::Mutex类代码示例

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


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

示例1: recordingStarted

void Sampler::recordingStarted() {
	printf("Record start\n");
	controlMutex.lock();
	recording = true;
	recordPos = 0;
	controlMutex.unlock();
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:7,代码来源:Sampler.cpp

示例2: recordingEnded

void Sampler::recordingEnded() {
	printf("Record end\n");
	controlMutex.lock();
	recording = false;
	sample.load(recordBuffer, recordPos);
	printf("Loaded sample of %d length\n", recordPos);
	controlMutex.unlock();
	noteOffset = -12;
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:9,代码来源:Sampler.cpp

示例3: soundChanged

void Sampler::soundChanged() {

	controlMutex.lock();
	string sndUrl = "";//AppSettings::soundFile;
	if(sndUrl=="") {
		sndUrl = ofToDataPath("sounds/harp.wav");
	}
	sample.loadFromFile(sndUrl);
	controlMutex.unlock();
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:10,代码来源:Sampler.cpp

示例4: DoSomethingConcurrently

    void DoSomethingConcurrently()
    {
        // Declares a mutex (mutual exclusion)
        Poco::Mutex mutex;
        
        // No other thread will be able to execute the next line until the mutex is unlocked by a previous thread
        mutex.lock();

        ::OutputDebugStringW(L"Something done.\n");

        mutex.unlock();
    }
开发者ID:Kailashkatheth1,项目名称:quimeraengine,代码行数:12,代码来源:MultithreadingMethod.cpp

示例5: audioRequested

void Sampler::audioRequested (float * output, int bufferSize, int nChannels) {
	controlMutex.lock();
	// if we're recording, we want silence!!
	if(recording) {
		memset(output, 0, bufferSize*nChannels*sizeof(float));
	} else {
	//	printf("Sound %f\n", playbackSpeed);
		// otherwise, maybe we want playback
		for(int i = 0; i < bufferSize; i++) {
			float s = sample.getSample(playbackSpeed);
			for(int channel = 0; channel < nChannels; channel++) {
				output[i*nChannels + channel] = s;
			}
		}
	}
	controlMutex.unlock();
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:17,代码来源:Sampler.cpp

示例6:

//--------------------------------------------------------------
void Sampler::audioReceived 	(float * input, int bufferSize, int nChannels){

	//if(recording) printf("We're recording\n");
	//else printf("Not record\n");
	controlMutex.lock();
	for(int i = 0; i < bufferSize; i++) {

		float inp = input[i*nChannels];

		// do the recording
		if(recording && recordPos<recordBufferSize) {
			recordBuffer[recordPos++] = inp;
		}
		// do a level meter
		if(inputLevel<inp) {
			inputLevel = inp;
		} else {
			inputLevel *= 0.99995;
		}
	}
	controlMutex.unlock();

}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:24,代码来源:Sampler.cpp

示例7: init

//--------------------------------------------------------------
void Sampler::init(){
	
	currTouchId = -1;
	//AppSettings::addListener(this);
	movementThreshold = 0.02;
	//Particle::color = &AppSettings::color3;

	recordBufferSize = SAMPLERATE*MAX_RECORD_SECONDS;
	recordBuffer = new float[recordBufferSize];
	recordPos = 0;
	recording = false;
	inputLevel = 0;
	playbackSpeed = 1;
	lastSound = -1;


	ofDirectory DIR;

	int numFiles = DIR.listDir("sounds");
	for(int i = 0; i < numFiles; i++) {
		sounds.push_back(DIR.getName(i));
	}


	// this is the last time that there was a note
	noteLastTime = -10;
	lastNote = 0;


	scales.push_back(PENTATONIC);
	scales.push_back(MAJOR);
	scales.push_back(MINOR);
	scales.push_back(CHROMATIC);


	memset(recordBuffer, 0, recordBufferSize*sizeof(float));
	// 1 output channels,
	// 2 input channels
	// 44100 samples per second
	// 256 samples per buffer
	// 1 num buffers (latency)


 
	controlMutex.lock();
	sample.loadFromFile(ofToDataPath("sounds/harp.wav"));
	controlMutex.unlock();


	//--------- PANEL 1

	video.listDevices();
	#ifdef TARGET_OF_IPHONE
	video.setDeviceID(1);
	#endif
	video.initGrabber(VISION_WIDTH, VISION_HEIGHT, OF_PIXELS_BGRA);
	vision.setup();
	gui.setup();
	
	gui.recordButton->recListener = this;
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:62,代码来源:Sampler.cpp

示例8: copyCachedModel

namespace rrllvm
{

typedef cxx11_ns::weak_ptr<ModelResources> WeakModelPtr;
typedef cxx11_ns::shared_ptr<ModelResources> SharedModelPtr;
typedef cxx11_ns::unordered_map<std::string, WeakModelPtr> ModelPtrMap;

static Poco::Mutex cachedModelsMutex;
static ModelPtrMap cachedModels;


/**
 * copy the cached model fields between a cached model, and a
 * executable model.
 *
 * We don't want to have ExecutableModel inherit from CahcedModel
 * because they do compleltly different things, and have completly
 * differnt deletion semantics
 */
template <typename a_type, typename b_type>
void copyCachedModel(a_type* src, b_type* dst)
{
    dst->symbols = src->symbols;
    dst->context = src->context;
    dst->executionEngine = src->executionEngine;
    dst->errStr = src->errStr;

    dst->evalInitialConditionsPtr = src->evalInitialConditionsPtr;
    dst->evalReactionRatesPtr = src->evalReactionRatesPtr;
    dst->getBoundarySpeciesAmountPtr = src->getBoundarySpeciesAmountPtr;
    dst->getFloatingSpeciesAmountPtr = src->getFloatingSpeciesAmountPtr;
    dst->getBoundarySpeciesConcentrationPtr = src->getBoundarySpeciesConcentrationPtr;
    dst->getFloatingSpeciesConcentrationPtr = src->getFloatingSpeciesConcentrationPtr;
    dst->getCompartmentVolumePtr = src->getCompartmentVolumePtr;
    dst->getGlobalParameterPtr = src->getGlobalParameterPtr;
    dst->evalRateRuleRatesPtr = src->evalRateRuleRatesPtr;
    dst->getEventTriggerPtr = src->getEventTriggerPtr;
    dst->getEventPriorityPtr = src->getEventPriorityPtr;
    dst->getEventDelayPtr = src->getEventDelayPtr;
    dst->eventTriggerPtr = src->eventTriggerPtr;
    dst->eventAssignPtr = src->eventAssignPtr;
    dst->evalVolatileStoichPtr = src->evalVolatileStoichPtr;
    dst->evalConversionFactorPtr = src->evalConversionFactorPtr;
}


ExecutableModel* LLVMModelGenerator::createModel(const std::string& sbml,
        uint options)
{
    bool forceReCompile = options & LoadSBMLOptions::RECOMPILE;

    string md5;

    if (!forceReCompile)
    {
        // check for a chached copy
        md5 = rr::getMD5(sbml);

        if (options & LoadSBMLOptions::CONSERVED_MOIETIES)
        {
            md5 += "_conserved";
        }

        ModelPtrMap::const_iterator i;

        SharedModelPtr sp;

        cachedModelsMutex.lock();

        if ((i = cachedModels.find(md5)) != cachedModels.end())
        {
            sp = i->second.lock();
        }

        cachedModelsMutex.unlock();

        // we could have recieved a bad ptr, a model could have been deleted,
        // in which case, we should have a bad ptr.

        if (sp)
        {
            Log(Logger::LOG_DEBUG) << "found a cached model for " << md5;
            return new LLVMExecutableModel(sp, createModelData(*sp->symbols, sp->random));
        }
        else
        {
            Log(Logger::LOG_TRACE) << "no cached model found for " << md5
                    << ", creating new one";
        }
    }

    SharedModelPtr rc(new ModelResources());

    ModelGeneratorContext context(sbml, options);

    rc->evalInitialConditionsPtr =
            EvalInitialConditionsCodeGen(context).createFunction();

    rc->evalReactionRatesPtr =
            EvalReactionRatesCodeGen(context).createFunction();
//.........这里部分代码省略.........
开发者ID:Peter-J,项目名称:roadrunner,代码行数:101,代码来源:LLVMModelGenerator.cpp

示例9: update

void Sampler::update() {

	if(!wasRecording && gui.recording) {
		// recording just started.
		//ofSoundStreamStop();
		//ofSoundStreamSetup(0, 1, ofGetAppPtr(), 44100, 512, 4);

	}
	
	wasRecording = gui.recording;
	if(gui.input==INPUT_ACCELEROMETER) {
		#ifdef TARGET_OF_IPHONE
		ofPoint a = ofxAccelerometer.getOrientation();
		float ax = a.x;// + a.y;
	//	printf("%f\n", ax);
		float pitch = ofMap(ax, -45, 45, 1, 0);
		float vol = 0.8;
		if(gui.useYAxisAsVolume) {
			vol = ofMap(a.y, -45, 45, 1, 0);
		}
		
		if(ax<-45) pitch = 1;
		else if(ax>45) {
			pitch = 0;
//			pitch = ofMap(ax, 45, 135, 0, 1, true);
		}
		int currNote = pitch*vision.levels.size();
		if(currNote!=lastNote) {
			
			playSound(vol, pitch);
		}
		#endif
	}
	ofBackground(0,0,0);
	vision.numLevels = gui.noteRange;
	vision.video = &video;
	// the vision code works out how much average change there is in each of
	// either vertical or horizontal strips across the screen.
	// this bit of code finds out if the strip with the most change
	// is a different strip from the last strip, and then triggers that note.
	float max = 0;
	int currMaxLevel = -1;
	for(int i = 0; i < vision.levels.size(); i++) {

		if(max<vision.levels[i].second) {
			max = vision.levels[i].second;
			currMaxLevel = i;
		}
	}

	if(lastMaxLevel!=currMaxLevel) {
		//printf("Playing note %d %f\n", currMaxLevel, max);
		float volume = ofMap(max, 0, 0.5, 0, 1);
		if(volume>1) volume = 1;
		if(volume>movementThreshold) { // some threshold
			lastMaxLevel = currMaxLevel;
			if(gui.input==INPUT_CAMERA) playSound(volume, 1.f - (float)currMaxLevel/vision.levels.size());
		} else {
			currMaxLevel = -1;
		}
	}

	lastMaxLevel = currMaxLevel;



	vision.update();
	
	
	if(gui.mustLoadSound) {
		controlMutex.lock();
		sample.loadFromFile(gui.soundFile);

		controlMutex.unlock();
		gui.mustLoadSound = false;
		noteOffset = 0;
	}
	
	
	/*for(int i = 0; i < particles.size(); i++) {
		particles[i].update();
		if(!particles[i].alive) {
			particles.erase(particles.begin()+i);
			i--;
		}
	}*/
}
开发者ID:HellicarAndLewis,项目名称:MulticolouredMagic,代码行数:87,代码来源:Sampler.cpp

示例10: createModel

ExecutableModel* LLVMModelGenerator::createModel(const std::string& sbml,
        uint options)
{
    bool computeAndAssignConsevationLaws =
            options & ModelGenerator::ComputeAndAssignConsevationLaws;

    bool forceReCompile = options & ModelGenerator::ForceReCompile;

    string md5;

    if (!forceReCompile)
    {
        // check for a chached copy
        md5 = rr::getMD5(sbml);

        ModelPtrMap::const_iterator i;

        SharedModelPtr sp;

        cachedModelsMutex.lock();

        if ((i = cachedModels.find(md5)) != cachedModels.end())
        {
            sp = i->second.lock();
        }

        cachedModelsMutex.unlock();

        // we could have recieved a bad ptr, a model could have been deleted,
        // in which case, we should have a bad ptr.

        if (sp)
        {
            Log(Logger::PRIO_DEBUG) << "found a cached model for " << md5;
            return new LLVMExecutableModel(sp);
        }
        else
        {
            Log(Logger::PRIO_TRACE) << "no cached model found for " << md5
                    << ", creating new one";
        }
    }

    SharedModelPtr rc(new ModelResources());

    ModelGeneratorContext context(sbml, computeAndAssignConsevationLaws);

    rc->evalInitialConditionsPtr =
            EvalInitialConditionsCodeGen(context).createFunction();

    rc->evalReactionRatesPtr =
            EvalReactionRatesCodeGen(context).createFunction();

    rc->getBoundarySpeciesAmountPtr =
            GetBoundarySpeciesAmountCodeGen(context).createFunction();

    rc->getFloatingSpeciesAmountPtr =
            GetFloatingSpeciesAmountCodeGen(context).createFunction();

    rc->getBoundarySpeciesConcentrationPtr =
            GetBoundarySpeciesConcentrationCodeGen(context).createFunction();

    rc->getFloatingSpeciesConcentrationPtr =
            GetFloatingSpeciesConcentrationCodeGen(context).createFunction();

    rc->getCompartmentVolumePtr =
            GetCompartmentVolumeCodeGen(context).createFunction();

    rc->getGlobalParameterPtr =
            GetGlobalParameterCodeGen(context).createFunction();

    rc->evalRateRuleRatesPtr =
            EvalRateRuleRatesCodeGen(context).createFunction();

    rc->getEventTriggerPtr =
            GetEventTriggerCodeGen(context).createFunction();

    rc->getEventPriorityPtr =
            GetEventPriorityCodeGen(context).createFunction();

    rc->getEventDelayPtr =
            GetEventDelayCodeGen(context).createFunction();

    rc->eventTriggerPtr =
            EventTriggerCodeGen(context).createFunction();

    rc->eventAssignPtr =
            EventAssignCodeGen(context).createFunction();

    rc->evalVolatileStoichPtr =
            EvalVolatileStoichCodeGen(context).createFunction();

    rc->evalConversionFactorPtr =
            EvalConversionFactorCodeGen(context).createFunction();

    if (options & ModelGenerator::ReadOnlyModel)
    {
        rc->setBoundarySpeciesAmountPtr = 0;
        rc->setBoundarySpeciesConcentrationPtr = 0;
        rc->setFloatingSpeciesConcentrationPtr = 0;
//.........这里部分代码省略.........
开发者ID:Alcibiades586,项目名称:roadrunner,代码行数:101,代码来源:LLVMModelGenerator.cpp

示例11: Result

  operator TextCache::Result() const {
#ifdef ENABLE_OPENGL
    return texture;
#else
    return { data, width, width, height };
#endif
  }
开发者ID:acasadoalonso,项目名称:LK8000,代码行数:7,代码来源:Cache.cpp

示例12: Unlock

 void Unlock() { text_cache_mutex.unlock(); }
开发者ID:acasadoalonso,项目名称:LK8000,代码行数:1,代码来源:Cache.cpp

示例13: Lock

 void Lock() { text_cache_mutex.lock(); }
开发者ID:acasadoalonso,项目名称:LK8000,代码行数:1,代码来源:Cache.cpp

示例14: Unlock

void Message::Unlock() {
  CritSec_Messages.unlock();
}
开发者ID:atrebbi,项目名称:LK8000,代码行数:3,代码来源:Message.cpp

示例15: LockComm

void LockComm() {
  CritSec_Comm.lock();
}
开发者ID:acasadoalonso,项目名称:LK8000,代码行数:3,代码来源:device.cpp


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