aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectLoaderQueue.java
blob: d68585286974e084b5b264100d6788a42247c27a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (C) 2010, Google Inc. and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.lib;

import java.io.IOException;

import org.eclipse.jgit.errors.MissingObjectException;

/**
 * Queue to open objects asynchronously.
 *
 * A queue may perform background decompression of objects and supply them
 * (possibly out-of-order) to the application.
 *
 * @param <T>
 *            type of identifier supplied to the call that made the queue.
 */
public interface AsyncObjectLoaderQueue<T extends ObjectId> extends
		AsyncOperation {

	/**
	 * Position this queue onto the next available result.
	 *
	 * Even if this method returns true, {@link #open()} may still throw
	 * {@link org.eclipse.jgit.errors.MissingObjectException} if the underlying
	 * object database was concurrently modified and the current object is no
	 * longer available.
	 *
	 * @return true if there is a result available; false if the queue has
	 *         finished its input iteration.
	 * @throws org.eclipse.jgit.errors.MissingObjectException
	 *             the object does not exist. If the implementation is retaining
	 *             the application's objects {@link #getCurrent()} will be the
	 *             current object that is missing. There may be more results
	 *             still available, so the caller should continue invoking next
	 *             to examine another result.
	 * @throws java.io.IOException
	 *             the object store cannot be accessed.
	 */
	boolean next() throws MissingObjectException, IOException;

	/**
	 * Get the current object, null if the implementation lost track.
	 *
	 * @return the current object, null if the implementation lost track.
	 *         Implementations may for performance reasons discard the caller's
	 *         ObjectId and provider their own through {@link #getObjectId()}.
	 */
	T getCurrent();

	/**
	 * Get the ObjectId of the current object. Never null.
	 *
	 * @return the ObjectId of the current object. Never null.
	 */
	ObjectId getObjectId();

	/**
	 * Obtain a loader to read the object.
	 *
	 * This method can only be invoked once per result
	 *
	 * Due to race conditions with a concurrent modification of the underlying
	 * object database, an object may be unavailable when this method is
	 * invoked, even though next returned successfully.
	 *
	 * @return the ObjectLoader to read this object. Never null.
	 * @throws MissingObjectException
	 *             the object does not exist. If the implementation is retaining
	 *             the application's objects {@link #getCurrent()} will be the
	 *             current object that is missing. There may be more results
	 *             still available, so the caller should continue invoking next
	 *             to examine another result.
	 * @throws java.io.IOException
	 *             the object store cannot be accessed.
	 */
	ObjectLoader open() throws IOException;
}