Skip to content
Snippets Groups Projects
Select Git revision
  • deb997c885500a4b8c161a22242f42b891b98b13
  • noblogs default
  • noblogs-5.7.1
  • upstream
  • noblogs-5.7
  • noblogs-5.6new
  • upstream5.5.1
  • noblogs28dic
  • upstream28dic
  • noblogs-5.5.1
  • noblogs-5.4.2
  • noblogs-5.4_seconda
  • noblogs-5.4
  • noblogs-7c
  • wp5.2.3p3
  • mergedbconf
  • noblogs-5.7.1
  • noblogs.5.7.0p1
  • noblogs-5.7.0
  • noblogs-5.6p3
  • noblogs5.6p2
  • noblogs-5.6p1
  • noblogs-5.6
  • noblogs-5.4.2p1
  • noblogs-5.4.2
  • noblogs-5.4.1
  • noblogs-5.4
  • noblogs-p5.4
  • noblogs-5.3.2p2
  • noblogs-5.3.2p1
  • noblogs-5.3.2
  • noblogs-5.3
  • noblogs-5.2.3p4
  • noblogs-5.2.3p3
  • noblogs-5.2.3p2
  • noblogs-5.2.3p1
36 results

customize-base.js

Blame
  • pointstore.go 856 B
    package main
    
    import (
    	"errors"
    	"sort"
    	"sync"
    )
    
    var (
    	errPointNotFound = errors.New("point does not exist")
    )
    
    type pointStore struct {
    	pointMap map[string]*point
    	lock     *sync.RWMutex
    }
    
    func newPointStore() *pointStore {
    	return &pointStore{
    		pointMap: make(map[string]*point),
    		lock:     &sync.RWMutex{},
    	}
    }
    
    func (ps *pointStore) keys() []string {
    	ps.lock.Lock()
    	keys := make([]string, 0)
    	for k := range ps.pointMap {
    		keys = append(keys, k)
    	}
    	sort.Strings(keys)
    	ps.lock.Unlock()
    	return keys
    }
    
    func (ps *pointStore) set(p *point) error {
    	var err error
    	ps.lock.Lock()
    	ps.pointMap[p.key()] = p
    	ps.lock.Unlock()
    	return err
    }
    
    func (ps *pointStore) get(name string) (*point, error) {
    	ps.lock.Lock()
    	if p, ok := ps.pointMap[name]; ok {
    		ps.lock.Unlock()
    		return p, nil
    	}
    	ps.lock.Unlock()
    	return &point{}, errPointNotFound
    }