KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonathan > apis > resources > Scheduler


1 /***
2  * Jonathan: an Open Distributed Processing Environment
3  * Copyright (C) 1999 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 2.0
20  *
21  * Contact: jonathan@objectweb.org
22  *
23  * Author: Bruno Dumant
24  *
25  */

26
27
28 package org.objectweb.jonathan.apis.resources;
29
30 /**
31  * Schedulers are used to create and schedule Jobs.
32  * <p>
33  * To allow application programmers to change the default scheduling used by Java,
34  * and to implement some resource management policy on activity resources
35  * (threads), Jonathan introduces abstractions to represent activities
36  * (interface {@link Job Job}) and schedulers
37  * (interface {@link Scheduler Scheduler}).
38  * <p>
39  * A Job is the abstraction of an activity in the system. When this activity
40  * is sequential
41  * (the usual case), it may be thought of as a thread. The role of a scheduler is
42  * to create Jobs (a scheduler is a job factory), and to manage them according to
43  * their properties (a priority, a deadline, ...). A scheduler has thus the
44  * responsibility to associate a Job with some processing resource (which may be
45  * a processor, or more simply a Java thread) when it is entitled to run.
46  */

47 public interface Scheduler {
48
49    
50    /**
51     * Returns a new job created by the scheduler.
52     * @return a new job created by the scheduler.
53     */

54    public Job newJob();
55
56    
57    /**
58     * Returns the currently executing job (the job performing the call).
59     * @return the currently executing job.
60     */

61    public Job getCurrent();
62
63    
64    /**
65     * Calling this method gives the opportunity to the scheduler to re-schedule
66     * the currently executing jobs.
67     */

68    public void yield();
69    
70    /**
71     * Blocks the calling job until the {@link #notify(Object) <tt>notify</tt>} or
72     * {@link #notifyAll(Object) <tt>notifyAll</tt>} method is called providing the
73     * same lock identifier.
74     * @param lock the lock identifier.
75     * @exception InterruptedException
76     */

77    public void wait(Object JavaDoc lock) throws InterruptedException JavaDoc;
78
79    /**
80     * Blocks the calling job until the {@link #notify(Object) <tt>notify</tt>} or
81     * {@link #notifyAll(Object) <tt>notifyAll</tt>} method is called providing the
82     * same lock identifier.
83     * @param lock the lock identifier.
84     * @param millis a time out in milliseconds.
85     * @exception InterruptedException
86     */

87    public void wait(Object JavaDoc lock,long millis) throws InterruptedException JavaDoc;
88
89    /**
90     * Unblocks a job {@link #wait(Object) waiting} on the lock.
91     * @param lock the lock identifier.
92     */

93    public void notify(Object JavaDoc lock);
94
95    
96    /**
97     * Unblocks all jobs {@link #wait(Object) waiting} on the lock.
98     * @param lock the lock identifier.
99     */

100    public void notifyAll(Object JavaDoc lock);
101
102    
103    /**
104     * Causes the calling job to be removed from the set of jobs managed by the
105     * target scheduler. It is necessary to call this method before every possibly
106     * blocking method so that the scheduler can give a chance to run to another job.
107     */

108    public void escape();
109
110    /**
111     * Causes a job {@link #escape() "escaped"} from the scheduler to be re-admitted
112     * in the set of jobs managed by the target scheduler.
113     */

114    public void enter();
115 }
116
117
118
Popular Tags