Heavily improving the clients join and leave performance
This commit is contained in:
parent
88158742e8
commit
0a73e4c10c
@ -103,7 +103,6 @@ namespace ts {
|
||||
INIT_HIGH, //Web -> Auth
|
||||
CONNECTED,
|
||||
DISCONNECTING,
|
||||
DISCONNECTING_FLUSHING,
|
||||
DISCONNECTED
|
||||
};
|
||||
}
|
||||
|
@ -315,14 +315,14 @@ namespace ts {
|
||||
CLIENT_OUTPUT_HARDWARE, //automatically up-to-date for any client "in view", this clients headphone/speakers hardware status (is the playback device opened?)
|
||||
CLIENT_DEFAULT_CHANNEL, //only usable for ourself, the default channel we used to connect on our last connection attempt
|
||||
CLIENT_DEFAULT_CHANNEL_PASSWORD, //internal use
|
||||
CLIENT_SERVER_PASSWORD, //internal use
|
||||
CLIENT_SERVER_PASSWORD, //internal use (Passed within the clientinit, will not be stored)
|
||||
CLIENT_META_DATA, //automatically up-to-date for any client "in view", not used by TeamSpeak, free storage for sdk users
|
||||
CLIENT_IS_RECORDING, //automatically up-to-date for any client "in view"
|
||||
CLIENT_VERSION_SIGN, //sign
|
||||
CLIENT_VERSION_SIGN, //sign (will currently not be set within the clientinit method!)
|
||||
CLIENT_SECURITY_HASH, //SDK use, not used by teamspeak. Hash is provided by an outside source. A channel will use the security salt + other client data to calculate a hash, which must be the same as the one provided here.
|
||||
|
||||
//Rare properties
|
||||
CLIENT_KEY_OFFSET, //internal use
|
||||
CLIENT_KEY_OFFSET, //internal use (Passed within the clientinit, will not be stored)
|
||||
CLIENT_LOGIN_NAME, //used for serverquery clients, makes no sense on normal clients currently
|
||||
CLIENT_LOGIN_PASSWORD, //used for serverquery clients, makes no sense on normal clients currently
|
||||
CLIENT_DATABASE_ID, //automatically up-to-date for any client "in view", only valid with PERMISSION feature, holds database client id
|
||||
|
@ -128,6 +128,7 @@ namespace ts {
|
||||
* Helper class for tasks which could be executed multiple times.
|
||||
* It will avoid execution stacking while the task is executing.
|
||||
* The task will never be executed twice only sequential.
|
||||
* Note: If the `multi_shot_task` handle gets deleted no enqueued tasks will be executed.
|
||||
*/
|
||||
struct multi_shot_task {
|
||||
public:
|
||||
@ -135,16 +136,22 @@ namespace ts {
|
||||
|
||||
multi_shot_task(std::shared_ptr<task_executor> executor, std::string task_name, std::function<void()> callback)
|
||||
: inner{std::make_shared<execute_inner>(std::move(executor), std::move(task_name), std::move(callback))} {
|
||||
this->inner->callback_wrapper = [inner = this->inner]{
|
||||
auto result = inner->schedule_kind.exchange(2);
|
||||
std::weak_ptr weak_inner{this->inner};
|
||||
this->inner->callback_wrapper = [weak_inner]{
|
||||
auto callback_inner = weak_inner.lock();
|
||||
if(!callback_inner) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = callback_inner->schedule_kind.exchange(2);
|
||||
assert(result == 1);
|
||||
(void) result;
|
||||
|
||||
try {
|
||||
(inner->callback)();
|
||||
execute_finished(&*inner);
|
||||
(callback_inner->callback)();
|
||||
execute_finished(&*callback_inner);
|
||||
} catch (...) {
|
||||
execute_finished(&*inner);
|
||||
execute_finished(&*callback_inner);
|
||||
std::rethrow_exception(std::current_exception());
|
||||
}
|
||||
};
|
||||
|
@ -90,8 +90,7 @@ std::shared_ptr<sqlite3_stmt> SqliteManager::allocateStatement(const std::string
|
||||
return nullptr;
|
||||
|
||||
return std::shared_ptr<sqlite3_stmt>(stmt, [](void* _ptr) {
|
||||
auto _stmt = static_cast<sqlite3_stmt*>(_ptr);
|
||||
if(_stmt) sqlite3_finalize(_stmt);
|
||||
sqlite3_finalize(static_cast<sqlite3_stmt*>(_ptr));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user