What's the best practice to manage global state in thread-safe way in Swift NIO based web apps like Vapor, Kitura?
I want to store a simple integer value in memory and pass to clients.
I chose the simplest way like having a mutable variable with a struct type and two closures, a setter (POST /value) and a getter (GET /value) that manipulates it. I suppose race condition can easily occur without additional protection around the variable.
One way is to use GDC queues or I can rely on pthread facilities.
I appreciate your suggestions,