Skip to content
Snippets Groups Projects
Commit 6afbf09a authored by Jono Wenger's avatar Jono Wenger
Browse files

Add global tracker for number of cmix followers running

parent 48ea7af6
No related branches found
No related tags found
1 merge request!18XX-4272 / Purge
...@@ -11,6 +11,7 @@ package wasm ...@@ -11,6 +11,7 @@ package wasm
import ( import (
"gitlab.com/elixxir/xxdk-wasm/utils" "gitlab.com/elixxir/xxdk-wasm/utils"
"sync/atomic"
"syscall/js" "syscall/js"
) )
...@@ -60,6 +61,8 @@ func (c *Cmix) StartNetworkFollower(_ js.Value, args []js.Value) interface{} { ...@@ -60,6 +61,8 @@ func (c *Cmix) StartNetworkFollower(_ js.Value, args []js.Value) interface{} {
return nil return nil
} }
atomic.AddUint64(&NumClientsRunning, 1)
return nil return nil
} }
...@@ -77,6 +80,7 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} { ...@@ -77,6 +80,7 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} {
utils.Throw(utils.TypeError, err) utils.Throw(utils.TypeError, err)
return nil return nil
} }
atomic.AddUint64(&NumClientsRunning, ^uint64(0))
return nil return nil
} }
......
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2022 xx foundation //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
package wasm
// NumClientsRunning is an atomic that tracks the current number of Cmix
// followers that have been started. Every time one is started, this counter
// must be incremented and every time one is stopped, it must be decremented.
//
// This variable is an atomic. Only access it with atomic functions
var NumClientsRunning uint64
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment