bool LockerImpl<IsForMMAPV1>::isCollectionLockedForMode(StringData ns, LockMode mode) const { invariant(nsIsFull(ns)); if (isW()) return true; if (isR() && isSharedLockMode(mode)) return true; const NamespaceString nss(ns); const ResourceId resIdDb(RESOURCE_DATABASE, nss.db()); LockMode dbMode = getLockMode(resIdDb); if (!shouldConflictWithSecondaryBatchApplication()) return true; switch (dbMode) { case MODE_NONE: return false; case MODE_X: return true; case MODE_S: return isSharedLockMode(mode); case MODE_IX: case MODE_IS: { const ResourceId resIdColl(RESOURCE_COLLECTION, ns); return isLockHeldForMode(resIdColl, mode); } break; case LockModesCount: break; } invariant(false); return false; }
/* Not include the day*/ int toEnd(int y, int m, int d) { if (isR(y)) { printf( "toEnd %d\n", (366 - toStart(y, m, d))); return (366 - toStart(y, m, d)); } printf( "toEnd %d\n", (365 - toStart(y, m, d))); return (365 - toStart(y, m, d)); }
bool LockerImpl<IsForMMAPV1>::isDbLockedForMode(StringData dbName, LockMode mode) const { invariant(nsIsDbOnly(dbName)); if (isW()) return true; if (isR() && isSharedLockMode(mode)) return true; const ResourceId resIdDb(RESOURCE_DATABASE, dbName); return isLockHeldForMode(resIdDb, mode); }
/* y > yy */ int hasR(int y, int yy) { printf("y = %d, yy = %d\n", y, yy); int i = 0; int tmp = 0; for ( i = yy + 1; i < y; ++i ) { if (isR(i)) tmp += 1; } printf("hasR %d\n", tmp); return tmp; }
/*Include the day*/ int toStart(int y, int m, int d) { int i = 0; int total = 0; for (i = 1; i < m; ++i) { total += md[i]; } if (isR(y) && m > 2) { printf("toStart %d\n", (total + d + 1) ); return (total + d + 1); } printf("toStart %d\n", (total + d ) ); return (total + d); }