/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Manages a Solaris event port and manipulates a native array of pollfd structs
* on Solaris.
*/
class EventPortWrapper {
// Maximum number of open file descriptors
// Maximum number of events to retrive in one call to port_getn
// initial size of the array to hold pending updates
// maximum size of updateArray
// special update status to indicate that it should be ignored
// port file descriptor
private final int pfd;
// the poll array (populated by port_getn)
private final long pollArrayAddress;
// required when accessing the update* fields
// the number of pending updates
private int updateCount;
// queue of file descriptors with updates pending
// events for file descriptors with registration changes pending, indexed
// by file descriptor and stored as bytes for efficiency reasons. For
// file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
// least then the update is stored in a map.
// Used by release and updateRegistrations to track whether a file
// bit set to indicate if a file descriptor has been visited when
// processing updates (used to avoid duplicates calls to port_associate)
this.pfd = port_create();
if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
eventsHigh = new HashMap<>();
}
}
private short getSource(int i) {
}
int getEventOps(int i) {
}
int getDescriptor(int i) {
if (addressSize == 4) {
} else {
}
}
if (addressSize == 4) {
} else {
}
}
if (fd < MAX_UPDATE_ARRAY_SIZE) {
} else {
}
}
if (fd < MAX_UPDATE_ARRAY_SIZE) {
} else {
// result should never be null
}
}
// update registrations prior to poll
synchronized (updateLock) {
// process newest updates first
int i = updateCount - 1;
while (i >= 0) {
int fd = updateDescriptors[i];
if (ev == 0) {
}
} else {
}
}
}
}
i--;
}
updateCount = 0;
}
// poll for events
// after polling we need to queue all polled file descriptors as they
// are candidates to register for the next poll.
synchronized (updateLock) {
for (int i=0; i<updated; i++) {
if (getSource(i) == PORT_SOURCE_USER) {
interrupted = true;
setDescriptor(i, -1);
} else {
// the default is to re-associate for the next poll
int fd = getDescriptor(i);
}
}
}
return updated;
}
// record the file descriptor and events, expanding the
// respective arrays first if necessary.
if (updateCount >= oldCapacity) {
int[] newDescriptors = new int[newCapacity];
}
}
synchronized (updateLock) {
}
}
synchronized (updateLock) {
try {
} catch (IOException ioe) {
InternalError x =
throw x;
}
}
}
}
// -- wakeup support --
private boolean interrupted;
public void interrupt() {
try {
} catch (IOException ioe) {
InternalError x =
throw x;
}
}
boolean interrupted() {
return interrupted;
}
void clearInterrupted() {
interrupted = false;
}
}