mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 15:10:46 +00:00
Use sync.Mutex instead of sync/atomic for 32 bit systems (#388)
Change CLRF -> LF
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
#! /bin/bash
|
||||
# bash programmable completion for gctcli
|
||||
# copy to /etc/bash_completion.d/gctcli and source it or restart your shell
|
||||
|
||||
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||
|
||||
_gctcli() {
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
|
||||
else
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -o nospace -F _gctcli $PROG
|
||||
#! /bin/bash
|
||||
# bash programmable completion for gctcli
|
||||
# copy to /etc/bash_completion.d/gctcli and source it or restart your shell
|
||||
|
||||
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||
|
||||
_gctcli() {
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
|
||||
else
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -o nospace -F _gctcli $PROG
|
||||
unset PROG
|
||||
@@ -1,14 +1,14 @@
|
||||
# zsh programmable completion for gctcli
|
||||
# source zsh_autocomplete
|
||||
|
||||
_gctcli() {
|
||||
|
||||
local -a opts
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||
|
||||
_describe 'values' opts
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
# zsh programmable completion for gctcli
|
||||
# source zsh_autocomplete
|
||||
|
||||
_gctcli() {
|
||||
|
||||
local -a opts
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||
|
||||
_describe 'values' opts
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
compdef _gctcli gctcli
|
||||
@@ -35,7 +35,7 @@ type CancelOpenOrdersBatch struct {
|
||||
// DetailMerged stores the ticker detail merged data
|
||||
type DetailMerged struct {
|
||||
Detail
|
||||
Version int `json:"version"`
|
||||
Version int64 `json:"version"`
|
||||
Ask []float64 `json:"ask"`
|
||||
Bid []float64 `json:"bid"`
|
||||
}
|
||||
@@ -108,7 +108,7 @@ type Detail struct {
|
||||
Close float64 `json:"close"`
|
||||
High float64 `json:"high"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
ID int `json:"id"`
|
||||
ID int64 `json:"id"`
|
||||
Count int `json:"count"`
|
||||
Low float64 `json:"low"`
|
||||
Volume float64 `json:"vol"`
|
||||
|
||||
@@ -2,22 +2,27 @@ package nonce
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Nonce struct holds the nonce value
|
||||
type Nonce struct {
|
||||
n int64
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
// Inc increments the nonce value
|
||||
func (n *Nonce) Inc() {
|
||||
atomic.AddInt64(&n.n, 1)
|
||||
n.m.Lock()
|
||||
n.n++
|
||||
n.m.Unlock()
|
||||
}
|
||||
|
||||
// Get retrives the nonce value
|
||||
func (n *Nonce) Get() Value {
|
||||
return Value(atomic.LoadInt64(&n.n))
|
||||
n.m.Lock()
|
||||
defer n.m.Unlock()
|
||||
return Value(n.n)
|
||||
}
|
||||
|
||||
// GetInc increments and returns the value of the nonce
|
||||
@@ -28,7 +33,9 @@ func (n *Nonce) GetInc() Value {
|
||||
|
||||
// Set sets the nonce value
|
||||
func (n *Nonce) Set(val int64) {
|
||||
atomic.StoreInt64(&n.n, val)
|
||||
n.m.Lock()
|
||||
n.n = val
|
||||
n.m.Unlock()
|
||||
}
|
||||
|
||||
// String returns a string version of the nonce
|
||||
|
||||
Reference in New Issue
Block a user