/** * Get a CacheToken for a row as specified by its id (_id column) * * @param id the id of the record * @return a CacheToken needed in order to write data for the record back to the cache */ public synchronized CacheToken getCacheToken(String id) { // If another thread is already writing the data, return an invalid token CacheToken token = mTokenList.add(id); if (mLockMap.contains(id)) { token.invalidate(); } return token; }
/*package*/ void invalidate() { if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { LogUtils.d(mLogTag, "============ List invalidated"); } for (CacheToken token : this) { token.invalidate(); } clear(); }
/*package*/ int invalidateTokens(String id) { if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id); } ArrayList<CacheToken> removeList = new ArrayList<CacheToken>(); int count = 0; for (CacheToken token : this) { if (token.getId().equals(id)) { token.invalidate(); removeList.add(token); count++; } } for (CacheToken token : removeList) { remove(token); } return count; }