Remove unnecessary SConfig from readwritesplit

The configuration doesn't need to be contained in shared pointer as each
session holds its own version of it. This removes most of the overhead in
configuration reloading. The only thing that's left is any overhead added
by the use of thread-local storage.
This commit is contained in:
Markus Mäkelä
2018-08-01 10:25:15 +03:00
parent 403b9e09f5
commit c01840ffb3
7 changed files with 116 additions and 117 deletions

View File

@ -201,8 +201,6 @@ struct Config
bool optimistic_trx; /**< Enable optimistic transactions */
};
typedef std::shared_ptr<Config> SConfig;
/**
* The statistics for this router instance
*/
@ -229,11 +227,11 @@ class RWSplit: public mxs::Router<RWSplit, RWSplitSession>
RWSplit& operator=(const RWSplit&);
public:
RWSplit(SERVICE* service, SConfig config);
RWSplit(SERVICE* service, const Config& config);
~RWSplit();
SERVICE* service() const;
SConfig config() const;
const Config& config() const;
Stats& stats();
const Stats& stats() const;
int max_slave_count() const;
@ -303,15 +301,15 @@ public:
private:
// Update configuration
void store_config(SConfig config);
void store_config(const Config& config);
void update_local_config() const;
SConfig* get_local_config() const;
Config* get_local_config() const;
// Called when worker local data needs to be updated
static void update_config(void* data);
SERVICE* m_service; /**< Service where the router belongs*/
SConfig m_config;
Config m_config;
mutable std::mutex m_lock; /**< Protects updates of m_config */
Stats m_stats;