public Future<T> retrieve(String key, boolean executeInline) {

		// Sanity checks.
		assert (key != null);

		// Must keep track of whether a new task was created, so that it can
		// possibly be submitted to an execution queue.
		boolean createdTask = false;

		// Extract the task related to this object from the cache.
		Task<T> task = cache.get(key);

		// Oops, the associated task did not exist.
		if (task == null) {

			// Create a new task for the given object.
			Task<T> newTask = createTask(key);

			// Atomically insert this into the cache.
			Task<T> existingEntry = cache.putIfAbsent(key, newTask);

			if (existingEntry == null) {

				// The new task was actually inserted into the cache. Indicate
				// that the a new task was created and set value for treatment
				// below.
				createdTask = true;
				task = newTask;
			} else {

				// Unlucky; another thread beat us to creating the task. Use the
				// task created by the other thread, throwing away the one we
				// created above.
				task = existingEntry;
			}

		}

		if (executeInline) {

			// The client indicated that it will wait for the result and it
			// is OK to try to build this task inline.
			task.run();

		} else {

			// If we created a task and we're not going to run it immediately,
			// make sure it gets submitted to an execution queue.
			if (createdTask) {
				compiler.submit(task);
			}

		}

		return task;
	}
public Future < T > retrieve ( String key , boolean executeInline ) { assert ( key != null ) ; boolean createdTask = false ; Task < T > task = cache . get ( key ) ; if ( task == null ) { Task < T > newTask = createTask ( key ) ; Task < T > existingEntry = cache . putIfAbsent ( key , newTask ) ; if ( existingEntry == null ) { createdTask = true ; task = newTask ; } else { task = existingEntry ; } } if ( executeInline ) { task . run ( ) ; } else { if ( createdTask ) { compiler . submit ( task ) ; } } return task ; }
Returns a <code>Future</code> corresponding to the named object template;
this will add a new entry if one does not yet exist for the given key.

@param key
key to use for the lookup, typically an object or template
name
@param executeInline
If the client is going to wait for the task to complete, then
it can indicate that the task can be run inline.

@return <code>Future</code> that references the compiled template