SQLite学习(五) - 异步I/O的实现 sqlite3async.c
一般情况下,当我们的程序有I/O操作需要写磁盘时,程序会等待I/O完成后才把程序控制还给用户。由于I/O是相对比较慢的,所以这有可能会成为性能瓶颈。SQLite的异步I/O使用一个单独的线程完成I/O。虽然这样没有减少系统资源的使用,但是控制权立刻返回给用户,更好的用户体验。 SQLite异步I/O限制 3.锁和并发 可以用sqlite3async_control() disable文件锁,这样I/O时就不需要额外的去获得文件锁,以得到更好的性能。 4.编译和使用Asynchronous IO extension The asynchronous IO VFS API is described in detail in comments in sqlite3async.h. Using the API usually consists of the following steps: 1. Register the asynchronous IO VFS with SQLite by calling the sqlite3async_initialize() function. Refer to comments in the sqlite3async.h header file for details.
5.移植 Currently there is no externally available interface to allow this,but modifying the code within sqlite3async.c to include the new platforms concurrency primitives is relatively easy. Search within sqlite3async.c for the comment string "PORTING FUNCTIONS" for details. Then implement new versions of each of the following: static void async_mutex_enter(int eMutex); static void async_mutex_leave(int eMutex); static void async_cond_ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |