Browse Source

exportNextId

tags/v1.0.0
yitter 3 years ago
parent
commit
9c34748c52
3 changed files with 9 additions and 6 deletions
  1. BIN
      FFI for Python-Node-PHP/lib/yitidgen.dll
  2. +4
    -2
      Go/source/idgen/YitIdHelper.go
  3. +5
    -4
      Go/source/main.go

BIN
FFI for Python-Node-PHP/lib/yitidgen.dll View File


+ 4
- 2
Go/source/idgen/YitIdHelper.go View File

@@ -58,8 +58,10 @@ func SetIdGenerator(options *IdGeneratorOptions) {
func NextId() uint64 {
if idGenerator == nil {
singletonMutex.Lock()
options := NewIdGeneratorOptions(1)
idGenerator = NewDefaultIdGenerator(options)
if idGenerator == nil {
options := NewIdGeneratorOptions(1)
idGenerator = NewDefaultIdGenerator(options)
}
singletonMutex.Unlock()
}



+ 5
- 4
Go/source/main.go View File

@@ -8,13 +8,13 @@ import (
"yitidgen/regworkerid"
)

///export SetOptions
//export SetOptions
func SetOptions(workerId uint16) {
var options = idgen.NewIdGeneratorOptions(workerId)
idgen.SetIdGenerator(options)
}

///export NextId
//export NextId
func NextId() uint64 {
return idgen.NextId()
}
@@ -65,5 +65,6 @@ func main() {

}

// go build -o target\yitidgengo.dll -buildmode=c-shared main.go

// go build -o ./target/yitidgengo.dll -buildmode=c-shared main.go
// go install -buildmode=shared -linkshared std
// go build -o ./target/yitidgengo.so -buildmode=c-shared main.go

Loading…
Cancel
Save