|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.util.RequestProcessor
Request processor that is capable to execute requests in dedicated threads. You can create your own instance or use the shared one.
There are several use cases for RequestProcessor:
RequestProcessor.getDefault()
.post(runnable)
for this purpose.
RequestProcessor.getDefault()
.post(runnable, delay)
RequestProcessor.Task
's ability to
schedule()
, like
static RequestProcessor.Task CLEANER = RequestProcessor.getDefault().post(runnable,DELAY); public void run() { doTheWork(); CLEANER.schedule(DELAY); }Note: Please think twice before implementing some periodic background activity. It is generally considered evil if it will run regardless of user actions and the IDE state, even while the application is minimized / not currently used.
RequestProcessor(name)
and use it from all places you'd like to have serialized. It works
like a simple Mutex.
RequestProcessor(name,throughput)
set proper throughput and use it to schedule the work.
It works like a queue of requests passing through a semafore with predefined
number of DOWN()
s.
RequestProcessor
instance with limited throughput (probably
set to 1), the IDE would try to run all your requests in parallel otherwise.
Nested Class Summary | |
class |
RequestProcessor.Task
The task describing the request sent to the processor. |
Constructor Summary | |
RequestProcessor()
Creates new RequestProcessor with automatically assigned unique name. |
|
RequestProcessor(String name)
Creates a new named RequestProcessor with throughput 1. |
|
RequestProcessor(String name,
int throughput)
Creates a new named RequestProcessor with defined throughput. |
Method Summary | |
RequestProcessor.Task |
create(Runnable run)
Creates request that can be later started by setting its delay. |
static RequestProcessor.Task |
createRequest(Runnable run)
Deprecated. Sharing of one singlethreaded RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases. |
static RequestProcessor |
getDefault()
The getter for the shared instance of the RequestProcessor . |
boolean |
isRequestProcessorThread()
Tests if the current thread is request processor thread. |
RequestProcessor.Task |
post(Runnable run)
This methods asks the request processor to start given runnable immediately. |
RequestProcessor.Task |
post(Runnable run,
int timeToWait)
This methods asks the request processor to start given runnable after timeToWait milliseconds. |
RequestProcessor.Task |
post(Runnable run,
int timeToWait,
int priority)
This methods asks the request processor to start given runnable after timeToWait milliseconds. |
static RequestProcessor.Task |
postRequest(Runnable run)
Deprecated. Sharing of one singlethreaded RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases. |
static RequestProcessor.Task |
postRequest(Runnable run,
int timeToWait)
Deprecated. Sharing of one singlethreaded RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases. |
static RequestProcessor.Task |
postRequest(Runnable run,
int timeToWait,
int priority)
Deprecated. Sharing of one singlethreaded RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases. |
void |
stop()
Stops processing of runnables processor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RequestProcessor()
public RequestProcessor(String name)
name
- the name to use for the request processor threadpublic RequestProcessor(String name, int throughput)
name
- the name to use for the request processor threadthroughput
- the maximal count of requests allowed to run in parallelMethod Detail |
public static RequestProcessor getDefault()
RequestProcessor
.
public RequestProcessor.Task post(Runnable run)
Thread.MIN_PRIORITY
.
run
- class to run
public RequestProcessor.Task post(Runnable run, int timeToWait)
timeToWait
milliseconds. The default priority is Thread.MIN_PRIORITY
.
run
- class to runtimeToWait
- to wait before execution
public RequestProcessor.Task post(Runnable run, int timeToWait, int priority)
timeToWait
milliseconds. Given priority is assigned to the
request. For request relaying please consider:
post(run, timeToWait, Thread.currentThread().getPriority());
run
- class to runtimeToWait
- to wait before executionpriority
- the priority from Thread.MIN_PRIORITY
to Thread.MAX_PRIORITY
public RequestProcessor.Task create(Runnable run)
run
- action to run in the process
public boolean isRequestProcessorThread()
waitFinished
method. Any two tasks created
by request processor must not wait for themself.
true
if the current thread is request processor
thread, otherwise false
public void stop()
public static RequestProcessor.Task postRequest(Runnable run)
RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases.
timeToWait
milliseconds. The default priority is Thread.MIN_PRIORITY
.
run
- class to run
public static RequestProcessor.Task postRequest(Runnable run, int timeToWait)
RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases.
timeToWait
milliseconds.
The default priority is Thread.MIN_PRIORITY
.
run
- class to runtimeToWait
- to wait before execution
public static RequestProcessor.Task postRequest(Runnable run, int timeToWait, int priority)
RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases.
timeToWait
milliseconds. Given priority is assigned to the
request.
run
- class to runtimeToWait
- to wait before executionpriority
- the priority from Thread.MIN_PRIORITY
to Thread.MAX_PRIORITY
public static RequestProcessor.Task createRequest(Runnable run)
RequestProcessor
among different users and posting even blocking requests is inherently
deadlock-prone. See use cases.
run
- action to run in the process
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |