Beispiel #1
0
bool xtionni::BaseManager::finalize()
{
	if (!isInitialized_) return true;
	bool result = finalize_();
	isInitialized_ = !result;
	xtion_ = NULL;
	return result;
}
Beispiel #2
0
GLView::status_t
GLView::initialize_()
{
	finalize_();

	if(m_rc)
		return status::ALREADY_INITIALIZED;

	PIXELFORMATDESCRIPTOR pixel_format_desc = {
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
		PFD_TYPE_RGBA,
		24,
		0, 0, 0, 0, 0, 0,
		0,
		0,
		0,
		0, 0, 0, 0,
		32,
		0,
		0,
		PFD_MAIN_PLANE,
		0,
		0, 0, 0
	};

	if(flags() & DOUBLE_BUFFERING)
		pixel_format_desc.dwFlags |= PFD_DOUBLEBUFFER;
//	if(flags() & 

	m_dc = new DC(hwnd());
	int pixel_format = ChoosePixelFormat(*m_dc, &pixel_format_desc);
	int status = SetPixelFormat(*m_dc, pixel_format, &pixel_format_desc);

	if(! status)
	{
		delete m_dc;
		m_dc = NULL;

		return status::FAILED_TO_SET_PIXEL_FORMAT;
	}

	m_rc = wglCreateContext(*m_dc);
	wglMakeCurrent(*m_dc, m_rc);

//	glFlush();

	return st::NO_ERR;
}
Beispiel #3
0
GLView::~GLView()
{
	finalize_();
}
Beispiel #4
0
void DepTask::operator()()
{
    //Enqueue upstream tasks
    for (auto& vertex: _vertex->links())
    {
        if (!vertex->nodes().size()) continue;
        _sched->enqueue_priv(****vertex->nodes().begin());
    }
    
    {
        Mutex::Scoped _(_lock);
        //If there is an upstream task then we must wait to start
        if (_depUpWait > 0)
        {
            _state = State::depUpWait;
            DepTask_trace(*this, sout() << "Waiting for upstream. Wait task count: " << _depUpWait);
            return;
        }
        assert(!_depUpWait, "Task state corrupt");
        _state = State::exec;
        _thread = &Thread::current();
        if (_priority != Thread::priorityNormal()) _thread->setPriority(_priority);
    }
    
    DepTask_trace(*this, "Executing");
    try { exec(); } catch (std::exception& e) { Log_debug << info() << "Unexpected task execution error: " << e; }
    DepTask_trace(*this, "Completed");
    
    {
        Mutex::Scoped _(_lock);
        //restore priority to ensure its task-locality
        if (_priority != Thread::priorityNormal()) _thread->setPriority(Thread::priorityNormal());
        //consume any set interrupt to ensure its task-locality
        try { thread::current::interruptPoint(); } catch (...) {}
        _thread = nullptr;
    }
    
    //Finalize any upstream tasks that are waiting
    for (auto& vertex: _vertex->links())
    {
        if (!vertex->nodes().size()) continue;
        DepTask& e = ****vertex->nodes().begin();
        if (--e._depDownWait > 0) continue;
        Mutex::Scoped _(e._lock);
        e.finalize_();
    }
    
    {
        Mutex::Scoped _(_lock);
        //Re-enqueue any downstream tasks that are waiting
        for (auto& vertex: _vertex->links(DepNode::DepType::in))
        {
            if (!vertex->nodes().size()) continue;
            DepTask& e = ****vertex->nodes().begin();
            if (e._sched != _sched || e._bindId != _bindId) continue; //This task is not upstream of root
            if (--e._depUpWait > 0) continue;
            //Within enqueue_priv here we hold locks for both us and downstream,
            //but deadlock is not possible because downstream never holds locks for both itself and upstream
            _sched->enqueue_priv(e);
        }

        if (this == _root.lock())
        {
            //Root task must finalize itself
            --_depDownWait;
            finalize_();
        }
        else
        {
            //We must wait for downstream to finalize us
            _state = State::depDownWait;
            DepTask_trace(*this, sout() << "Waiting for downstream. Wait task count: " << _depDownWait);
        }
    }
}