Ignore:
Timestamp:
Mar 23, 2018, 11:36:43 PM (7 years ago)
Author:
bird
Message:

kFsCache,dir-nt-bird: Added locking to the cache to make it accessible from winchildren worker threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/kFsCache.h

    r2967 r3184  
    5555/** The max UTF-16 name length. */
    5656#define KFSCACHE_CFG_MAX_UTF16_NAME         (256*2 + 16)
     57/** Enables locking of the cache and thereby making it thread safe. */
     58#define KFSCACHE_CFG_LOCKING                1
    5759
    5860
     
    372374    PKFSOBJ             pFsObj;
    373375} KFSHASHW;
     376#endif
     377
     378
     379/** @def KFSCACHE_LOCK
     380 *  Locks the cache exclusively. */
     381/** @def KFSCACHE_UNLOCK
     382 *  Counterpart to KFSCACHE_LOCK. */
     383#ifdef KFSCACHE_CFG_LOCKING
     384# define KFSCACHE_LOCK(a_pCache)        EnterCriticalSection(&(a_pCache)->u.CritSect)
     385# define KFSCACHE_UNLOCK(a_pCache)      LeaveCriticalSection(&(a_pCache)->u.CritSect)
     386#else
     387# define KFSCACHE_LOCK(a_pCache)        do { } while (0)
     388# define KFSCACHE_UNLOCK(a_pCache)      do { } while (0)
    374389#endif
    375390
     
    440455    KFSDIR              RootDir;
    441456
     457#ifdef KFSCACHE_CFG_LOCKING
     458    /** Critical section protecting the cache. */
     459    union
     460    {
     461# ifdef _WINBASE_
     462        CRITICAL_SECTION    CritSect;
     463# endif
     464        KU64                abPadding[2 * 4 + 4 * sizeof(void *)];
     465    } u;
     466#endif
     467
    442468    /** File system hash table for ANSI filename strings. */
    443469    PKFSHASHA           apAnsiPaths[KFSCACHE_CFG_PATH_HASH_TAB_SIZE];
Note: See TracChangeset for help on using the changeset viewer.