sun.nio.ch.ThreadPool Java Examples

The following examples show how to use sun.nio.ch.ThreadPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnixFileSystemProvider.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #2
Source File: UnixChannelFactory.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #3
Source File: UnixFileSystemProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #4
Source File: UnixChannelFactory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #5
Source File: UnixFileSystemProvider.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #6
Source File: UnixChannelFactory.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #7
Source File: UnixFileSystemProvider.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #8
Source File: UnixChannelFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #9
Source File: UnixFileSystemProvider.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #10
Source File: UnixChannelFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #11
Source File: UnixFileSystemProvider.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #12
Source File: UnixChannelFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #13
Source File: UnixFileSystemProvider.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #14
Source File: UnixChannelFactory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #15
Source File: UnixChannelFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #16
Source File: UnixChannelFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #17
Source File: UnixFileSystemProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #18
Source File: UnixChannelFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #19
Source File: UnixFileSystemProvider.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #20
Source File: UnixChannelFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #21
Source File: UnixFileSystemProvider.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #22
Source File: UnixChannelFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #23
Source File: UnixFileSystemProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #24
Source File: UnixChannelFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an asynchronous file channel by opening the given file.
 */
static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
                                                          Set<? extends OpenOption> options,
                                                          int mode,
                                                          ThreadPool pool)
    throws UnixException
{
    Flags flags = Flags.toFlags(options);

    // default is reading
    if (!flags.read && !flags.write) {
        flags.read = true;
    }

    // validation
    if (flags.append)
        throw new UnsupportedOperationException("APPEND not allowed");

    // for now use simple implementation
    FileDescriptor fdObj = open(-1, path, null, flags, mode);
    return SimpleAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
}
 
Example #25
Source File: UnixFileSystemProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #26
Source File: UnixFileSystemProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path obj,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs) throws IOException
{
    UnixPath file = checkPath(obj);
    int mode = UnixFileModeAttribute
        .toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    try {
        return UnixChannelFactory
            .newAsynchronousFileChannel(file, options, mode, pool);
    } catch (UnixException x) {
        x.rethrowAsIOException(file);
        return null;
    }
}
 
Example #27
Source File: WindowsFileSystemProvider.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs)
    throws IOException
{
    if (path == null)
        throw new NullPointerException();
    if (!(path instanceof WindowsPath))
        throw new ProviderMismatchException();
    WindowsPath file = (WindowsPath)path;
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    WindowsSecurityDescriptor sd =
        WindowsSecurityDescriptor.fromAttribute(attrs);
    try {
        return WindowsChannelFactory
            .newAsynchronousFileChannel(file.getPathForWin32Calls(),
                                        file.getPathForPermissionCheck(),
                                        options,
                                        sd.address(),
                                        pool);
    } catch (WindowsException x) {
        x.rethrowAsIOException(file);
        return null;
    } finally {
        if (sd != null)
            sd.release();
    }
}
 
Example #28
Source File: WindowsFileSystemProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs)
    throws IOException
{
    if (path == null)
        throw new NullPointerException();
    if (!(path instanceof WindowsPath))
        throw new ProviderMismatchException();
    WindowsPath file = (WindowsPath)path;
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    WindowsSecurityDescriptor sd =
        WindowsSecurityDescriptor.fromAttribute(attrs);
    try {
        return WindowsChannelFactory
            .newAsynchronousFileChannel(file.getPathForWin32Calls(),
                                        file.getPathForPermissionCheck(),
                                        options,
                                        sd.address(),
                                        pool);
    } catch (WindowsException x) {
        x.rethrowAsIOException(file);
        return null;
    } finally {
        if (sd != null)
            sd.release();
    }
}
 
Example #29
Source File: WindowsFileSystemProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs)
    throws IOException
{
    if (path == null)
        throw new NullPointerException();
    if (!(path instanceof WindowsPath))
        throw new ProviderMismatchException();
    WindowsPath file = (WindowsPath)path;
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    WindowsSecurityDescriptor sd =
        WindowsSecurityDescriptor.fromAttribute(attrs);
    try {
        return WindowsChannelFactory
            .newAsynchronousFileChannel(file.getPathForWin32Calls(),
                                        file.getPathForPermissionCheck(),
                                        options,
                                        sd.address(),
                                        pool);
    } catch (WindowsException x) {
        x.rethrowAsIOException(file);
        return null;
    } finally {
        if (sd != null)
            sd.release();
    }
}
 
Example #30
Source File: WindowsFileSystemProvider.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
                                                          Set<? extends OpenOption> options,
                                                          ExecutorService executor,
                                                          FileAttribute<?>... attrs)
    throws IOException
{
    if (path == null)
        throw new NullPointerException();
    if (!(path instanceof WindowsPath))
        throw new ProviderMismatchException();
    WindowsPath file = (WindowsPath)path;
    ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
    WindowsSecurityDescriptor sd =
        WindowsSecurityDescriptor.fromAttribute(attrs);
    try {
        return WindowsChannelFactory
            .newAsynchronousFileChannel(file.getPathForWin32Calls(),
                                        file.getPathForPermissionCheck(),
                                        options,
                                        sd.address(),
                                        pool);
    } catch (WindowsException x) {
        x.rethrowAsIOException(file);
        return null;
    } finally {
        if (sd != null)
            sd.release();
    }
}