func (r *relayItems) Entomb(id uint32, deleteAfter time.Duration) (relayItem, bool) {
	r.Lock()
	if r.tombs > _maxRelayTombs {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Too many tombstones, deleting relay item immediately.")
		return r.Delete(id)
	}
	item, ok := r.items[id]
	if !ok {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Can't find relay item to entomb.")
		return item, false
	}
	if item.tomb {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Re-entombing a tombstone.")
		return item, false
	}
	r.tombs++
	item.tomb = true
	r.items[id] = item
	r.Unlock()

	// TODO: We should be clearing these out in batches, rather than creating
	// individual timers for each item.
	time.AfterFunc(deleteAfter, func() { r.Delete(id) })
	return item, true
}
func (r *relayItems) Entomb(id uint32, deleteAfter time.Duration) (relayItem, bool) {
	r.Lock()
	if r.tombs > _maxRelayTombs {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Too many tombstones, deleting relay item immediately.")
		return r.Delete(id)
	}
	item, ok := r.items[id]
	if !ok {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Can't find relay item to entomb.")
		return item, false
	}
	if item.tomb {
		r.Unlock()
		r.logger.WithFields(LogField{"id", id}).Warn("Re-entombing a tombstone.")
		return item, false
	}
	r.tombs++
	item.tomb = true
	r.items[id] = item
	r.Unlock()

	
	
	time.AfterFunc(deleteAfter, func() { r.Delete(id) })
	return item, true
}
func ( r * relayItems ) Entomb ( id uint32 , deleteAfter time . Duration ) ( relayItem , bool ) { r . Lock ( ) if r . tombs > _maxRelayTombs { r . Unlock ( ) r . logger . WithFields ( LogField { " " , id } ) . Warn ( " " ) return r . Delete ( id ) } item , ok := r . items [ id ] if ! ok { r . Unlock ( ) r . logger . WithFields ( LogField { " " , id } ) . Warn ( " " ) return item , false } if item . tomb { r . Unlock ( ) r . logger . WithFields ( LogField { " " , id } ) . Warn ( " " ) return item , false } r . tombs ++ item . tomb = true r . items [ id ] = item r . Unlock ( ) // TODO: We should be clearing these out in batches, rather than creating // individual timers for each item. time . AfterFunc ( deleteAfter , func ( ) { r . Delete ( id ) } ) return item , true }
// Entomb sets the tomb bit on a relayItem and schedules a garbage collection. It
// returns the entombed item, along with a bool indicating whether we completed
// a relayed call.
Entomb sets the tomb bit on a relayItem and schedules a garbage collection . It returns the entombed item along with a bool indicating whether we completed a relayed call .