设置结构体下的锁的函数指针

锁的调用采用结构体函数指针的方式,调用通过下面这个结构体,找到对应的指针,然后调用。鄙人认为,这种方式可能借用多态的方式,便于在多种平台上进行规范化的调用。 初始化时默认采用如下方式设置

    sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
      static const sqlite3_mutex_methods sMutex = {
        winMutexInit,
        winMutexEnd,
        winMutexAlloc,
        winMutexFree,
        winMutexEnter,
        winMutexTry,
        winMutexLeave,
    #ifdef SQLITE_DEBUG  //debug下才使用
        winMutexHeld,
        winMutexNotheld
    #else
        0,
    0
    #endif
      };
      return &sMutex;
    }
    #endif /* SQLITE_MUTEX_W32 */

results matching ""

    No results matching ""