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

groovyx.gpars.csp.ChannelOutputList.groovy Maven / Gradle / Ivy

Go to download

The Groovy and Java high-level concurrency library offering actors, dataflow, CSP, agents, parallel collections, fork/join and more

There is a newer version: 1.2.1
Show newest version
// GPars - Groovy Parallel Systems
//
// Copyright © 2008-10  The original author or authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package groovyx.gpars.csp

import org.jcsp.lang.Channel
import org.jcsp.plugNplay.ProcessWrite

/**
 * ChannelOutputList is used to create a list of
 * ChannelOUTPUTEnds
 * 

Company: Napier University

* * @author Jon Kerridge, Ken Barclay, John Savage * @version 1.0 * * @version 1.1 included the empty constructor to enable * easier NetChannelOUTPUT list creation (Jon Kerridge) * and changes to comply with Groovy-jsr03 */ class ChannelOutputList { def cList = [] /** * ChannelOutputList uses the ArrayList class of java * This ChannelOutputList takes an array of One2OneChannels as its * constructor parameter and converts them to a list of ChannelOUTPUTEnds * */ ChannelOutputList(channelArray) { cList = (Arrays.asList(Channel.getOutputArray(channelArray))) } /** * ChannelOutputList uses the ArrayList class of java * This constructor creates an empty ArrayList to be populated with * NetChannelOUTPUTs * */ ChannelOutputList() { // nothing required it is just an empty list } def append(value) { cList << value } def size() { return cList.size() } def contains(value) { return cList.contains(value) } def remove(value) { return cList.remove(value) } def minus(list) { return cList - list } def plus(list) { return cList + list } def putAt(index, value) { cList[index] = value } def getAt(index) { return cList[index] } def Object[] toArray() { return cList.toArray() } def write(value) { def channels = cList.size() def writerList = [] (0.. writerList[i] = new ProcessWrite(cList[i]) writerList[i].value = value } def parWrite = new PAR(writerList) parWrite.run() } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy