code: func (na *cnmNetworkAllocator) IsTaskAllocated(t *api.Task) bool {
  	// If the task is not found in the allocated set, then it is
  	// not allocated.
  	if _, ok := na.tasks[t.ID]; !ok {
  		return false
  	}
  
  	// If Networks is empty there is no way this Task is allocated.
  	if len(t.Networks) == 0 {
  		return false
  	}
  
  	// To determine whether the task has its resources allocated,
  	// we just need to look at one global scope network (in case of
  	// multi-network attachment).  This is because we make sure we
  	// allocate for every network or we allocate for none.
  
  	// Find the first global scope network
  	for _, nAttach := range t.Networks {
  		// If the network is not allocated, the task cannot be allocated.
  		localNet, ok := na.networks[nAttach.Network.ID]
  		if !ok {
  			return false
  		}
  
  		// Nothing else to check for local scope network
  		if localNet.isNodeLocal {
  			continue
  		}
  
  		// Addresses empty. Task is not allocated.
  		if len(nAttach.Addresses) == 0 {
  			return false
  		}
  
  		// The allocated IP address not found in local endpoint state. Not allocated.
  		if _, ok := localNet.endpoints[nAttach.Addresses[0]]; !ok {
  			return false
  		}
  	}
  
  	return true
  }
docs: // IsTaskAllocated returns if the passed task has its network resources allocated or not.