Exemplo n.º 1
0
int main() {

	/*Driver code to test the implementation*/
	head = NULL; // empty list. set head as NULL. 
	
	// Calling an Insert and printing list both in forward as well as reverse direction. 
	InsertAtTail(2); Print(); ReversePrint();
	InsertAtTail(4); Print(); ReversePrint();
	InsertAtHead(6); Print(); ReversePrint();
	InsertAtTail(8); Print(); ReversePrint();
	
}
Exemplo n.º 2
0
int main(int argc, char const *argv[])
{

	/*Driver code to test the implementation*/
	node* head = NULL; // empty list. set head as NULL.
	head = GetNewNode(1);
	
	// Calling an Insert and printing list both in forward as well as reverse direction. 
	InsertAtTail(2, head); Print(head);
	InsertAtTail(4, head); Print(head);
	InsertAtTail(8, head); Print(head);
	/* code */
	return 0;
}
gxConfigListNode *gxConfig::Add(const gxString &s)
{
  gxConfigListNode *node = new gxConfigListNode(s);
  if(!node) return 0; // Could not allocate memory for the node
  InsertAtTail((gxListNodeB *)node);
  return node;
}
void RUIUseBufferList::_UnlinkAndInsertTail(RUIUseBuffer* pRUIUseBuffer)
{
	if (pRUIUseBuffer == NULL)
	{
		ASSERT(FALSE);
		return;
	}

	Unlink(pRUIUseBuffer);
	InsertAtTail(pRUIUseBuffer);
}
VOID
FxWakeInterruptMachine::ProcessEvent(
    __in FxWakeInterruptEvents Event
    )
{
    NTSTATUS status;
    KIRQL irql;
    LONGLONG timeout = 0;
 
    //
    // Acquire state machine *queue* lock, raising to DISPATCH_LEVEL
    //
    Lock(&irql);

    if (IsFull()) {
        //
        // The queue is full. This should never happen.
        //
        Unlock(irql);

        ASSERTMSG("The wake interrupt state machine queue is full\n", 
                  FALSE);
        return;
    }

    if (IsClosedLocked()) {
        //
        // The queue is closed. This should never happen.
        //
        DoTraceLevelMessage(
          m_PkgPnp->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
          "WDFDEVICE 0x%p !devobj 0x%p current wake interrupt state"
          " %!FxWakeInterruptStates! dropping event "
          "%!FxWakeInterruptEvents! because of a closed queue",
          m_PkgPnp->GetDevice()->GetHandle(),
          m_PkgPnp->GetDevice()->GetDeviceObject(),
          m_CurrentState, 
          Event);
            
        Unlock(irql);
        
        ASSERTMSG(
            "The wake interrupt state machine queue is closed\n", 
            FALSE
            );
        return;
    }

    //
    // Enqueue the event
    //
    m_Queue[InsertAtTail()] = Event;

    //
    // Drop the state machine *queue* lock
    //
    Unlock(irql);
    
    //
    // Now, if we are running at PASSIVE_LEVEL, attempt to run the state machine
    // on this thread. If we can't do that, then queue a work item.
    //
    if (irql == PASSIVE_LEVEL) {
        //
        // Try to acquire the state machine lock
        //
        status = m_StateMachineLock.AcquireLock(
                    m_PkgPnp->GetDriverGlobals(), 
                    &timeout
                    );
        if (FxWaitLockInternal::IsLockAcquired(status)) {
            FxPostProcessInfo info;

            //
            // We now hold the state machine lock.  So call the function that
            // dispatches the next state.
            //
            ProcessEventInner(&info);

            //
            // The pnp state machine should be the only one deleting the object
            //
            ASSERT(info.m_DeleteObject == FALSE);

            //
            // Release the state machine lock
            //
            m_StateMachineLock.ReleaseLock(
                m_PkgPnp->GetDriverGlobals()
                );

            info.Evaluate(m_PkgPnp);

            return;
        }
    }
    
    //
    // For one reason or another, we couldn't run the state machine on this
    // thread.  So queue a work item to do it.
    //
    QueueToThread();
    return;
}