exportNextId
This commit is contained in:
Binary file not shown.
@@ -58,8 +58,10 @@ func SetIdGenerator(options *IdGeneratorOptions) {
|
|||||||
func NextId() uint64 {
|
func NextId() uint64 {
|
||||||
if idGenerator == nil {
|
if idGenerator == nil {
|
||||||
singletonMutex.Lock()
|
singletonMutex.Lock()
|
||||||
|
if idGenerator == nil {
|
||||||
options := NewIdGeneratorOptions(1)
|
options := NewIdGeneratorOptions(1)
|
||||||
idGenerator = NewDefaultIdGenerator(options)
|
idGenerator = NewDefaultIdGenerator(options)
|
||||||
|
}
|
||||||
singletonMutex.Unlock()
|
singletonMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import (
|
|||||||
"yitidgen/regworkerid"
|
"yitidgen/regworkerid"
|
||||||
)
|
)
|
||||||
|
|
||||||
///export SetOptions
|
//export SetOptions
|
||||||
func SetOptions(workerId uint16) {
|
func SetOptions(workerId uint16) {
|
||||||
var options = idgen.NewIdGeneratorOptions(workerId)
|
var options = idgen.NewIdGeneratorOptions(workerId)
|
||||||
idgen.SetIdGenerator(options)
|
idgen.SetIdGenerator(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
///export NextId
|
//export NextId
|
||||||
func NextId() uint64 {
|
func NextId() uint64 {
|
||||||
return idgen.NextId()
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user