< prev index next >

src/java.base/share/classes/java/nio/channels/spi/AbstractSelectableChannel.java

Print this page
rev 48757 : [mq]: nio-cleanup

*** 1,7 **** /* ! * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,34 **** */ package java.nio.channels.spi; import java.io.IOException; ! import java.nio.channels.*; /** * Base implementation class for selectable channels. * --- 24,41 ---- */ package java.nio.channels.spi; import java.io.IOException; ! import java.nio.channels.CancelledKeyException; ! import java.nio.channels.ClosedChannelException; ! import java.nio.channels.ClosedSelectorException; ! import java.nio.channels.IllegalBlockingModeException; ! import java.nio.channels.IllegalSelectorException; ! import java.nio.channels.SelectableChannel; ! import java.nio.channels.SelectionKey; ! import java.nio.channels.Selector; /** * Base implementation class for selectable channels. *
*** 65,76 **** private final Object keyLock = new Object(); // Lock for registration and configureBlocking operations private final Object regLock = new Object(); ! // Blocking mode, protected by regLock ! boolean blocking = true; /** * Initializes a new instance of this class. * * @param provider --- 72,83 ---- private final Object keyLock = new Object(); // Lock for registration and configureBlocking operations private final Object regLock = new Object(); ! // Blocking mode, need regLock to change; ! private volatile boolean nonBlocking; /** * Initializes a new instance of this class. * * @param provider
*** 195,205 **** synchronized (regLock) { if (!isOpen()) throw new ClosedChannelException(); if ((ops & ~validOps()) != 0) throw new IllegalArgumentException(); ! if (blocking) throw new IllegalBlockingModeException(); SelectionKey k = findKey(sel); if (k != null) { k.interestOps(ops); k.attach(att); --- 202,212 ---- synchronized (regLock) { if (!isOpen()) throw new ClosedChannelException(); if ((ops & ~validOps()) != 0) throw new IllegalArgumentException(); ! if (isBlocking()) throw new IllegalBlockingModeException(); SelectionKey k = findKey(sel); if (k != null) { k.interestOps(ops); k.attach(att);
*** 262,274 **** // -- Blocking -- public final boolean isBlocking() { ! synchronized (regLock) { ! return blocking; ! } } public final Object blockingLock() { return regLock; } --- 269,279 ---- // -- Blocking -- public final boolean isBlocking() { ! return !nonBlocking; } public final Object blockingLock() { return regLock; }
*** 285,300 **** throws IOException { synchronized (regLock) { if (!isOpen()) throw new ClosedChannelException(); ! if (blocking == block) ! return this; if (block && haveValidKeys()) throw new IllegalBlockingModeException(); implConfigureBlocking(block); ! blocking = block; } return this; } /** --- 290,306 ---- throws IOException { synchronized (regLock) { if (!isOpen()) throw new ClosedChannelException(); ! boolean blocking = !nonBlocking; ! if (block != blocking) { if (block && haveValidKeys()) throw new IllegalBlockingModeException(); implConfigureBlocking(block); ! nonBlocking = !block; ! } } return this; } /**
< prev index next >