本文整理汇总了C++中MessageManagerLock类的典型用法代码示例。如果您正苦于以下问题:C++ MessageManagerLock类的具体用法?C++ MessageManagerLock怎么用?C++ MessageManagerLock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessageManagerLock类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logMessage
void logMessage (const String& message)
{
MessageManagerLock mm (this);
if (mm.lockWasGained()) // this lock may fail if this thread has been told to stop
owner.logMessage (message);
}
示例2: run
void run()
{
#if JUCE_LINUX
{
MessageManagerLock mml (this);
if (! mml.lockWasGained())
return;
owner.updateContext();
owner.updateContextPosition();
}
#endif
while (! threadShouldExit())
{
const uint32 startOfRendering = Time::getMillisecondCounter();
if (! owner.performRender())
break;
const int elapsed = (int) (Time::getMillisecondCounter() - startOfRendering);
Thread::sleep (jmax (1, (1000 / 60) - elapsed));
}
#if JUCE_LINUX
owner.deleteContext();
#endif
}
示例3: run
//==============================================================================
void run()
{
{
// Allow the message thread to finish setting-up the context before using it..
MessageManagerLock mml (this);
if (! mml.lockWasGained())
return;
}
nativeContext->makeActive();
initialiseOnThread();
#if JUCE_USE_OPENGL_SHADERS && ! JUCE_OPENGL_ES
shadersAvailable = OpenGLShaderProgram::getLanguageVersion() > 0;
#endif
while (! threadShouldExit())
{
const uint32 frameRenderStartTime = Time::getMillisecondCounter();
if (renderFrame())
waitForNextFrame (frameRenderStartTime);
}
shutdownOnThread();
}
示例4: mml
void LAudioAppComponent::getNextAudioBlock( const AudioSourceChannelInfo& bufferToFill ) {
if(stopped
|| !audioOpen
|| !hasCallback("getNextAudioBlock")
|| (audioOpen && audioSourcePlayer.getCurrentSource()==nullptr) )
{
bufferToFill.clearActiveBufferRegion();
return;
}
if(hasCallback("getNextAudioBlock")) {
MessageManagerLock mml (Thread::getCurrentThread());
if (! mml.lockWasGained()) {
DBG("CAN'T GET LOCK");
return; // another thread is trying to kill us!
}
LAudioSampleBuffer audioBuffer(Ls, *bufferToFill.buffer);
callback("getNextAudioBlock", 0, {
bufferToFill.startSample,
bufferToFill.numSamples,
bufferToFill.buffer->getNumChannels(),
new LRefBase("AudioSampleBuffer", &audioBuffer)
});
if(volume>-1) {
if(volume) bufferToFill.buffer->applyGain(volume);
else bufferToFill.clearActiveBufferRegion();
}
}
}
示例5: postLocked
void PostWindowController::postLocked(const String& textToWrite,
const PostLevel pl,
bool isBold)
{
const MessageManagerLock mmLock;
if(mmLock.lockWasGained())
post(textToWrite, pl, isBold);
}
示例6: mm
bool LMRecorder::getCurrentFrame(GestureFrame &gestureFrame)
{
{
MessageManagerLock mm (Thread::getCurrentThread());
if (! mm.lockWasGained())
return false;
}
ScopedLock frameLock(frameMutex);
if (currentFrame != NULL) {
gestureFrame = *currentFrame;
return true;
}
return false;
}
示例7: paintComponent
void paintComponent()
{
if (needsUpdate)
{
MessageManagerLock mm (this);
if (! mm.lockWasGained())
return;
needsUpdate = false;
// you mustn't set your own cached image object when attaching a GL context!
jassert (get (component) == this);
const Rectangle<int> bounds (component.getLocalBounds());
if (! ensureFrameBufferSize (bounds.getWidth(), bounds.getHeight()))
return;
RectangleList invalid (bounds);
invalid.subtract (validArea);
validArea = bounds;
if (! invalid.isEmpty())
{
clearRegionInFrameBuffer (invalid);
{
ScopedPointer<LowLevelGraphicsContext> g (createOpenGLGraphicsContext (context, cachedImageFrameBuffer));
g->clipToRectangleList (invalid);
paintOwner (*g);
JUCE_CHECK_OPENGL_ERROR
}
if (! context.isActive())
context.makeActive();
}
JUCE_CHECK_OPENGL_ERROR
}
示例8: sl
bool OpenGLComponent::performRender()
{
const ScopedLock sl (contextLock);
#if JUCE_LINUX
updateContext();
#endif
if (context != nullptr)
{
if (! makeCurrentRenderingTarget())
return false;
if (needToUpdateViewport)
{
needToUpdateViewport = false;
glViewport (0, 0, getWidth(), getHeight());
}
renderOpenGL();
if (needToRepaint && (flags & allowSubComponents) != 0)
{
needToRepaint = false;
contextLock.exit(); // (MM must be locked before the context lock)
MessageManagerLock mmLock (renderThread);
contextLock.enter();
if (! mmLock.lockWasGained())
return false;
// you mustn't set your own cached image object for an OpenGLComponent!
jassert (dynamic_cast<OpenGLCachedComponentImage*> (getCachedComponentImage()) == cachedImage);
const Rectangle<int> bounds (getLocalBounds());
OpenGLFrameBuffer& frameBuffer = cachedImage->getFrameBuffer (bounds.getWidth(), bounds.getHeight());
{
RectangleList invalid (bounds);
invalid.subtract (cachedImage->validArea);
cachedImage->validArea = bounds;
if (! invalid.isEmpty())
{
jassert (getCurrentContext() != nullptr);
{
OpenGLGraphicsContext g (*getCurrentContext(), frameBuffer);
g.clipToRectangleList (invalid);
g.setFill (Colours::transparentBlack);
g.fillRect (bounds, true);
g.setFill (Colours::black);
paintSelf (g);
}
makeCurrentRenderingTarget();
}
}
glEnable (GL_TEXTURE_2D);
context->extensions.glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, frameBuffer.getTextureID());
context->copyTexture (bounds, Rectangle<int> (bounds.getWidth(),
bounds.getHeight()));
glBindTexture (GL_TEXTURE_2D, 0);
}
swapBuffers();
}
return true;
}