/** * Execute the supplied {@link Callable} under a lock determined by the * descriptor. * * @param <R> the result type * @param callable the operation to perform under lock * @return whatever the supplied {@link Callable} returns * @throws Exception if the supplied {@link Callable} throws an exception */ <R> R withLock(final @NotNull Callable<R> callable) throws Exception;
/** * Execute the supplied {@link Runnable} under a lock determined by the * descriptor. * * @param runnable the operation to perform under lock */ void withLock(final @NotNull Runnable runnable);
/** * A {@link Supplier} of {@link ReentrantReadWriteLock read write locks}. * * @return lock factory */ static @NotNull com.atlassian.util.concurrent.Supplier<ReadWriteLock> readWriteLockFactory() { return new com.atlassian.util.concurrent.Supplier<ReadWriteLock>() { public ReadWriteLock get() { return new ReentrantReadWriteLock(); } }; }
/** * Execute the supplied {@link Supplier} under a lock determined by the * descriptor. * <p> * Unlike {@link #withLock(Callable)} this version returns a result and does * not declare a checked exception. * * @param <R> the result type * @param supplier the operation to perform under lock * @return whatever the supplied {@link Callable} returns */ <R> R withLock(final @NotNull Supplier<R> supplier);
/** * A {@link Supplier} of {@link ReentrantLock locks}. * * @return lock factory */ static @NotNull com.atlassian.util.concurrent.Supplier<Lock> lockFactory() { return new com.atlassian.util.concurrent.Supplier<Lock>() { public Lock get() { return new ReentrantLock(); } }; }
/** * Get a {@link ManagedLock.ReadWrite} that manages the supplied * {@link ReadWriteLock}. * * @param lock the lock to use. * @return a managed read write lock */ public static @NotNull ManagedLock.ReadWrite manageReadWrite(final @NotNull ReadWriteLock lock) { return new ReadWriteManagedLock(lock); }
/** * Get a {@link ManagedLock} that manages a {@link ReentrantLock}. * * @return a managed lock */ public static @NotNull ManagedLock newManagedLock() { return manage(new ReentrantLock()); }
/** * Creates a new SRSW BlockingReference. * * @deprecated use {@link #newSRSW()} instead. */ @Deprecated public BlockingReference(@NotNull final V value) { this(new BooleanLatch(), value); }
/** * Construct a new {@link WeakMemoizer} instance. * * @param initialCapacity how large the internal map should be initially. * @param delegate for creating the initial values. * @throws IllegalArgumentException if the initial capacity of elements is * negative. */ WeakMemoizer(final @NotNull Function<K, V> delegate) { this.map = new ConcurrentHashMap<K, MappedReference<K, V>>(); this.delegate = notNull("delegate", delegate); }
/** * Create a Builder with the supplied Executor * * @param executor */ public Builder(@NotNull final Executor executor) { this.executor = notNull("executor", executor); }
/** * Get a function that uses the Supplier as a factory for all inputs. * * @param <D> the key type, ignored * @param <R> the result type * @param supplier called for all inputs * @return the function */ public static <D, R> Function<D, R> fromSupplier(final @NotNull Supplier<R> supplier) { return new FromSupplier<D, R>(supplier); }
@Override public Collection<ProjectConfiguration> load(@NotNull Long projectId) { ProjectConfigurationAO[] projectConfigurationAOs = getAO().find( ProjectConfigurationAO.class, ProjectConfigurationAO.COLUMN_PROJECT_ID + " = ?", projectId); return Arrays.<ProjectConfiguration>asList(projectConfigurationAOs); } }
/** * Get a {@link ThreadFactory} with the required name prefix and type (user or * daemon). The produced threads have normal priority. * * @param name the prefix to use for naming the threads. * @param type whether they are User or Daemon threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name, @NotNull final Type type) { return named(name).type(type).build(); }
/** * Convenience method that calls * {@link ManagedLocks#weakManagedLockFactory(Function)} using the * {@link Functions#identity() identity function} for striping, essentially * meaning that unique input will have its own lock. * * @param <T> the type of the thing used to look up locks * @see #weakManagedLockFactory(Function, Supplier) */ public static @NotNull <T> com.atlassian.util.concurrent.Function<T, ManagedLock> weakManagedLockFactory() { return weakManagedLockFactory(Functions.<T> identity()); }
/** * Set the value of this reference. This method is lock-free. A thread waiting * in {@link #take()} or {@link #take(long, TimeUnit)} will be released and * given this value. * * @param value the new value. */ public void set(@NotNull final V value) { notNull("value", value); internalSet(value); }
/** * Get a {@link ThreadFactory} with the required name prefix. The produced * threads are user threads and have normal priority. * * @param name the prefix to use for naming the threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name) { return named(name).build(); }
@Override public void init(@NotNull Plugin plugin, @NotNull Element element) throws PluginParseException { super.init(plugin, element); this.type = getOptionalAttribute(element, "type", getKey()); this.schemaFactoryClassName = getOptionalAttribute(element, "schema-factory-class", null); this.schemaTransformerClassName = getOptionalAttribute(element, "schema-transformer-class", null); this.maxOccurs = getOptionalAttribute(element, "max-occurs", "unbounded"); this.requiredPermissions = getPermissions(element.element("required-permissions")); this.optionalPermissions = getPermissions(element.element("optional-permissions")); }