Skip to content
Snippets Groups Projects
Select Git revision
  • a4ddf570c9e1fc41be356a60d81563abaeb91563
  • master default protected
  • v1.3.4
  • v1.3.3
  • v1.3.2
  • v1.3.1
  • v1.3.0
  • v1.2.5
  • v1.2.4
  • v1.2.3
  • v1.2.2
  • v1.2.1
  • v1.2.0
  • v1.1.0
  • v1.0.3
  • v1.0.2
  • v1.0.1
  • v1.0.0
18 results

build-cover-report.nix

Blame
  • runnable-counter.go 624 B
    package jobqueue
    
    import (
    	"sync"
    )
    
    // CounterResult is a result of a counter
    type CounterResult struct {
    	Count int
    }
    
    // CounterRunnable is a runnable that counts
    type CounterRunnable struct {
    	Count int
    	mu    sync.Mutex
    }
    
    // GetCount returns the current count
    func (c *CounterRunnable) GetCount() int {
    	c.mu.Lock()
    	defer c.mu.Unlock()
    	return c.Count
    }
    
    // Run runs the counter
    func (c *CounterRunnable) Run() (RunResult[CounterResult], error) {
    	c.mu.Lock()
    	defer c.mu.Unlock()
    
    	c.Count++
    
    	return RunResult[CounterResult]{
    		Status: ResultStatusSuccess,
    		Data: CounterResult{
    			Count: c.Count,
    		},
    	}, nil
    }