示例#1
0
void TThread::Cancel() {
	TLock Lck(CriticalSection);

	if (!IsAlive()) { return; }
	Status = STATUS_CANCELLED;
	int code = pthread_cancel(ThreadHandle);
	EAssertR(code == 0, "Failed to cancel thread!");
}
示例#2
0
bool BufferManager::PutIn(PACKET& packet)
{
	std::unique_lock<std::mutex> Lck(m_localbufferMutex);
	if (GetRemainBufferInSecond() <= 0)
	{
		m_localbufferCV.wait(Lck);
	}
	m_localbuffer->push_back(packet);
	return true;
}
示例#3
0
HRESULT CAMRSplitter::RemoveOutputPins()
{
	CAutoLock Lck(&lock_filter);
	if (m_State != State_Stopped) {
		return VFW_E_NOT_STOPPED;
	}

	// we retire all current output pins
	for (int i=0; i<output.GetCount(); i++) {
		CAMROutputPin *pin = output[i];
		if (pin->IsConnected()) {
			pin->GetConnected()->Disconnect();
			pin->Disconnect();
		}
		retired.Add(pin);
	}
	output.RemoveAll();
	return NOERROR;
}
示例#4
0
bool BufferManager::PullOut(PACKET& packet)
{
	std::unique_lock<std::mutex> Lck(m_localbufferMutex);
	if (!m_localbuffer->empty())
	{
		packet = m_localbuffer->front();
		m_localbuffer->pop_front();
		if (GetRemainBufferInSecond() <= MAX_BUFFER_SIZE_IN_SECONDS / 2)
		{
			m_localbufferCV.notify_one();
		}
	}
	else
	{
		//std::cout << "buffer is empty" << std::endl;
		return false;
	}
	return true;
}
示例#5
0
文件: GWindow.cpp 项目: FEI17N/Lgi
GRect &GWindow::GetPos()
{
	static GRect r;
	
	r = Pos;
	
	GLocker Lck(Wnd, _FL);
	if (Lck.Lock())
	{
		BRect frame = Wnd->Frame();
		r.x1 = frame.left;
		r.y1 = frame.top;
		r.x2 = frame.right;
		r.y2 = frame.bottom;
		Pos = frame;

		Lck.Unlock();
	}
	
	return r;
}
示例#6
0
void TThread::Start() {
    TLock Lck(CriticalSection);

    if (IsAlive()) {
        printf("Tried to start a thread that is already alive! Ignoring ...\n");
        return;
    }
    if (IsCancelled()) {
        return;
    }

    Status = STATUS_STARTED;

    // create new thread
    int code = pthread_create(
                   &ThreadHandle,	// Handle
                   NULL,			// Attributes
                   EntryPoint,		// Thread func
                   this			// Arg
               );
    EAssert(code == 0);
}
示例#7
0
bool TThread::IsFinished() {
    TLock Lck(CriticalSection);
    return Status == STATUS_FINISHED;
}
示例#8
0
bool TThread::IsCancelled() {
    TLock Lck(CriticalSection);
    return Status == STATUS_CANCELLED;
}
示例#9
0
bool TThread::IsAlive() {
    TLock Lck(CriticalSection);
    return Status == STATUS_STARTED || IsCancelled();
}
示例#10
0
TThread::~TThread() {
    TLock Lck(CriticalSection);
    if (IsAlive() && !IsCancelled()) {
        Cancel();
    }
}
示例#11
0
void TThread::SetFinished(void *pArg) {
    TThread *pThis = (TThread *) pArg;

    TLock Lck(pThis->CriticalSection);
    pThis->Status = STATUS_FINISHED;
}
示例#12
0
void BufferManager::SubDurationRemain(double duration)
{
	std::unique_lock<std::mutex> Lck(m_localbufferMutex);
	m_buffer_in_duration_remain -= duration;
}