| 209 | } |
| 210 | |
| 211 | bool |
| 212 | BgFetchState::init(const PrefetchConfig &config) |
| 213 | { |
| 214 | int status = true; |
| 215 | |
| 216 | /* Is throttling configured, 0 - don't throttle */ |
| 217 | _concurrentFetchesMax = config.getFetchMax(); |
| 218 | |
| 219 | /* Initialize the state */ |
| 220 | TSMutexLock(_lock); |
| 221 | |
| 222 | /* Initialize 'simple' policy used to avoid concurrent fetches of the same object */ |
| 223 | status &= initializePolicy(_unique, "simple"); |
| 224 | |
| 225 | /* Initialize the fetch metrics */ |
| 226 | status &= initializeMetrics(_metrics, config); |
| 227 | |
| 228 | /* Initialize the "pre-fetch" log */ |
| 229 | status &= initializeLog(_log, config); |
| 230 | |
| 231 | TSMutexUnlock(_lock); |
| 232 | |
| 233 | /* Initialize fetching policy */ |
| 234 | TSMutexLock(_policyLock); |
| 235 | |
| 236 | if (!config.getFetchPolicy().empty() && 0 != config.getFetchPolicy().compare("simple")) { |
| 237 | status &= initializePolicy(_policy, config.getFetchPolicy().c_str()); |
| 238 | if (nullptr != _policy) { |
| 239 | setMetric(FETCH_POLICY_MAXSIZE, _policy->getMaxSize()); |
| 240 | } |
| 241 | } else { |
| 242 | PrefetchDebug("Policy not specified or 'simple' policy chosen (skipping)"); |
| 243 | } |
| 244 | |
| 245 | TSMutexUnlock(_policyLock); |
| 246 | |
| 247 | return status; |
| 248 | } |
| 249 | |
| 250 | bool |
| 251 | BgFetchState::acquire(const String &url) |
no test coverage detected