January 2019
Intermediate to advanced
520 pages
14h 32m
English
You may have already heard that shared data is a bad thing and a potential cause of bottlenecks, if it has to be changed from separate threads. However, shared data can be useful if we want to share the address of a channel or if we don't need frequent access to it. In this section, we need a user database. In the following example, I'll show you how to add a shared state to our generator function. This approach can be used for a variety of reasons, such as keeping a connection to a database.
A user database will obviously hold data about users. Let's add some types to handle this:
type UserId = u64;struct UserData;
UserId represents the user's unique identifier. UserData represents the stored data, but we use an empty ...
Read now
Unlock full access