// Default in-memory implementation
351847
func (this WebhookMap) Send(domain, serviceKey, eventKey string, message interface{}, templateString string) error {
	m := this[serviceKey]
	if m == nil {
		return ErrNoServiceDefined
	}
	hook, has := m[eventKey]
	if !has {
		return ErrNoWebhookDefined
	}
	return hook.Send(message, templateString)
}
389959
func Default(address ...string) (server *Server) {
	c := &Options{}
	for _, addr := range address {
		c.Entries = append(c.Entries, Entry{Address: addr})
	}
	return New(c)
}
973145
func (store *defaultGroupStore) inBulkSetAck(wg *sync.WaitGroup) {
	for {
		bsam := <-store.bulkSetAckState.inMsgChan
		if bsam == nil {
			break
		}
		ring := store.msgRing.Ring()
		var rightwardPartitionShift uint64
		if ring != nil {
			rightwardPartitionShift = 64 - uint64(ring.PartitionBitCount())
		}
		b := bsam.body
		// div mul just ensures any trailing bytes are dropped
		l := len(b) / _GROUP_BULK_SET_ACK_MSG_ENTRY_LENGTH * _GROUP_BULK_SET_ACK_MSG_ENTRY_LENGTH
		for o := 0; o < l; o += _GROUP_BULK_SET_ACK_MSG_ENTRY_LENGTH {
			keyA := binary.BigEndian.Uint64(b[o:])
			if ring != nil && !ring.Responsible(uint32(keyA>>rightwardPartitionShift)) {
				atomic.AddInt32(&store.inBulkSetAckWrites, 1)
				timestampbits := binary.BigEndian.Uint64(b[o+32:]) | _TSB_LOCAL_REMOVAL
				ptimestampbits, err := store.write(keyA, binary.BigEndian.Uint64(b[o+8:]), binary.BigEndian.Uint64(b[o+16:]), binary.BigEndian.Uint64(b[o+24:]), timestampbits, nil, true)
				if err != nil {
					atomic.AddInt32(&store.inBulkSetAckWriteErrors, 1)
				} else if ptimestampbits >= timestampbits {
					atomic.AddInt32(&store.inBulkSetAckWritesOverridden, 1)
				}
			}
		}
		store.bulkSetAckState.inFreeMsgChan <- bsam
	}
	wg.Done()
}
719877
func (c *Calcium) doReallocNodesMemory(ctx context.Context, nodeContainersInfo nodeContainers, memory int64) error {
	// 只 check 增量情况下是否满足所需
	for node, containers := range nodeContainersInfo {
		if cap := int(node.MemCap / memory); cap < len(containers) {
			return types.NewDetailedErr(types.ErrInsufficientRes, node.Name)
		}
	}
	return nil
}
289600
func init() {
	buf, err := GetBytes(9)
	if err != nil {
		localID = [9]byte{'D', 'e', 'f', 'a', 'u', 'l', 't', 'I', 'D'}
	} else {
		_, err = io.ReadFull(bytes.NewBuffer(buf), localID[:])
		if err != nil {
			localID = [9]byte{'D', 'e', 'f', 'a', 'u', 'l', 't', 'I', 'D'}
		}
	}
}
1317179
func getMemoryCapacity() (uint64, error) {
	out, err := ioutil.ReadFile("/proc/meminfo")
	if err != nil {
		return 0, err
	}
	return parseCapacity(out, memoryCapacityRegexp)
}
155142
func (s *Scheme) Default(src Object) {
	if fn, ok := s.defaulterFuncs[reflect.TypeOf(src)]; ok {
		fn(src)
	}
}
120128
func NewMemoryConfigurationSource() MemorySource {
	memoryConfigSource := new(MemoryConfigurationSource)
	memoryConfigSource.priority = memoryVariableSourcePriority
	memoryConfigSource.Configurations = make(map[string]interface{})
	memoryConfigSource.CallbackCheck = make(chan bool)
	return memoryConfigSource
}
47688
func isMemoryBestEffort(container *api.Container) bool {
	// A container is memory best-effort if its memory request is unspecified or 0.
	// If a request is specified, then the user expects some kind of resource guarantee.
	return container.Resources.Requests.Memory().Value() == 0
}
527996
func (l *LFUNoTS) incr(ci *cacheItem) {
	var nextValue int
	var nextPosition *list.Element
	// update existing one
	if ci.freqElement != nil {
		nextValue = ci.freqElement.Value.(*entry).freqCount + 1
		// replace the position of frequency element
		nextPosition = ci.freqElement.Next()
	} else {
		// create new frequency element for cache item
		// ci.freqElement is nil so next value of freq will be 1
		nextValue = 1
		// we created new element and its position will be head of linked list
		nextPosition = l.frequencyList.Front()
		l.currentSize++
	}

	// we need to check position first, otherwise it will panic if we try to fetch value of entry
	if nextPosition == nil || nextPosition.Value.(*entry).freqCount != nextValue {
		// create new entry node for linked list
		entry := newEntry(nextValue)
		if ci.freqElement == nil {
			nextPosition = l.frequencyList.PushFront(entry)
		} else {
			nextPosition = l.frequencyList.InsertAfter(entry, ci.freqElement)
		}
	}

	nextPosition.Value.(*entry).listEntry[ci] = struct{}{}
	ci.freqElement = nextPosition

	// we have moved the cache item to the next position,
	// then we need to  remove old position of the cacheItem from the list
	// then we deleted previous position of cacheItem
	if ci.freqElement.Prev() != nil {
		l.remove(ci, ci.freqElement.Prev())
	}
}
151636
func init() {
	if intIs64 {
		arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_LONG
		arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_ULONG
	} else {
		arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_INT
		arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_UINT
	}
}
772409
func (b *LRUCache) Init(capacity uint) {
	b.table = make(map[string]*entry, capacity)
	b.priorityQueue = make([]*entry, 0, capacity)
	b.lruList.Init()
	b.freeList.Init()
	heap.Init(&b.priorityQueue)

	// Reserve all the entries in one giant continous block of memory
	arrayOfEntries := make([]entry, capacity)
	for i := uint(0); i < capacity; i++ {
		e := &arrayOfEntries[i]
		e.element.Value = e
		e.index = -1
		b.freeList.PushElementBack(&e.element)
	}
}
1024046
func (r *Store) GetInt64Default(key string, def int64) int64 {
	if v, err := r.GetInt64(key); err == nil {
		return v
	}

	return def
}
651064
func (fs *fsImpl) checkInvariants() {
	// INVARIANT: For each k in inodes, k < nextInodeID
	for k, _ := range fs.inodes {
		if !(k < fs.nextInodeID) {
			panic("Unexpectedly large inode ID")
		}
	}
}
270296
func (s *systemInfo) MemFree() (uint64, error) {
	memInfo, err := mem.VirtualMemory()
	if err != nil {
		return 0, err
	}
	return memInfo.Free, err
}
1236536
func (mab *memoryAddrBook) AddrStream(ctx context.Context, p peer.ID) <-chan ma.Multiaddr {
	mab.addrmu.RLock()
	defer mab.addrmu.RUnlock()

	baseaddrslice := mab.addrs[p]
	initial := make([]ma.Multiaddr, 0, len(baseaddrslice))
	for _, a := range baseaddrslice {
		initial = append(initial, a.Addr)
	}

	return mab.subManager.AddrStream(ctx, p, initial)
}
104837
func NewInMemoryUsageStore() (UsageStore, error) {
	m := &memoryStore{}
	m.set = make(map[string]memEntry)
	m.quit = make(chan struct{})
	go m.garbageCollector()
	return m, nil
}