设为首页 收藏本站
查看: 998|回复: 0

[经验分享] SQLITE源码剖析(8)

[复制链接]

尚未签到

发表于 2016-11-29 07:13:16 | 显示全部楼层 |阅读模式
  声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iyunv.com/)原创,未经笔者授权,任何人和机构不能转载
  /*库线程安全
  ** CAPI3REF: Test To See If The Library Is Threadsafe
  **SQLITE_THREADSAFE预处理宏编译时选项设为0,则忽略SQLITE的互斥代码,
  **此时,sqlite3_threadsafe()返回0
  ** ^The sqlite3_threadsafe() function returns zero if and only if
  ** SQLite was compiled mutexing code omitted due to the
  ** [SQLITE_THREADSAFE] compile-time option being set to 0.
  **SQLITE可在有互斥和没有互斥情况下编译,当SQLITE_THREADSAFE宏是1或2**时,互斥被允许,SQLITE是线程安全的。该宏为0时,不使用互斥,超过一
  **个线程同时使用SQLite是不安全的
  ** SQLite can be compiled with or without mutexes.  When
  ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
  ** are enabled and SQLite is threadsafe.  When the
  ** [SQLITE_THREADSAFE] macro is 0, 
  ** the mutexes are omitted.  Without the mutexes, it is not safe
  ** to use SQLite concurrently from more than one thread.
  **允许互斥,将会产生一些可预见的后果。如果速度是第一位的,最好是禁止
  **互斥,对于最好安全性而言,互斥要开启,默认的行为是互斥开启。
  ** Enabling mutexes incurs a measurable performance penalty.
  ** So if speed is of utmost importance, it makes sense to disable
  ** the mutexes.  But for maximum safety, mutexes should be enabled.
  ** ^The default behavior is for mutexes to be enabled.
  **这些接口被应用程序使用,确认该SQLITE版本编译链接时是否使用
  **sqlite_threadsafe宏
  ** This interface can be used by an application to make sure that the
  ** version of SQLite that it is linking against was compiled with
  ** the desired setting of the [SQLITE_THREADSAFE] macro.
  **该接口仅在编译时,互斥设置了SQLITE_THREADSAFE标志时才报告,如
  **果 SQLITE使用SQLITE_THREADSAFE=1或=2的方式编译,互斥被允许,但
  **通过SQLITE_CONFIG_SINGLETHREAD、SQLITE_CONFIG_MULTITHREAD能部分或
  **完全禁止对sqlite3_config()的调用,
  ** This interface only reports on the compile-time mutex setting
  ** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
  ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
  ** can be fully or partially disabled using a call to [sqlite3_config()]
  ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
  ** or [SQLITE_CONFIG_MUTEX].  
  **sqlite3_threadsafe()函数的返回值仅指示编译时设置了线程安全
  **不能被sqlite3_config()可在运行时改变
  **^(The return value of the
  ** sqlite3_threadsafe() function shows only the compile-time setting of
  ** thread safety, not any run-time changes to that setting made by
  ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
  ** is unchanged by calls to sqlite3_config().)^
  **调用sqlite3_config()不能改变sqlite3_threadsafe()返回值,
  ** See the [threading mode] documentation for additional information.
  */
  SQLITE_API int sqlite3_threadsafe(void);
  /*数据库连接句柄
  ** CAPI3REF: Database Connection Handle
  ** KEYWORDS: {database connection} {database connections}
  **关键字:{database connection} {database connections}
  **每个打开的SQLite数据库做为一个指针出现,该指针指向隐藏的sqlite3
  **结构的实例,建议将sqlite3指针视 为对象 ,
  **sqlite3_open()、sqlite3_open16()、sqlite3_open_v2()接口是这该对象
  **的构造器,sqlite3_close()是析构器。
  ** Each open SQLite database is represented by a pointer to an instance of
  ** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
  ** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
  ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
  ** is its destructor.  
  **还有一些其它接口sqlite3_prepare_v2()、sqlite3_create_function()、
  **sqlite3_busy_timeout()为sqlite3 对象 的方法 
  There are many other interfaces (such as
  ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
  ** [sqlite3_busy_timeout()] to name but three) that are methods on an
  ** sqlite3 object.
  */
  typedef struct sqlite3 sqlite3;

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-306828-1-1.html 上篇帖子: SQLite中重复值的插入 下篇帖子: 测试SQLite工具及方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表