sqlite3_exec回调是同步还是异步
Is sqlite3_exec callback synchronous or asynchronous?
Sqlite3 函数sqlite3_exec()
回调参数是同步运行还是异步运行?
调用示例:
int retStatus = sqlite3_exec(pDB, "SELECT * FROM SomeTable WHERE Something='Hi'", callback, &object, &error);
...Next line(s) of code...
同步:执行sqlite3_exec行,然后调用回调,然后执行下一行代码。
异步:执行sqlite3_exec行,下一行代码执行,并在某个时候调用回调。
同步。在代码继续之前,为找到的每一行调用回调:
static int _getName(void* pNames, int columns, char** data, char** columnNames)
{
if (columns < 2)
{
assert(false && "Function called on wrong table!");
// Signify failure
return 1;
}
std::vector<std::string>* vNames = static_cast< std::vector<std::string>* >(pNames);
vNames->push_back(data[1]);
// Success:
return 0;
}
{
std::vector<std::string> names;
// assume pDB is a valid, opened sqlite3* db
char* error = 0;
if (sqlite3_exec(pDB, "SELECT * FROM TableNames", _getName, static_cast<void*>(&names), &error) != SQLITE_OK)
{
// log and free error:
}
assert(names.size() && "No entries were found in the table");
}
将在表TableNames
中找到的每个条目上调用_getName
。如果未找到任何条目,则不会调用该函数,并且不会有错误。如果您有名为 TableNames 的表,其中包含 10 个条目,则names.size() == 10
。 如果返回非零_getName
,将不再调用
相关文章:
- gRPC cpp 异步服务器与同步服务器
- 异步操作的 Asio 处理程序在其同步对应项正常工作时不会调用
- 提升 ASIO:异步写入,同步
- 将阻止同步代码转换为异步
- 使用boost :: Beast进行CPU重的REST API,我是否应该使用异步或同步方式来实现它们以期望延迟
- 在 UWP 应用程序中,future.wait() 在尝试同步来自异步方法的响应时继续等待
- sqlite3_exec回调是同步还是异步
- 谈到套接字时使用的同步和异步术语
- C++:如何异步调用同步库调用
- 设计一个结合同步和异步操作的c++ API
- 同步来自多个对象的异步调用
- 工作线程中的同步与异步ioctl
- 当调用ReadDirectoryChangesW时,只有第一次调用返回任何更改(同步和异步)
- curl_easy_perform()是同步还是异步
- 是更好的同步或异步从boost asio时,有大量的计算和推/弹出线程安全容器
- C++ 提升 ASIO |同步写入到异步读取 |无法在第二次读取中接收正确的数据
- 是boost::信号槽被同步或异步调用
- 提升asio同步与异步操作性能
- 使用异步调用与在线程中使用同步调用相同
- 同步和异步api