/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.aspects.concurrent;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;


/**
 * Attach a semaphore to a method.
 * Only a certain amount of threads are allowed to access that method at one time.
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 */
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SemaphoredMethod
{
   /**
    * max number of permits
    */
   int permits();
   boolean isFair() default false;

   long timeout() default -1;
   TimeUnit unit() default TimeUnit.MILLISECONDS;
}
