func StartCollectorWith(config Config) io.Closer {
	config = setConfigDefaults(config)
	stop := make(chan struct{})
	join := make(chan struct{})
	go func() {
		runtime.LockOSThread()
		defer runtime.UnlockOSThread()
		defer close(join)
		ticker := time.NewTicker(config.CollectInterval)
		config.Collector.Collect()
		for {
			select {
			case <-ticker.C:
				config.Collector.Collect()
			case <-stop:
				return
			}
		}
	}()
	return &closer{stop: stop, join: join}
}
StartCollectorWith starts a Collector with the provided Config.
package procstats
import (
	"io"
	"runtime"
	"sync"
	"time"
)
type Collector interface {
	Collect()
}
type CollectorFunc func()
func (f CollectorFunc) Collect() { f() }
type Config struct {
	Collector       Collector
	CollectInterval time.Duration
}
func MultiCollector(collectors ...Collector) Collector {
	return CollectorFunc(func() {
		for _, c := range collectors {
			c.Collect()
		}
	})
}
func StartCollector(collector Collector) io.Closer {
	return StartCollectorWith(Config{Collector: collector})
}