1 |
package manta.runtime; |
package gnu.java.nio; |
2 |
|
|
3 |
import java.util.*; |
import java.util.*; |
4 |
import java.nio.channels.*; |
import java.nio.channels.*; |
9 |
{ |
{ |
10 |
Set keys, selected, canceled; |
Set keys, selected, canceled; |
11 |
|
|
12 |
SelectorImpl(SelectorProvider provider) |
public SelectorImpl(SelectorProvider provider) |
13 |
{ |
{ |
14 |
super(provider); |
super(provider); |
15 |
} |
} |
16 |
|
|
17 |
Set keys() |
public Set keys() |
18 |
{ |
{ |
19 |
return keys; |
return keys; |
20 |
} |
} |
21 |
|
|
22 |
int selectNow() { return select(1); } |
public int selectNow() { return select(1); } |
23 |
int select() { return select(Long.MAX_VALUE); } |
public int select() { return select(Long.MAX_VALUE); } |
24 |
|
|
25 |
private static MantaNative int java_do_select(int []read, |
private static native int java_do_select(int []read, |
26 |
int []write, |
int []write, |
27 |
int []except, |
int []except, |
28 |
long timeout); |
long timeout); |
29 |
|
|
30 |
int select(long timeout) |
public int select(long timeout) |
31 |
{ |
{ |
32 |
if (keys == null) |
if (keys == null) |
33 |
{ |
{ |
72 |
return ret; |
return ret; |
73 |
} |
} |
74 |
|
|
|
|
|
|
Set selectedKeys() { return selected; } |
|
|
Set cancelledKeys() { return canceled; } |
|
|
|
|
|
|
|
75 |
|
|
76 |
Selector wakeup() |
public Set selectedKeys() { return selected; } |
77 |
|
public Set cancelledKeys() { return canceled; } |
78 |
|
|
79 |
|
public Selector wakeup() |
80 |
{ |
{ |
81 |
return null; |
return null; |
82 |
} |
} |
83 |
|
|
84 |
void add(SelectionKeyImpl k) |
public void add(SelectionKeyImpl k) |
85 |
{ |
{ |
86 |
if (keys == null) |
if (keys == null) |
87 |
keys = new HashSet(); |
keys = new HashSet(); |
88 |
|
|
89 |
keys.add(k); |
keys.add(k); |
90 |
} |
} |
91 |
|
|
92 |
void add_selected(SelectionKeyImpl k) |
void add_selected(SelectionKeyImpl k) |
93 |
{ |
{ |
94 |
if (selected == null) |
if (selected == null) |
117 |
{ |
{ |
118 |
/* |
/* |
119 |
// filechannel is not selectable ? |
// filechannel is not selectable ? |
120 |
if (ch instanceof manta.runtime.FileChannelImpl) |
if (ch instanceof gnu.java.nio.FileChannelImpl) |
121 |
{ |
{ |
122 |
FileChannelImpl fc = (FileChannelImpl) ch; |
FileChannelImpl fc = (FileChannelImpl) ch; |
123 |
|
|
132 |
else |
else |
133 |
*/ |
*/ |
134 |
|
|
135 |
if (ch instanceof manta.runtime.SocketChannelImpl) |
if (ch instanceof gnu.java.nio.SocketChannelImpl) |
136 |
{ |
{ |
137 |
SocketChannelImpl fc = (SocketChannelImpl) ch; |
SocketChannelImpl fc = (SocketChannelImpl) ch; |
138 |
|
|