Compare commits

...

12 Commits

Author SHA1 Message Date
kayos@tcp.direct d30d173462
Remove queue branch code from speedometer branch tree 2023-10-21 13:52:27 -07:00
kayos@tcp.direct 3aec09c5d2
Merge branch 'main' into speedo 2023-10-21 13:51:05 -07:00
kayos@tcp.direct b8210b691c
Fix[CI]: fix go version in workflow 2023-10-21 13:50:23 -07:00
kayos 12a0ad064c
Merge pull request #6 from yunginnanet/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-09-07 20:49:27 -07:00
dependabot[bot] ac393e3b5a
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 00:21:05 +00:00
kayos 9de4224b56
Merge pull request #5 from yunginnanet/dependabot/github_actions/github/codeql-action-2 2023-04-01 11:14:05 -07:00
kayos 679a58ed89
Merge pull request #4 from yunginnanet/dependabot/github_actions/actions/checkout-3 2023-04-01 11:13:52 -07:00
kayos ac8d4c61b7
Merge pull request #3 from yunginnanet/dependabot/github_actions/actions/setup-go-4 2023-04-01 11:13:39 -07:00
dependabot[bot] 98de5d07b9
Bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 18:11:12 +00:00
dependabot[bot] d4cccdf154
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 18:11:08 +00:00
dependabot[bot] 52b87b3542
Bump actions/setup-go from 2 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 18:11:05 +00:00
kayos b569b3be6a
Update dependabot.yml 2023-04-01 11:10:10 -07:00
5 changed files with 12 additions and 135 deletions

View File

@ -1,7 +1,7 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View File

@ -38,11 +38,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -67,4 +67,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@ -6,12 +6,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: '1.17'
go-version: '1.21'
- name: Run coverage
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov

View File

@ -1,5 +0,0 @@
package queue
import "errors"
var ErrQueueFull = errors.New("bounded queue is full")

View File

@ -1,122 +0,0 @@
package queue
import (
"fmt"
"sync"
"sync/atomic"
"git.tcp.direct/kayos/common/list"
"golang.org/x/exp/constraints"
)
type Item[P constraints.Ordered, V any] struct {
value *V
priority P
index int
}
func NewItem[P constraints.Ordered, V any](v *V, p P) *Item[P, V] {
return &Item[P, V]{
value: v,
priority: p,
index: 0,
}
}
func (i *Item[P, V]) Less(j any) bool {
return i.priority < j.(Item[P, V]).priority
}
func (i *Item[P, V]) Value() *V {
return i.value
}
func (i *Item[P, V]) Priority() P {
return i.priority
}
func (i *Item[P, V]) Set(v *V) {
i.value = v
}
func (i *Item[P, V]) SetPriority(p P) {
i.priority = p
}
type boundedQueue[P constraints.Ordered, V any] struct {
items []*Item[P, V]
qcap int64
qlen *atomic.Int64
mu *sync.RWMutex
errs *list.LockingList
}
type BoundedQueue[P constraints.Ordered, V any] struct {
// making sure container/heap can access boundedQueue without the normal API being exposed to the user
inner *boundedQueue[P, V]
}
func NewBoundedQueue[P constraints.Ordered, V any](cap int64) *BoundedQueue[P, V] {
bq := &BoundedQueue[P, V]{}
bq.inner = &boundedQueue[P, V]{
items: make([]*Item[P, V], 0, cap),
qcap: cap,
qlen: &atomic.Int64{},
mu: &sync.RWMutex{},
errs: list.New(),
}
bq.inner.qlen.Store(0)
return bq
}
func (b *boundedQueue[P, V]) err(err error) {
b.errs.PushBack(err)
}
func (b *BoundedQueue[P, V]) Err() error {
errLen := b.inner.errs.Len()
switch errLen {
case 0:
return nil
case 1:
return b.inner.errs.Front().Value().(error)
default:
return fmt.Errorf("%w | (%d more errors in queue)", b.inner.errs.Front().Value().(error), errLen-1)
}
}
func (b *BoundedQueue[P, V]) Len() int {
return int(b.inner.qlen.Load())
}
func (b *boundedQueue[P, V]) Less(i, j int) bool {
b.mu.RLock()
less := b.items[P, V][i].priority < b.items[P, V][j].priority
b.mu.RUnlock()
return less
}
func (b *boundedQueue[P, V]) Swap(i, j int) {
b.mu.Lock()
b.items[P, V][i], b.items[P, V][j] = b.items[P, V][j], b.items[P, V][i]
b.items[P, V][i].index = i
b.items[P, V][j].index = j
b.mu.Unlock()
}
func (b *boundedQueue[P, V]) Push(x any) {
if b.qlen.Load() >= b.qcap {
b.err(fmt.Errorf("%w: %v dropped", ErrQueueFull, x))
return
}
defer b.qlen.Add(1)
b.mu.Lock()
b.items[P, V] = append(b.items[P, V], x.(*Item[P, V]))
b.qlen.Add(1)
b.mu.Unlock()
}
func (b *boundedQueue[P, V]) Pop() any {
// todo
return nil
}