All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pcj.internal.message.splitgroup.SplitGroupFuture Maven / Gradle / Ivy

Go to download

PCJ is Java library for parallel computing in Java. It is based on the PGAS (Partitioned Global Address Space) paradigm. It allows for easy implementation in Java of any parallel algorithm. PCJ application can be run on laptop, workstation, cluster and HPC system including large supercomputers.

The newest version!
/*
 * Copyright (c) 2011-2021, PCJ Library, Marek Nowicki
 * All rights reserved.
 *
 * Licensed under New BSD License (3-clause license).
 *
 * See the file "LICENSE" for the full license governing this code.
 */
package org.pcj.internal.message.splitgroup;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.pcj.Group;
import org.pcj.PcjFuture;
import org.pcj.PcjRuntimeException;
import org.pcj.internal.InternalFuture;

/*
 * @author Marek Nowicki ([email protected])
 */
public class SplitGroupFuture extends InternalFuture implements PcjFuture {

    private Group group;

    SplitGroupFuture() {
    }

    protected void setGroup(Group group) {
        this.group = group;
    }

    protected void signalDone() {
        super.signal();
    }

    @Override
    public boolean isDone() {
        return super.isSignaled();
    }

    @Override
    public Group get() throws PcjRuntimeException {
        try {
            super.await();
        } catch (InterruptedException ex) {
            throw new PcjRuntimeException(ex);
        }
        return group;
    }

    @Override
    public Group get(long timeout, TimeUnit unit) throws TimeoutException, PcjRuntimeException {
        try {
            super.await(timeout, unit);
        } catch (InterruptedException ex) {
            throw new PcjRuntimeException(ex);
        }
        return group;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy