Exemplo n.º 1
0
void Invoker::CreateInvoker(ThreadPtr t, MutexPtr mutex)
{
    APP_API_ASSERT(t);
    APP_API_ASSERT(mutex);

    m_Thread = t;
    m_Mutex = mutex;
    m_Created = TRUE;
}
Exemplo n.º 2
0
void SpriteInstance::Load(const std::string& resName)
{
    m_CurrentAnimation  = 0;
    m_CurrentFrame      = 0;
    m_AnimationCount    = 0;
    m_FramesCount       = 0;
    m_TotalFrames       = 0;
    m_TotalTextures     = 0;

    m_Frames->clear();
    m_Animations->clear();
    m_Atlases->clear();

    {
        SpriteFramesListPtr frames(new SpriteFramesList());
        SpriteAnimationsListPtr anims(new SpriteAnimationsList());
        SpriteTexturesListPtr textures(new SpriteTexturesList());

        if (!AssetsManager::getRef().GetMapping(resName, frames, anims, textures))
        {
            APP_API_ASSERT("Error when loading mapping file." && FALSE);
            LogMessage(LOG_ERR, "Error when loading mapping file " << resName.c_str());
            return;
        }

        //Silent copy
        *m_Frames = *frames;
        *m_Animations = *anims;
        *m_Atlases = *textures;
    }

    // Load textures
    const size_t atlasesSize = m_Atlases->size();
    for (size_t i = 0; i < atlasesSize; ++i)
    {
        if (!m_Atlases->get(i).texture())
        {
            std::string textureFile	= MEDIA_PATH + m_Atlases->get(i).name; //PVR
            video::ITexture* texture = m_Driver->getTexture(textureFile.c_str());
            APP_API_ASSERT(texture);

            m_Atlases->get(i).texture(texture);
        }
    }

    m_TotalTextures = m_Atlases->size();
    m_TotalFrames = m_Frames->size();
    m_AnimationCount = m_Animations->size();
    if (m_CurrentAnimation < m_AnimationCount)
    {
        m_FramesCount = m_Animations->get(m_CurrentAnimation).frames.size();
    }
}
Exemplo n.º 3
0
bool_t Invoker::NeedInvoke() const
{
    APP_API_ASSERT(m_Created);

    if (m_Thread)
        return boost::this_thread::get_id() != m_Thread->get_id();
    else if (m_ThreadId)
        return *m_ThreadId != boost::this_thread::get_id();

    APP_API_ASSERT("There are no acceptable comparator for thread id" && FALSE);

    return FALSE;
}
Exemplo n.º 4
0
void Invoker::BeginInvoke( InvokeFunction_t f )
{
    APP_API_ASSERT(m_Created);
    boost::lock_guard<boost::mutex> lock(*m_Mutex);

    m_Funcs.push(f);
}
void EditablePagedLevel::Init()
{
#ifdef USE_INVOKER
    if (NeedInvoke())
    {
        BeginInvoke(std::bind(&EditablePagedLevel::Init, this));
    }
    else
#endif
    {
        m_PageList.clear();
        m_PagesInView.clear();
        m_SelectedObject.reset();

        for (size_t i = 0; i < MaxPagesInView; ++i)
        {
            PageInstance* page = new PageInstance();
            APP_API_ASSERT(page->Init(i));

            //Add clear page
            AddPage(page);

            m_PagesInView.push_back(page);
        }
    }
}
Exemplo n.º 6
0
void Invoker::BeginInvoke( InvokeFunction_t f )
{
    APP_API_ASSERT(m_Created);
    boost::mutex::scoped_try_lock lock(*m_Mutex);

    m_Funcs.push(f);
}
Exemplo n.º 7
0
void Invoker::CreateInvoker(ThreadPtr t)
{
    APP_API_ASSERT(t);

    m_Mutex.reset(new Mutex_t());
    m_Thread = t;
    m_Created = TRUE;
}
Exemplo n.º 8
0
//Must be called from secondary thread context
void Invoker::UpdateInvoker()
{
    APP_API_ASSERT(m_Created);

    boost::mutex::scoped_try_lock lock(*m_Mutex);

    while(!m_Funcs.empty())
    {
		m_Funcs.front()();
        CondVar.notify_one();
		m_Funcs.pop();
    }
}
Exemplo n.º 9
0
void Invoker::PerformCrossThreadCall( InvokeFunction_t f, Invoker* invobj, bool_t wait_until_done )
{
    APP_API_ASSERT(invobj->IsInvokerCreated());

    if (!wait_until_done)
    {
        invobj->BeginInvoke(f);
    }
    else
    {
        boost::unique_lock<boost::mutex> lock(*invobj->m_Mutex);
        invobj->m_Funcs.push(f);
        CondVar.wait(lock);
    }
}
Exemplo n.º 10
0
bool_t Invoker::NeedInvoke() const
{
    APP_API_ASSERT(m_Created);
    return boost::this_thread::get_id() != m_Thread->get_id();
}