Skip to content

Commit

Permalink
Fixed header defitinion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriztiaan committed Oct 31, 2024
1 parent 2c42f0c commit c555e57
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 15 deletions.
7 changes: 2 additions & 5 deletions cpp/ConnectionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,15 @@ void ConnectionPool::closeAll() {
std::future<void> ConnectionPool::refreshSchema() {
std::vector<std::future<void>> futures;

// Collect the future from the write connection
futures.push_back(writeConnection.refreshSchema());

// Collect the futures from the read connections
for (unsigned int i = 0; i < maxReads; i++) {
futures.push_back(readConnections[i]->refreshSchema());
}

// Return a future that completes when all collected futures are done
return std::async(std::launch::async, [futures = std::move(futures)]() mutable {
for (auto& fut : futures) {
fut.get(); // This will block until the future is ready and rethrow exceptions if any
for (auto& future : futures) {
future.get();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/ConnectionPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ConnectionPool {
/**
* Refreshes the schema for all connections.
*/
std::future<void> ConnectionPool::refreshSchema();
std::future<void> refreshSchema();

/**
* Attaches another database to all connections
Expand Down
3 changes: 0 additions & 3 deletions cpp/ConnectionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include "fileUtils.h"
#include "sqlite3.h"



const std::string EMPTY_LOCK_ID = "";

SQLiteOPResult genericSqliteOpenDb(string const dbName, string const docPath,
Expand Down Expand Up @@ -65,7 +63,6 @@ std::future<void> ConnectionState::refreshSchema() {
return future;
}


void ConnectionState::close() {
waitFinished();
// So that the thread can stop (if not already)
Expand Down
5 changes: 1 addition & 4 deletions cpp/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ void osp::install(jsi::Runtime &rt,
return {};
});


auto refreshSchema = HOSTFN("refreshSchema", 1) {
if (count == 0) {
throw jsi::JSError(rt, "[react-native-quick-sqlite][refreshSchema] database name is required");
Expand Down Expand Up @@ -323,9 +322,7 @@ void osp::install(jsi::Runtime &rt,
}).detach();

} catch (const std::exception& exc) {
auto errorCtr = rt.global().getPropertyAsFunction(rt, "Error");
auto error = errorCtr.callAsConstructor(rt, jsi::String::createFromUtf8(rt, exc.what()));
reject->asObject(rt).asFunction(rt).call(rt, error);
invoker->invokeAsync([&rt, &exc] { jsi::JSError(rt, exc.what()); });
}

return {};
Expand Down
2 changes: 0 additions & 2 deletions cpp/sqliteBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ sqliteOpenDb(string const dbName, string const docPath,
};
}


std::future<void> sqliteRefreshSchema(const std::string& dbName) {
if (dbMap.count(dbName) == 0) {
// Database not found, return a future that's already set
Expand All @@ -73,7 +72,6 @@ std::future<void> sqliteRefreshSchema(const std::string& dbName) {
return connection->refreshSchema();
}


SQLiteOPResult sqliteCloseDb(string const dbName) {
if (dbMap.count(dbName) == 0) {
return generateNotOpenResult(dbName);
Expand Down

0 comments on commit c555e57

Please sign in to comment.