-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66a9f33
commit d623913
Showing
5 changed files
with
167 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package eval | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/dicedb/dice/internal/global" | ||
) | ||
|
||
var ( | ||
clients = make([]global.IOThread, 0) | ||
mu = sync.Mutex{} | ||
) | ||
|
||
func GetClients() []global.IOThread { | ||
return clients | ||
} | ||
|
||
func AddClient(client global.IOThread) { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
clients = append(clients, client) | ||
} | ||
|
||
// if id is monotonic binary search can be used | ||
func RemoveClientByID(id string) { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
for i, client := range clients { | ||
if client.ID() == id { | ||
clients = append(clients[:i], clients[i+1:]...) | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package global | ||
|
||
import "context" | ||
|
||
type IOThread interface { | ||
ID() string | ||
Start(context.Context) error | ||
Stop() error | ||
String() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters