aboutsummaryrefslogtreecommitdiffstats
path: root/src/mongo.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo.go')
-rw-r--r--src/mongo.go16
1 files changed, 0 insertions, 16 deletions
diff --git a/src/mongo.go b/src/mongo.go
index 764f877..1d9f74f 100644
--- a/src/mongo.go
+++ b/src/mongo.go
@@ -2,8 +2,6 @@ package main
2 2
3import ( 3import (
4 "context" 4 "context"
5 "fmt"
6 "sync"
7 "time" 5 "time"
8 6
9 "go.mongodb.org/mongo-driver/bson" 7 "go.mongodb.org/mongo-driver/bson"
@@ -15,8 +13,6 @@ type mongoClient struct {
15 dbName, colName string 13 dbName, colName string
16 client *mongo.Client 14 client *mongo.Client
17 col *mongo.Collection 15 col *mongo.Collection
18 Mutex sync.Mutex
19 // Attention: 这把锁是否有必要?
20} 16}
21 17
22func (mc *mongoClient) init(dbName, colName string) error { 18func (mc *mongoClient) init(dbName, colName string) error {
@@ -100,15 +96,3 @@ func (mc *mongoClient) Disconnect() error {
100 mc.colName = "" 96 mc.colName = ""
101 return nil 97 return nil
102} 98}
103
104func (mc *mongoClient) GetLock() bool {
105 for i := 0; i < 200000; {
106 if !mc.Mutex.TryLock() {
107 i++
108 } else {
109 return true
110 }
111 }
112 fmt.Printf("Die...\n")
113 return false
114}