/** * Jobs are cached in memory even if they already have finished. But finished jobs are never * restored after the app has relaunched. Since finished jobs could cause memory leaks, they wrapped * inside of a {@link WeakReference} and can be removed from memory. If you need to know the results * of finished jobs or whether a job has been run, you can call {@link #getAllJobResults()}. * * @return A duplicate {@link Set} containing all running and cached finished jobs or an empty set. * Never returns {@code null}. The set may be modified without direct effects to the actual * backing store. */ @NonNull public Set<Job> getAllJobs() { return mJobExecutor.getAllJobs(); }
@Test public void verifyGetAllJobResultsReturnsAllResults() { JobExecutor executor = new JobExecutor(); executor.markJobAsFinished(createJobMock(1)); executor.markJobAsFinished(createJobMock(2)); assertThat(executor.getAllJobs()).hasSize(2); assertThat(executor.getAllJobResults().size()).isEqualTo(2); }
/** * Jobs are cached in memory even if they already have finished. But finished jobs are never * restored after the app has relaunched. Since finished jobs could cause memory leaks, they wrapped * inside of a {@link WeakReference} and can be removed from memory. If you need to know the results * of finished jobs or whether a job has been run, you can call {@link #getAllJobResults()}. * * @return A duplicate {@link Set} containing all running and cached finished jobs or an empty set. * Never returns {@code null}. The set may be modified without direct effects to the actual * backing store. */ @NonNull public Set<Job> getAllJobs() { return mJobExecutor.getAllJobs(); }