Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
27
backend/internal/home/global.go
Normal file
27
backend/internal/home/global.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package home
|
||||
|
||||
import "sync/atomic"
|
||||
|
||||
var currentClient atomic.Pointer[Client]
|
||||
|
||||
// SetCurrent sets the active home client used by runtime integrations.
|
||||
func SetCurrent(client *Client) {
|
||||
currentClient.Store(client)
|
||||
}
|
||||
|
||||
// Current returns the active home client instance, if any.
|
||||
func Current() *Client {
|
||||
return currentClient.Load()
|
||||
}
|
||||
|
||||
// ClearCurrent removes the active home client.
|
||||
func ClearCurrent() {
|
||||
currentClient.Store(nil)
|
||||
}
|
||||
|
||||
// ClearCurrentIf removes the active client only when it is client.
|
||||
func ClearCurrentIf(client *Client) {
|
||||
if client != nil {
|
||||
currentClient.CompareAndSwap(client, nil)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue