blob: e97be617459189966474d2604c867f13fb53b5bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* Operation.java February 2007
*
* Copyright (C) 2007, Niall Gallagher <niallg@users.sf.net>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.simpleframework.transport.reactor;
import java.nio.channels.SelectableChannel;
import org.simpleframework.transport.trace.Trace;
/**
* The <code>Operation</code> interface is used to describe a task
* that can be executed when the associated channel is ready for some
* operation. Typically the <code>SelectableChannel</code> is used to
* register with a selector with a set of given interested operations
* when those operations can be performed this is executed.
*
* @author Niall Gallagher
*
* @see org.simpleframework.transport.reactor.Reactor
*/
public interface Operation extends Runnable {
/**
* This is used to acquire the trace object that is associated
* with the operation. A trace object is used to collection details
* on what operations are being performed. For instance it may
* contain information relating to I/O events or errors.
*
* @return this returns the trace associated with this operation
*/
Trace getTrace();
/**
* This is the <code>SelectableChannel</code> which is used to
* determine if the operation should be executed. If the channel
* is ready for a given I/O event it can be run. For instance if
* the operation is used to perform some form of read operation
* it can be executed when ready to read data from the channel.
*
* @return this returns the channel used to govern execution
*/
SelectableChannel getChannel();
/**
* This is used to cancel the operation if it has timed out. This
* is typically invoked when it has been waiting in a selector for
* an extended duration of time without any active operations on
* it. In such a case the reactor must purge the operation to free
* the memory and open channels associated with the operation.
*/
void cancel();
}
|