Skip to content

Commit

Permalink
added a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fnc12 committed Oct 15, 2023
1 parent 21b42c5 commit 642762c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dev/storage_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 642762c

Please sign in to comment.