code: func (s *StanServer) handleChannelDelete(c *channel) {
  	delete := false
  	cs := s.channels
  	cs.Lock()
  	a := c.activity
  	if a.preventDelete || a.deleteInProgress || c.ss.hasActiveSubs() {
  		if s.debug {
  			s.log.Debugf("Channel %q cannot be deleted: preventDelete=%v inProgress=%v hasActiveSubs=%v",
  				c.name, a.preventDelete, a.deleteInProgress, c.ss.hasActiveSubs())
  		}
  		c.stopDeleteTimer()
  	} else {
  		elapsed := time.Since(a.last)
  		if elapsed >= a.maxInactivity {
  			if s.debug {
  				s.log.Debugf("Channel %q is being deleted", c.name)
  			}
  			c.stopDeleteTimer()
  			// Leave in map for now, but mark as deleted. If we removed before
  			// completion of the removal, a new lookup could re-create while
  			// in the process of deleting it.
  			a.deleteInProgress = true
  			delete = true
  		} else {
  			var next time.Duration
  			if elapsed < 0 {
  				next = a.maxInactivity
  			} else {
  				// elapsed < a.maxInactivity
  				next = a.maxInactivity - elapsed
  			}
  			if s.debug {
  				s.log.Debugf("Channel %q cannot be deleted now, reset timer to fire in %v",
  					c.name, next)
  			}
  			c.resetDeleteTimer(next)
  		}
  	}
  	cs.Unlock()
  	if delete {
  		if testDeleteChannel {
  			time.Sleep(time.Second)
  		}
  		if s.isClustered {
  			s.replicateDeleteChannel(c.name)
  		} else {
  			s.processDeleteChannel(c.name)
  		}
  	}
  }
docs: // Check if the channel can be deleted. If so, do it in place.
  // This is called from the ioLoop by the leader or a standlone server.