Interface TaskLambda

  • All Superinterfaces:
    CarrotTask, Serializable
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface TaskLambda
    extends CarrotTask
    This is a functional interface which represents a lambda that will be parsed by Carrot. You may not create an actual instance of this class, instead you use it as follows:
    
    
         @Inject
         MyService myService;
    
         BackgroundTask.enqueue(myService -> myService.doWork("some argument"))
     

    or

    
    
         @Inject
         MyService myService;
    
         taskScheduler.enqueue(myService -> myService.doWork("some argument"))
     

    This functional interface allows you to enqueue background tasks while having an actual instance available of your service. While processing, Carrot will lookup the actual service in the IoC container or create a new instance using the default constructor.