コード例 #1
0
void
VariablesView::VariableTableModel::SetStackFrame(Thread* thread,
	StackFrame* stackFrame)
{
	if (fContainer != NULL) {
		AutoLocker<ValueNodeContainer> containerLocker(fContainer);

		if (fContainerListener != NULL)
			fContainer->RemoveListener(fContainerListener);

		fContainer->RemoveAllChildren();
		containerLocker.Unlock();
		fContainer->ReleaseReference();
		fContainer = NULL;
	}

	fNodeTable.Clear(true);

	if (!fNodes.IsEmpty()) {
		int32 count = fNodes.CountItems();
		for (int32 i = 0; i < count; i++)
			fNodes.ItemAt(i)->ReleaseReference();
		fNodes.MakeEmpty();
		NotifyNodesRemoved(TreeTablePath(), 0, count);
	}

	fStackFrame = stackFrame;
	fThread = thread;

	if (fStackFrame != NULL) {
		fContainer = new(std::nothrow) ValueNodeContainer;
		if (fContainer == NULL)
			return;

		status_t error = fContainer->Init();
		if (error != B_OK) {
			delete fContainer;
			fContainer = NULL;
			return;
		}

		AutoLocker<ValueNodeContainer> containerLocker(fContainer);

		if (fContainerListener != NULL)
			fContainer->AddListener(fContainerListener);

		for (int32 i = 0; Variable* variable = fStackFrame->ParameterAt(i);
				i++) {
			_AddNode(variable);
		}

		for (int32 i = 0; Variable* variable
				= fStackFrame->LocalVariableAt(i); i++) {
			_AddNode(variable);
		}

//		if (!fNodes.IsEmpty())
//			NotifyNodesAdded(TreeTablePath(), 0, fNodes.CountItems());
	}
}
コード例 #2
0
void
VariablesView::VariableTableModel::ValueNodeChildrenCreated(
	ValueNode* valueNode)
{
	if (fContainer == NULL)
		return;

	AutoLocker<ValueNodeContainer> containerLocker(fContainer);

	// check whether we know the node
	ValueNodeChild* nodeChild = valueNode->NodeChild();
	if (nodeChild == NULL)
		return;

	ModelNode* modelNode = fNodeTable.Lookup(nodeChild);
	if (modelNode == NULL)
		return;

	// Iterate through the children and create model nodes for the ones we
	// don't know yet.
	int32 childCount = valueNode->CountChildren();
	for (int32 i = 0; i < childCount; i++) {
		ValueNodeChild* child = valueNode->ChildAt(i);
		if (fNodeTable.Lookup(child) == NULL) {
			_AddNode(modelNode->GetVariable(), modelNode, child,
				child->IsInternal());
		}
	}
}
コード例 #3
0
status_t
ValueNodeManager::SetStackFrame(Thread* thread,
	StackFrame* stackFrame)
{
	if (fContainer != NULL) {
		AutoLocker<ValueNodeContainer> containerLocker(fContainer);

		fContainer->RemoveListener(this);

		fContainer->RemoveAllChildren();
		containerLocker.Unlock();
		fContainer->ReleaseReference();
		fContainer = NULL;
	}

	fStackFrame = stackFrame;
	fThread = thread;

	if (fStackFrame != NULL) {
		fContainer = new(std::nothrow) ValueNodeContainer;
		if (fContainer == NULL)
			return B_NO_MEMORY;

		status_t error = fContainer->Init();
		if (error != B_OK) {
			delete fContainer;
			fContainer = NULL;
			return error;
		}

		AutoLocker<ValueNodeContainer> containerLocker(fContainer);

		fContainer->AddListener(this);

		for (int32 i = 0; Variable* variable = fStackFrame->ParameterAt(i);
				i++) {
			_AddNode(variable);
		}

		for (int32 i = 0; Variable* variable
				= fStackFrame->LocalVariableAt(i); i++) {
			_AddNode(variable);
		}
	}

	return B_OK;
}
コード例 #4
0
void InsertEntity(ilist* list, int index, int entity) {
    ilist* ins = NULL;

    ins = (ilist *)_AddNode(ins, entity, (list+index*sizeof(ilist))); 
    if(ins == NULL) {
	puts("!!! ERROR: cannot add an entity !!!");
	exit(-1);
    }

    printf("%p\n", (list+(index)*sizeof(ilist)));

}
コード例 #5
0
ilist* CreateList() {
    ilist* list = NULL;

    list = _AddNode(list, '\0', NULL);

    if(list == NULL) {
	puts("!!!cannot create a list!!!");
	exit(-1);

    }

    return list;

}
コード例 #6
0
int TimerThread::AddNode( TimerObject *client, int event, int inteval )
{
	//gLog.log("AddNode before size %ld", mList.size() );
	time_t now = time(0);
	struct TimerNode *node = new TimerNode;
	node->mNextTime = now+inteval;
	node->mInteval = inteval;
	node->mEvent = event;
	node->mClient = client;

	pthread_mutex_lock(&mTimerMutex);
	_AddNode( node );
	pthread_mutex_unlock(&mTimerMutex);
	//gLog.log("AddNode after size %ld", mList.size() );
	return 0;
}
コード例 #7
0
void
VariablesView::VariableTableModel::_AddNode(Variable* variable)
{
	// create the node child for the variable
	ValueNodeChild* nodeChild = new (std::nothrow) VariableValueNodeChild(
		variable);
	BReference<ValueNodeChild> nodeChildReference(nodeChild, true);
	if (nodeChild == NULL || !fContainer->AddChild(nodeChild)) {
		delete nodeChild;
		return;
	}

	// create the model node
	status_t error = _AddNode(variable, NULL, nodeChild, false);
	if (error != B_OK)
		return;

	// automatically add child nodes for the top level nodes
	_AddChildNodes(nodeChild);
}
コード例 #8
0
void *TimerThread::TimerLoop( void * )
{
	TimerNode *node, *node2;
 	//list<TimerNode*>::iterator iList;
	time_t now = time(0);

	while (true )
	{
		if( mList.GetCount() == 0 )
		{
			sleep(1);
			now = time(0);
			continue;
		}

		//node = mList.front();
		node = (TimerNode*)(mList.GetHead()->DataBuf());
//		gLog.log("now %d node %d", (int)now, (int)node->mNextTime);
		if( node->mNextTime <= now )
		{
			gLog.log("next %d interval %d event %d mClient %p", (int)node->mNextTime, (int)node->mInteval, node->mEvent, node->mClient );

			node->mClient->TimerCallback( node->mEvent );

			pthread_mutex_lock(&mTimerMutex);
			//node->mNextTime += node->mInteval;
			node->mNextTime = now + node->mInteval;
			_AddNode( node );
			//mList.pop_front();
			mList.RemoveHead();
			pthread_mutex_unlock(&mTimerMutex);

			continue;
		}

		sleep(1);		// process next seconds.
		now = time(0);
	}

	return NULL;
}