diff --git a/dev/storage_base.h b/dev/storage_base.h index 9f6a7d787..4ce2be4c4 100644 --- a/dev/storage_base.h +++ b/dev/storage_base.h @@ -214,6 +214,15 @@ namespace sqlite_orm { return tableNames; } + /** + * Call it once during storage lifetime to make it keeping its connection opened till dtor call. + * By default if storage is not in-memory it calls `sqlite3_open` only when the connection is really + * needed and closes when it is not needed. This function breaks this rule. In memory storage always + * keeps connection opened so calling this for in-memory storage changes nothing. + * Note about multithreading: in multithreading context avoiding using this function for not in-memory + * storage may lead to data races. If you have data races in such a configuration try to call `open_forever` + * before accessing your storage - it may fix data races. + */ void open_forever() { this->isOpenedForever = true; this->connection->retain(); diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 8f982153d..37eb7dec4 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -14647,6 +14647,15 @@ namespace sqlite_orm { return tableNames; } + /** + * Call it once during storage lifetime to make it keeping its connection opened till dtor call. + * By default if storage is not in-memory it calls `sqlite3_open` only when the connection is really + * needed and closes when it is not needed. This function breaks this rule. In memory storage always + * keeps connection opened so calling this for in-memory storage changes nothing. + * Note about multithreading: in multithreading context avoiding using this function for not in-memory + * storage may lead to data races. If you have data races in such a configuration try to call `open_forever` + * before accessing your storage - it may fix data races. + */ void open_forever() { this->isOpenedForever = true; this->connection->retain();