lib

package
v0.0.0-...-743647c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2015 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEBUG = false
	INFO  = true
)
View Source
const (
	WORKSIZE = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Work     chan PrimeCalc
	Done     chan PrimeCalc
	Primes   []*big.Int
	PIndex   uint64
	NWorkers uint32

	LowestKey *big.Int
	KeyMutex  *sync.Mutex

	PrevEnd      *big.Int
	PrevEndMutex *sync.Mutex

	Factory *utils.RedisConf
}

func (*Base) CalculatePrime

func (b *Base) CalculatePrime()

func (*Base) SpawnWorkers

func (b *Base) SpawnWorkers()

type MinHeap

type MinHeap []PrimeCalc

func (MinHeap) Len

func (h MinHeap) Len() int

func (MinHeap) Less

func (h MinHeap) Less(i, j int) bool

func (MinHeap) Peek

func (h MinHeap) Peek() *PrimeCalc

func (*MinHeap) Pop

func (h *MinHeap) Pop() interface{}

func (*MinHeap) Push

func (h *MinHeap) Push(x interface{})

func (MinHeap) Swap

func (h MinHeap) Swap(i, j int)

func (h MinHeap) Less(i, j int) bool { return uti h[i].Id < h[j].Id }

type PrimeCalc

type PrimeCalc struct {
	Id     float64
	Start  big.Int
	End    big.Int
	Result []*big.Int
}

type PriorityQueue

type PriorityQueue []*QueueItem

A PriorityQueue implements heap.Interface and holds QueueItems.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type QueueItem

type QueueItem struct {
	// contains filtered or unexported fields
}

An QueueItem is something we manage in a priority queue.

type Scheduler

type Scheduler struct {
	Base  *Base
	Queue *MinHeap
}

func (*Scheduler) CreateWork

func (s *Scheduler) CreateWork() PrimeCalc

func (*Scheduler) Start

func (s *Scheduler) Start()

func (*Scheduler) StoreWork

func (s *Scheduler) StoreWork()

Ideas: Store primes in lists in redis. Each list contains 1000 primes. The key should just be a int64 or float64, incremented from 1 to N Problem with concurrency?

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL