├── .gitignore ├── .travis.yml ├── GPars_CI_only.iml ├── GPars_CI_only.ipr ├── LICENSE.txt ├── README.idea ├── README.md ├── artwork ├── GPars_logo.zip ├── gpars-logo.PNG ├── gpars-rgb-reverse-grey.svg ├── gpars-rgb-square-page.svg ├── gpars-rgb.svg ├── gpars_14x14.png ├── gpars_192x192.png ├── gpars_64x64.png └── license.txt ├── bambooBuild ├── bambooBuildRelease ├── build.gradle ├── buildSrc ├── build.gradle └── src │ └── main │ └── groovy │ ├── Coverage.groovy │ └── DemoTask.groovy ├── config └── codenarc │ └── codenarc.groovy ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── java-demo ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── gpars-java-demo.iml ├── java-demo.iml ├── java-demo.ipr ├── pom.xml └── src │ └── test │ └── java │ └── org │ └── codehaus │ └── gpars │ └── javademo │ ├── AgentTest.java │ ├── DataflowOperatorFibTest.java │ ├── DataflowOperatorTest.java │ ├── DataflowTaskTest.java │ ├── ReactorTest.java │ ├── StatefulActorTest.java │ ├── StatelessActorTest.java │ └── benchmark │ ├── ActorBenchmarkTest.java │ ├── DownloadStatefulDynamicDispatchActor.java │ ├── IndexStatefulDynamicDispatchActor.java │ ├── PipelineStatelessActorTest.java │ ├── StatefulDynamicDispatchActor.java │ └── WriteStatefulDynamicDispatchActor.java ├── lib └── caliper-1.0-SNAPSHOT.jar ├── licenses ├── LICENSE-multiverse.txt ├── LICENSE-netty.txt ├── LICENSE.base64.txt ├── LICENSE.commons-logging.txt ├── LICENSE.felix.txt ├── LICENSE.guice.txt ├── LICENSE.jboss-logging.txt ├── LICENSE.jboss-microcontainer.txt ├── LICENSE.jsr166y.txt ├── LICENSE.log4j.txt ├── LICENSE.protobuf.txt ├── LICENSE.slf4j.txt ├── LICENSE.spring.txt ├── LICENSE.xnio.txt └── NOTICE-netty.txt ├── overview.html ├── settings.gradle └── src ├── main ├── assembly │ └── all.xml ├── groovy │ └── groovyx │ │ └── gpars │ │ ├── AsyncException.java │ │ ├── AsyncFun.java │ │ ├── DataflowMessagingRunnable.java │ │ ├── Definitions.gdsl │ │ ├── GParsConfig.java │ │ ├── GParsExecutorsPool.groovy │ │ ├── GParsExecutorsPoolEnhancer.groovy │ │ ├── GParsExecutorsPoolUtil.groovy │ │ ├── GParsPool.groovy │ │ ├── GParsPoolUtil.java │ │ ├── MessagingRunnable.java │ │ ├── Parallel.groovy │ │ ├── ParallelEnhancer.groovy │ │ ├── ReactorMessagingRunnable.java │ │ ├── ThreadLocalPools.java │ │ ├── TransparentParallel.groovy │ │ ├── activeobject │ │ ├── ActiveMethod.java │ │ ├── ActiveObject.java │ │ ├── ActiveObjectASTTransformation.java │ │ ├── ActiveObjectRegistry.java │ │ ├── ActorWithExceptionHandler.java │ │ └── InternalActor.java │ │ ├── actor │ │ ├── AbstractLoopingActor.java │ │ ├── Actor.java │ │ ├── ActorMessage.java │ │ ├── ActorTimerTask.java │ │ ├── Actors.java │ │ ├── BlockingActor.java │ │ ├── DDAHelper.groovy │ │ ├── DefaultActor.java │ │ ├── DefaultActorClosure.java │ │ ├── DynamicDispatchActor.java │ │ ├── ForwardingDelegate.java │ │ ├── ReactiveActor.java │ │ ├── StaticDispatchActor.java │ │ ├── impl │ │ │ ├── ActorException.java │ │ │ ├── ActorReplyException.java │ │ │ ├── ActorStopException.java │ │ │ ├── ActorTerminationException.java │ │ │ ├── DDAClosure.groovy │ │ │ ├── MessageStream.java │ │ │ ├── ReplyingMessageStream.java │ │ │ ├── RunnableBackedBlockingActor.java │ │ │ ├── SDAClosure.java │ │ │ ├── SequentialProcessingActor.java │ │ │ └── package.html │ │ ├── package.html │ │ └── remote │ │ │ ├── RemoteActor.java │ │ │ ├── RemoteActors.java │ │ │ └── RemoteActorsUrlUtils.java │ │ ├── agent │ │ ├── Agent.java │ │ ├── AgentBase.java │ │ ├── AgentCore.java │ │ ├── AgentThreadFactory.java │ │ └── remote │ │ │ ├── AgentClosureExecutionClosure.java │ │ │ ├── AgentClosureExecutionPolicy.java │ │ │ ├── RemoteAgent.java │ │ │ ├── RemoteAgentMock.java │ │ │ └── RemoteAgents.java │ │ ├── csp │ │ ├── ALT.groovy │ │ ├── ChannelInputList.groovy │ │ ├── ChannelOutputList.groovy │ │ ├── GroovyMobileProcess.groovy │ │ ├── JCSPCopy.groovy │ │ ├── MobileAgent.groovy │ │ ├── PAR.groovy │ │ ├── plugAndPlay │ │ │ ├── GConsole.groovy │ │ │ ├── GConsoleStringToInteger.groovy │ │ │ ├── GDelta2.groovy │ │ │ ├── GFixedDelay.groovy │ │ │ ├── GIdentity.groovy │ │ │ ├── GIntegrate.groovy │ │ │ ├── GNumbers.groovy │ │ │ ├── GObjectToConsoleString.groovy │ │ │ ├── GPCopy.groovy │ │ │ ├── GPairs.groovy │ │ │ ├── GParPrint.groovy │ │ │ ├── GPlus.groovy │ │ │ ├── GPrefix.groovy │ │ │ ├── GPrint.groovy │ │ │ ├── GSquares.groovy │ │ │ ├── GStatePairs.groovy │ │ │ ├── GSuccessor.groovy │ │ │ └── GTail.groovy │ │ └── util │ │ │ ├── FairMultiplex.groovy │ │ │ ├── Multiplexer.groovy │ │ │ ├── PriMultiplex.groovy │ │ │ ├── TestUtilities.groovy │ │ │ └── TimedMultiplex.groovy │ │ ├── dataflow │ │ ├── BindErrorAdapter.java │ │ ├── BindErrorListener.java │ │ ├── DataCallback.java │ │ ├── DataCallbackWithPool.java │ │ ├── Dataflow.java │ │ ├── DataflowBroadcast.java │ │ ├── DataflowChannel.java │ │ ├── DataflowChannelListener.java │ │ ├── DataflowQueue.java │ │ ├── DataflowReadChannel.java │ │ ├── DataflowVariable.java │ │ ├── DataflowWriteChannel.java │ │ ├── Dataflows.java │ │ ├── KanbanFlow.groovy │ │ ├── KanbanLink.groovy │ │ ├── KanbanTray.groovy │ │ ├── LazyDataflowVariable.java │ │ ├── ProcessingNode.groovy │ │ ├── Promise.java │ │ ├── Select.java │ │ ├── SelectResult.java │ │ ├── SelectableChannel.java │ │ ├── SyncDataflowBroadcast.java │ │ ├── SyncDataflowQueue.java │ │ ├── SyncDataflowStreamReadAdapter.java │ │ ├── SyncDataflowVariable.java │ │ ├── expression │ │ │ ├── DataflowComplexExpression.java │ │ │ ├── DataflowExpression.java │ │ │ ├── DataflowGetPropertyExpression.java │ │ │ ├── DataflowInvocationExpression.java │ │ │ └── RemoteDataflowExpression.java │ │ ├── impl │ │ │ ├── BindErrorDistributor.java │ │ │ ├── BindErrorListenerManager.java │ │ │ ├── DataflowChannelEventDistributor.java │ │ │ ├── DataflowChannelEventListenerManager.java │ │ │ ├── DataflowChannelEventOrchestrator.java │ │ │ ├── GuardedSelectRequest.java │ │ │ ├── ResizeableCountDownLatch.java │ │ │ ├── SelectBase.java │ │ │ ├── SelectCallback.java │ │ │ ├── SelectRequest.java │ │ │ └── ThenMessagingRunnable.java │ │ ├── operator │ │ │ ├── BinaryChoiceClosure.java │ │ │ ├── ChainWithClosure.java │ │ │ ├── ChoiceClosure.java │ │ │ ├── ControlMessage.java │ │ │ ├── CopyChannelsClosure.java │ │ │ ├── CountingPoisonPill.java │ │ │ ├── DataflowEventAdapter.java │ │ │ ├── DataflowEventListener.java │ │ │ ├── DataflowOperator.java │ │ │ ├── DataflowOperatorActor.java │ │ │ ├── DataflowPrioritySelector.java │ │ │ ├── DataflowProcessor.java │ │ │ ├── DataflowProcessorActor.java │ │ │ ├── DataflowProcessorAtomicBoundAllClosure.java │ │ │ ├── DataflowSelector.java │ │ │ ├── DataflowSelectorActor.java │ │ │ ├── FilterClosure.java │ │ │ ├── ForkingDataflowOperatorActor.java │ │ │ ├── ForkingDataflowSelectorActor.java │ │ │ ├── ImmediateCountingPoisonPill.java │ │ │ ├── Pipeline.java │ │ │ ├── PoisonPill.java │ │ │ ├── PoisonTrackCounter.java │ │ │ ├── SeparationClosure.java │ │ │ ├── StopGently.java │ │ │ ├── component │ │ │ │ ├── GracefulShutdownListener.java │ │ │ │ ├── GracefulShutdownMonitor.java │ │ │ │ ├── OperatorStateMonitor.java │ │ │ │ └── ProcessorPauseResume.java │ │ │ └── package.html │ │ ├── package.html │ │ ├── remote │ │ │ ├── RemoteDataflowBroadcast.java │ │ │ ├── RemoteDataflowQueue.java │ │ │ ├── RemoteDataflowVariable.java │ │ │ └── RemoteDataflows.java │ │ └── stream │ │ │ ├── DataflowStream.java │ │ │ ├── DataflowStreamReadAdapter.java │ │ │ ├── DataflowStreamWriteAdapter.java │ │ │ ├── FList.java │ │ │ ├── FListIterator.java │ │ │ ├── StreamCore.java │ │ │ └── SyncDataflowStream.java │ │ ├── forkjoin │ │ ├── AbstractForkJoinWorker.java │ │ ├── CallAsyncTask.java │ │ ├── FJWorker.java │ │ ├── ForkJoinUtils.java │ │ └── GParsPoolUtilHelper.groovy │ │ ├── group │ │ ├── DefaultPGroup.java │ │ ├── NonDaemonPGroup.java │ │ ├── PGroup.java │ │ └── PGroupBuilder.java │ │ ├── pa │ │ ├── AbstractPAWrapper.groovy │ │ ├── CallAsyncTask.java │ │ ├── CallClosure.java │ │ ├── ClosureMapper.java │ │ ├── ClosureNegationPredicate.java │ │ ├── ClosurePredicate.java │ │ ├── ClosureReducer.java │ │ ├── CombineHolder.java │ │ ├── GParsPoolUtilHelper.groovy │ │ ├── MappedPAWrapper.groovy │ │ ├── PAWrapper.groovy │ │ └── SumClosure.java │ │ ├── package.html │ │ ├── remote │ │ ├── BroadcastDiscovery.java │ │ ├── LocalHost.java │ │ ├── RemoteConnection.java │ │ ├── RemoteHost.java │ │ ├── RemotingContextWithUrls.java │ │ ├── message │ │ │ ├── CloseConnectionMsg.java │ │ │ ├── HostIdMsg.java │ │ │ ├── RemoteActorReplyMsg.java │ │ │ ├── RemoteActorRequestMsg.java │ │ │ ├── RemoteAgentGetValMsg.java │ │ │ ├── RemoteAgentReplyMsg.java │ │ │ ├── RemoteAgentRequestMsg.java │ │ │ ├── RemoteAgentSendClosureMessage.java │ │ │ ├── RemoteAgentSendMessage.java │ │ │ ├── RemoteDataflowBroadcastReplyMsg.java │ │ │ ├── RemoteDataflowBroadcastRequestMsg.java │ │ │ ├── RemoteDataflowQueueEnqueueValueMsg.java │ │ │ ├── RemoteDataflowQueueReplyMsg.java │ │ │ ├── RemoteDataflowQueueRequestMsg.java │ │ │ ├── RemoteDataflowQueueValueRequestMsg.java │ │ │ ├── RemoteDataflowVariableReplyMsg.java │ │ │ ├── RemoteDataflowVariableRequestMsg.java │ │ │ └── package.html │ │ ├── netty │ │ │ ├── ConnectListener.java │ │ │ ├── NettyChannelInitializer.java │ │ │ ├── NettyClient.java │ │ │ ├── NettyHandler.java │ │ │ ├── NettyRemoteConnection.java │ │ │ ├── NettyServer.java │ │ │ ├── NettyTransportProvider.java │ │ │ ├── RemoteObjectDecoder.java │ │ │ ├── RemoteObjectEncoder.java │ │ │ ├── discovery │ │ │ │ ├── DiscoveryClient.java │ │ │ │ ├── DiscoveryClientHandler.java │ │ │ │ ├── DiscoveryRequest.java │ │ │ │ ├── DiscoveryRequestDecoder.java │ │ │ │ ├── DiscoveryRequestEncoder.java │ │ │ │ ├── DiscoveryRequestWithSender.java │ │ │ │ ├── DiscoveryResponse.java │ │ │ │ ├── DiscoveryResponseDecoder.java │ │ │ │ ├── DiscoveryResponseWithRecipient.java │ │ │ │ ├── DiscoveryResponseWithRecipientEncoder.java │ │ │ │ ├── DiscoveryServer.java │ │ │ │ └── DiscoveryServerHandler.java │ │ │ └── package.html │ │ └── package.html │ │ ├── scheduler │ │ ├── DefaultPool.java │ │ ├── FJPool.java │ │ ├── Pool.java │ │ ├── ResizeablePool.java │ │ ├── Scheduler.java │ │ ├── Timer.java │ │ └── package.html │ │ ├── serial │ │ ├── DefaultRemoteHandle.java │ │ ├── LocalHandle.java │ │ ├── RemoteHandle.java │ │ ├── RemoteSerialized.java │ │ ├── SerialContext.java │ │ ├── SerialHandle.java │ │ ├── SerialHandles.java │ │ ├── SerialMsg.java │ │ ├── WithSerialId.java │ │ └── package.html │ │ ├── stm │ │ ├── GParsAtomicBooleanBlock.java │ │ ├── GParsAtomicDoubleBlock.java │ │ ├── GParsAtomicIntBlock.java │ │ ├── GParsAtomicLongBlock.java │ │ ├── GParsAtomicVoidBlock.java │ │ ├── GParsStm.java │ │ └── GParsTxnExecutor.java │ │ ├── streams │ │ ├── ClosureConsumer.java │ │ └── ClosureReducer.java │ │ └── util │ │ ├── ASTUtils.java │ │ ├── AsyncFunASTTransformation.java │ │ ├── AsyncMessagingCore.java │ │ ├── AsyncUtils.java │ │ ├── DefaultMessageQueue.java │ │ ├── EnhancedRWLock.java │ │ ├── EnhancedSemaphore.java │ │ ├── FQMessageQueue.java │ │ ├── GeneralTimer.java │ │ ├── MessageQueue.java │ │ ├── PAGroovyUtils.groovy │ │ ├── PAUtils.java │ │ ├── ParallelUtils.java │ │ ├── PoolFactory.java │ │ ├── PoolUtils.java │ │ ├── TimerFactory.java │ │ └── package.html └── resources │ └── META-INF │ ├── LICENSE.txt │ ├── LICENSE_JUnit.txt │ ├── NOTICE.txt │ ├── README │ └── ReleaseNotest.txt └── test └── groovy └── groovyx └── gpars ├── AsyncFunAnnotationTest.groovy ├── AsyncInvocationWithTimeoutTest.groovy ├── AsynchronizerDSLTest.groovy ├── AsynchronizerExceptionTest.groovy ├── AsynchronizerIteratorTest.groovy ├── AsynchronizerStringTest.groovy ├── AsynchronizerTest.groovy ├── DataflowMessagingRunnableTest.groovy ├── DemoCar.groovy ├── ForkJoinPoolAsyncTest.groovy ├── ForkJoinPoolDSLTest.groovy ├── ForkJoinPoolStringTest.groovy ├── GParsExecutorsPoolAsyncFunTest.groovy ├── GParsExecutorsPoolEnhancerTest.groovy ├── GParsExecutorsPoolOnMapTest.groovy ├── GParsExecutorsPoolUtilTest.groovy ├── GParsPoolAsyncFunTest.groovy ├── GParsPoolOnMapTest.groovy ├── GParsPoolUtilTest.groovy ├── MakeConcurrentAndSequentialEnhancerTest.groovy ├── MakeConcurrentAndSequentialTest.groovy ├── MakeTransparentCornerCaseEnhancerTest.groovy ├── MakeTransparentCornerCaseTest.groovy ├── MakeTransparentEnhancerTest.groovy ├── MakeTransparentMethodEnhancerTest.groovy ├── MakeTransparentMethodTest.groovy ├── MakeTransparentTest.groovy ├── MapReduceSpockTest.groovy ├── MapReduceTest.groovy ├── MessageStreamTest.groovy ├── MessagingRunnableTest.groovy ├── ParallelArrayTest.groovy ├── ParallelEnhancerTest.groovy ├── ParallelGroupTest.groovy ├── ParallelizerTest.groovy ├── ReactorMessagingRunnableTest.groovy ├── SpeculationTest.groovy ├── activeobject ├── ActiveObjectASTTransformationTest.groovy ├── ActiveObjectExceptionASTTransformationTest.groovy ├── ActiveObjectGroupASTTransformationTest.groovy ├── DFVASTTransformationTest.groovy ├── InheritedPropertiesTest.groovy ├── NonBlockingActiveObjectTest.groovy └── NonBlockingTypesTest.groovy ├── actor ├── AbstractLoopingActorTest.groovy ├── AfterStopTest.groovy ├── DDAReplyTest.groovy ├── DefaultActorCreationTest.groovy ├── MemoryPropagationTest.groovy ├── MessageTypesTest.groovy ├── blocking │ ├── AbstractActorTest.groovy │ ├── ActorThreadTest.groovy │ ├── ActorsTest.groovy │ ├── ArraySumTest.groovy │ ├── DefaultActorTest.groovy │ ├── DeliveryErrorTest.groovy │ ├── ImmutableMessageTest.groovy │ ├── JoinTest.groovy │ ├── MergeSortTest.groovy │ ├── NestedClosureTest.groovy │ ├── NullMessageTest.groovy │ ├── ReplyTest.groovy │ ├── ReplyToMessageTest.groovy │ ├── SendAndWaitTest.groovy │ └── TimeCategoryActorsTest.groovy ├── nonBlocking │ ├── ConditionalLoopTest.groovy │ ├── DDALifeCycleTest.groovy │ ├── DeliveryErrorTest.groovy │ ├── DynamicDispatchActorTest.groovy │ ├── ImmutableMessageTest.groovy │ ├── JoinTest.groovy │ ├── LifeCycleTest.groovy │ ├── LifecycleErrorTest.groovy │ ├── LoopTest.groovy │ ├── MessagingTest.groovy │ ├── NestedClosureTest.groovy │ ├── NullMessageTest.groovy │ ├── PooledActorThreadTest.groovy │ ├── PooledMergeSortTest.groovy │ ├── ReactorLifeCycleTest.groovy │ ├── ReactorTest.groovy │ ├── ReceiveTest.groovy │ ├── RepeatLoopTest.groovy │ ├── ReplyTest.groovy │ ├── ReplyToMessageTest.groovy │ ├── SendAndWaitTest.groovy │ ├── SharedMemoryTest.groovy │ ├── SingleThreadLoopTest.groovy │ ├── SingleThreadedLifeCycleTest.groovy │ ├── SingleThreadedMessagingTest.groovy │ ├── StaticDispatchActorTest.groovy │ ├── TimeCategoryTimeoutTest.groovy │ └── TimeoutTest.groovy └── remote │ └── RemoteActorsUrlUtilsTest.groovy ├── agent ├── AgentListenerParametersTest.groovy ├── AgentListenerTest.groovy ├── AgentTest.groovy └── remote │ └── RemoteAgentsTest.groovy ├── benchmark ├── BenchmarkGParsPool.groovy ├── actorComparison │ ├── BenchmarkActiveObjectsWithArray.groovy │ ├── BenchmarkActorsContention.groovy │ ├── BenchmarkActorsContentionWithDDAs.groovy │ ├── BenchmarkActorsContentionWithFactory.groovy │ ├── BenchmarkAgent.groovy │ ├── BenchmarkReactor.groovy │ ├── BenchmarkReactors.groovy │ ├── BenchmarkSafe.groovy │ ├── BenchmarkSelectors.groovy │ ├── BenchmarkStatefulActors.groovy │ ├── BenchmarkStatefulActorsNoLoop.groovy │ ├── BenchmarkStatefulActorsWithArray.groovy │ ├── BenchmarkStatelessActors.groovy │ ├── BenchmarkStatelessActorsWithArray.groovy │ ├── BenchmarkStatelessActorsWithWhenClause.groovy │ ├── BenchmarkStaticActorsWithArray.groovy │ ├── BenchmarkTwoDynamicDispatchActors.groovy │ └── BenchmarkTwoStaticDispatchActors.groovy ├── akka │ ├── Messages.groovy │ ├── PipelineBenchmark.groovy │ ├── PipelineDynamicDispatchActorScript.groovy │ ├── PipelineStatefulActor.groovy │ ├── PipelineStatefulNoLoop.groovy │ └── PipelineStaticDispatchActorScript.groovy ├── caliper │ ├── BenchmarkRunner.java │ ├── README.md │ ├── akka │ │ ├── BenchmarkCaliper.java │ │ ├── BenchmarkLatencyDynamicDispatchActorCaliper.java │ │ ├── BenchmarkLatencyStaticDispatchActorCaliper.java │ │ ├── BenchmarkThroughputComputationDynamicActorCaliper.java │ │ ├── BenchmarkThroughputComputationStaticActorCaliper.java │ │ ├── BenchmarkThroughputDynamicDispatchActorCaliper.java │ │ └── BenchmarkThroughputStaticDispatchActorCaliper.java │ ├── chart │ │ ├── ChartBuilder.java │ │ ├── GoogleChartBuilder.groovy │ │ ├── HTMLBuilder.groovy │ │ └── JsonFileParser.java │ ├── instrument │ │ ├── LatencyMeasurementInstrument.java │ │ └── ThroughputMeasurementInstrument.java │ └── worker │ │ ├── LatencyMeasurementWorker.java │ │ └── ThroughputMeasurementWorker.java ├── dataflow │ ├── BenchmarkDataflowQueue.groovy │ ├── BenchmarkDataflowStream.groovy │ ├── BenchmarkMultiOperators.groovy │ └── BenchmarkOperators.groovy └── embarrassinglyParallel │ ├── BenchmarkActorOnPICalculation.groovy │ ├── BenchmarkActorsVsThreads.groovy │ ├── BenchmarkCollections.groovy │ └── BenchmarkThreads.groovy ├── dataflow ├── AsyncSelectTest.groovy ├── DFSpockTest.groovy ├── DataflowChannelChainingDSLTest.groovy ├── DataflowChannelChainingTest.groovy ├── DataflowChannelFilterTest.groovy ├── DataflowChannelLengthTest.groovy ├── DataflowChannelMapperTest.groovy ├── DataflowQueueTest.groovy ├── DataflowReadChannelEventTest.groovy ├── DataflowTaskTest.groovy ├── DataflowTest.groovy ├── DataflowVariableBindErrorTest.groovy ├── DataflowVariableTest.groovy ├── DataflowsTest.groovy ├── ErrorHandlerTest.groovy ├── ForkAndJoinPromiseTest.groovy ├── KanbanFlowTest.groovy ├── LazyDataflowVariableTest.groovy ├── LazyTaskTest.groovy ├── SelectTest.groovy ├── SelectToPromiseTest.groovy ├── SyncChannelsWithOperatorsTest.groovy ├── SyncChannelsWithSelectTest.groovy ├── SyncDataflowBroadcastTest.groovy ├── SyncDataflowQueueTest.groovy ├── SyncDataflowVariableDefaultTest.groovy ├── SyncDataflowVariableTest.groovy ├── ThreadLifeCycleTest.groovy ├── WhenBoundChainingTest.groovy ├── expression │ └── DataflowExpressionTest.groovy ├── impl │ └── ResizeableCountDownLatchTest.groovy ├── operator │ ├── DataflowOperatorCountingShutdownTest.groovy │ ├── DataflowOperatorGentlyStopTest.groovy │ ├── DataflowOperatorShutdownTest.groovy │ ├── DataflowOperatorTest.groovy │ ├── DataflowPrioritySelectorTest.groovy │ ├── DataflowProcessorEventExceptionTest.groovy │ ├── DataflowProcessorEventRewritingTest.groovy │ ├── DataflowProcessorEventTest.groovy │ ├── DataflowProcessorJavaAPITest.groovy │ ├── DataflowProcessorStateObjectTest.groovy │ ├── DataflowSelectorTest.groovy │ ├── DataflowTaskTest.groovy │ ├── InternallyParallelDataflowOperatorTest.groovy │ ├── InternallyParallelDataflowSelectorTest.groovy │ ├── PipelineFilterTest.groovy │ ├── PipelineTest.groovy │ ├── PoisonWithForkProcessorTest.groovy │ ├── SplitterTest.groovy │ └── component │ │ ├── GracefulShutdownTest.groovy │ │ ├── ProcessorPauseResumeTest.groovy │ │ └── TestControlMessage.groovy ├── remote │ ├── RemoteDataflowsDataflowBroadcastTest.groovy │ ├── RemoteDataflowsDataflowQueueTest.groovy │ └── RemoteDataflowsDataflowVariableTest.groovy └── stream │ ├── DataflowStreamAdapterTest.groovy │ ├── DataflowStreamBroadCastTest.groovy │ ├── DataflowStreamOperatorTest.groovy │ ├── DataflowStreamTest.groovy │ ├── DataflowStreamWriteAdapterTest.groovy │ ├── StreamAsDataflowChannelTest.groovy │ ├── SyncDataflowStreamDefaultTest.groovy │ └── SyncDataflowStreamTest.groovy ├── forkjoin ├── DirectChildrenCallTest.groovy ├── ForkJoinBuilderTest.groovy └── ForkJoinTest.groovy ├── groups ├── FJGroupTest.groovy ├── PGroupBuilderTest.groovy └── PGroupTest.groovy ├── integration ├── AwaitTaskTerminationTest.groovy └── remote │ ├── DiscoveryServiceTest.groovy │ ├── RemoteSpecification.groovy │ ├── actor │ ├── RemoteActorTest.groovy │ ├── RemoteActorsTest.groovy │ └── RemoteActorsWithNamesTest.groovy │ ├── agent │ └── RemoteAgentsWithServerTest.groovy │ └── dataflow │ ├── RemoteDataflowsDataflowBroadcastWithServerTest.groovy │ ├── RemoteDataflowsDataflowQueueWithServerTest.groovy │ └── RemoteDataflowsDataflowVariableWithServerTest.groovy ├── issues ├── ImmutableAct.groovy ├── ImmutableMessageIssue.groovy ├── MixinIssue1.groovy ├── MixinIssue2.groovy ├── MixinIssue3.groovy └── PropertyIssues.groovy ├── remote ├── LocalHostMock.groovy ├── LocalHostTest.groovy └── netty │ ├── NettyClientServerTest.groovy │ ├── NettyClientTest.groovy │ ├── NettyServerTest.groovy │ └── discovery │ ├── DiscoveryIntegrationTest.groovy │ ├── DiscoveryRequestDecoderTest.groovy │ ├── DiscoveryRequestEncoderTest.groovy │ ├── DiscoveryResponseDecoderTest.groovy │ └── DiscoveryResponseWithRecipientEncoderTest.groovy ├── samples ├── activeobject │ ├── DemoActiveObject.groovy │ ├── DemoAsynchronousActiveObject.groovy │ ├── DemoBlockingActiveObject.groovy │ ├── DemoComposingResults.groovy │ ├── DemoComposingResultsDetailed.groovy │ └── DemoSwingLifeWithActiveObjects.groovy ├── actors │ ├── DemoSwingLifeWithActors.groovy │ ├── blocking │ │ └── DemoBlockingDecryptor.groovy │ ├── dda │ │ ├── DemoDynamicDispatchActor.groovy │ │ └── DemoSieveEratosthenesActors.groovy │ ├── reactor │ │ ├── DemoReactor1.groovy │ │ ├── DemoReactor2.groovy │ │ ├── DemoSleepingBarber.groovy │ │ ├── DemoSleepingBarber_RW.groovy │ │ └── DemoSleepingLazyBarber.groovy │ ├── sda │ │ ├── DemoStaticDispatchActor.groovy │ │ └── DemoStaticDispatchActorUsingFactory.groovy │ ├── stateful │ │ ├── DemoConditionalLoop.groovy │ │ ├── DemoCountingLoop.groovy │ │ ├── DemoCurriedActorChain.groovy │ │ ├── DemoDecryptor.groovy │ │ ├── DemoDiningPhilosophers.groovy │ │ ├── DemoEventMergeSort.groovy │ │ ├── DemoForwarding.groovy │ │ ├── DemoGuessGame.groovy │ │ ├── DemoLoadBalancer.groovy │ │ ├── DemoMultiMessage.groovy │ │ ├── DemoNestedLoops.groovy │ │ ├── DemoNestedLoopsWithClosures.groovy │ │ ├── DemoNestedLoopsWithMetaClass.groovy │ │ ├── DemoNestedMethodCalls.groovy │ │ ├── DemoOnDeliveryError.groovy │ │ ├── DemoPipelinedActors.groovy │ │ ├── DemoPooledGroups.groovy │ │ ├── DemoPooledLifeCycleMethods.groovy │ │ ├── DemoReply.groovy │ │ ├── DemoReplyCompileStatic.groovy │ │ ├── DemoRockPaperScissors.groovy │ │ ├── DemoStockPrices.groovy │ │ ├── DemoStockPricesWithCoordinatingActor.groovy │ │ ├── DemoStockPricesWithResultActor.groovy │ │ └── DemoWordSort.groovy │ └── visual │ │ ├── DemoSwing.groovy │ │ └── DemoSwingActors.groovy ├── agent │ ├── DemoAdvancedThreadSafeCounter.groovy │ ├── DemoAgent.groovy │ ├── DemoAgentWithCustomPool.groovy │ ├── DemoCart.groovy │ ├── DemoListenersAndValidators.groovy │ ├── DemoNameSafe.groovy │ ├── DemoNestedSafeVariable.groovy │ ├── DemoPrintingService.groovy │ ├── DemoSafeAccountTransfer.groovy │ ├── DemoSafeList.groovy │ ├── DemoThreadSafeCounter.groovy │ └── DemoValidatorGotchas.groovy ├── collections │ ├── DemoAsynchronousProcessingr.groovy │ ├── DemoCombine.groovy │ ├── DemoCombineWithClone.groovy │ ├── DemoCombineWithCreatorClosure.groovy │ ├── DemoGParsExecutorsPool.groovy │ ├── DemoGParsExecutorsPoolAsyncClosures.groovy │ ├── DemoGParsExecutorsPoolEnhancer.groovy │ ├── DemoGParsExecutorsPoolParallelFunctionInvocation.groovy │ ├── DemoImmutableAccountTransfer.groovy │ ├── DemoImmutableAccountTransfer2.groovy │ ├── DemoMapReduce.groovy │ ├── DemoParallelArray.groovy │ ├── DemoParallelCollections.groovy │ ├── DemoParallelCollectionsWithAsConcurrent.groovy │ ├── DemoParallelCollectionsWithConcurrentAndSequentialSemantics.groovy │ ├── DemoParallelEnhancer.groovy │ ├── DemoParallelEnhancerWithAsConcurrent.groovy │ ├── DemoParallelEnhancerWithConcurrentAndSequentialSemantics.groovy │ ├── DemoParallelEnhancerWithConcurrentSemantics.groovy │ ├── DemoParallelMaps.groovy │ ├── DemoParallelTransparentCollections.groovy │ ├── DemoParallelWordCount.groovy │ ├── DemoQuicksort.groovy │ ├── DemoQuicksortMapReduce.groovy │ ├── DemoSleepingBarberWithQueue.groovy │ ├── DemoSpeculations.groovy │ ├── DemoSpeculativeDownloads.groovy │ ├── DemoSwingCollectionProcessing.groovy │ ├── DemoSwingMashup.groovy │ └── DemoSynchronizedAccountTransfer.groovy ├── csp │ ├── DemoNumbers.groovy │ ├── DemoSieveEratosthenesCSP.groovy │ ├── DemoThreading.groovy │ ├── FibonacciV1.groovy │ ├── FibonacciV2.groovy │ ├── proposed │ │ ├── ResetNumbers.groovy │ │ ├── ResetPrefix.groovy │ │ ├── ResetUser.groovy │ │ └── RunReset.groovy │ └── resetexamples │ │ ├── ResetNumbers.groovy │ │ ├── ResetPrefix.groovy │ │ ├── ResetUser.groovy │ │ └── RunReset.groovy ├── dataflow │ ├── BenchmarkManyDataflowVariables.groovy │ ├── DataflowDemo1.groovy │ ├── DataflowDemo2.groovy │ ├── DataflowDemo3.groovy │ ├── DataflowDemo4.groovy │ ├── DataflowDemo5.groovy │ ├── DataflowDemo6.groovy │ ├── DemoAsyncFunctionsFibonacci.groovy │ ├── DemoAsyncFunctionsSum.groovy │ ├── DemoAsynchronousFunctionsFibonacci.groovy │ ├── DemoAsynchronousFunctionsSum.groovy │ ├── DemoAvoidPotentialDeadlock1.groovy │ ├── DemoAvoidingPotentialDeadlock2.groovy │ ├── DemoBuildProcess.groovy │ ├── DemoBuildProcessWithFunctions.groovy │ ├── DemoBuildProcessWithOperators.groovy │ ├── DemoCallCenterWithAsyncTasks.groovy │ ├── DemoCallCenterWithTasks.groovy │ ├── DemoCombiningAsyncFunctions.groovy │ ├── DemoCombiningAsyncFunctionsInFreeStyle.groovy │ ├── DemoCombiningAsyncFunctionsWithDelayedPool.groovy │ ├── DemoCombiningAsyncFunctionsWithExplicitPool.groovy │ ├── DemoContinuations.groovy │ ├── DemoDFStreamSpeculations.groovy │ ├── DemoDFVSpeculations.groovy │ ├── DemoDataflowBroadcastMultipleReaders.groovy │ ├── DemoDataflowBroadcastStream.groovy │ ├── DemoDataflowOperator.groovy │ ├── DemoDataflowQueueIteration.groovy │ ├── DemoDataflowQueueMultipleReaders.groovy │ ├── DemoDataflows.groovy │ ├── DemoDataflowsPolished.groovy │ ├── DemoDeadLock.groovy │ ├── DemoDownloadingAsyncFunctions.groovy │ ├── DemoDownloadingAsyncFunctionsWithAnnotation.groovy │ ├── DemoDownloadingAsyncFunctionsWithMethods.groovy │ ├── DemoJoinActivitiesThroughPromises.groovy │ ├── DemoJoinPromises.groovy │ ├── DemoJoinPromisesWithErrorHandling.groovy │ ├── DemoJoiningTasks.groovy │ ├── DemoLazyDataflowVariable.groovy │ ├── DemoLazyDataflowVariableDependencies.groovy │ ├── DemoLazyTask.groovy │ ├── DemoLazyTaskDependencies.groovy │ ├── DemoLifeWithDataflowOperators.groovy │ ├── DemoManyDataflows.groovy │ ├── DemoMashupWithMethods.groovy │ ├── DemoNonDeterministicDeadlockWithDataflows.groovy │ ├── DemoNormalThreadDataflow.groovy │ ├── DemoPerfectNumbers.groovy │ ├── DemoPhysicalCalculations.groovy │ ├── DemoPriceEstimate.groovy │ ├── DemoProducerConsumer1.groovy │ ├── DemoProducerConsumer2.groovy │ ├── DemoPromiseComposition.groovy │ ├── DemoSieveEratosthenes.groovy │ ├── DemoSieveEratosthenesTheGoWay.groovy │ ├── DemoSieveEratosthenesTheGoWayWithOperators.groovy │ ├── DemoSieveEratosthenesWithContinuations.groovy │ ├── DemoSieveEratosthenesWithOperator.groovy │ ├── DemoSieveEratosthenesWithPipelines.groovy │ ├── DemoSimpleMashup.groovy │ ├── DemoStockPricesDataflows.groovy │ ├── DemoStockPricesWithDataflowOperator.groovy │ ├── DemoStockPricesWithTask.groovy │ ├── DemoSwingDataflowOperators.groovy │ ├── DemoSwingDataflowProgress.groovy │ ├── DemoSwingFancyDataflow.groovy │ ├── DemoSwingLifeWithDataflowOperators.groovy │ ├── DemoTaskReturnValue.groovy │ ├── DemoWaitForTaskTerminationWithAgent.groovy │ ├── expression │ │ ├── DemoExpressions.groovy │ │ ├── DemoMethodDispatch.groovy │ │ ├── DemoMethodDispatchWithArguments.groovy │ │ └── DemoProperties.groovy │ ├── kanban │ │ ├── DemoKanbanFlow.groovy │ │ ├── DemoKanbanFlowBroadcast.groovy │ │ ├── DemoKanbanFlowCycle.groovy │ │ ├── DemoKanbanFlowGameOfLife.groovy │ │ └── DemoKanbanLazyPrimeSequenceLoops.groovy │ ├── operators │ │ ├── DemoCallCenter.groovy │ │ ├── DemoDataflowOperatorWithState.groovy │ │ ├── DemoFibonacciWithSingleOperator.groovy │ │ ├── DemoFibonacciWithSingleOperatorCompileStatic.groovy │ │ ├── DemoOperatorCustomEvent.groovy │ │ ├── DemoOperatorExceptionHandling.groovy │ │ ├── DemoOperatorLifecycle.groovy │ │ ├── DemoOperatorPoisson.groovy │ │ ├── DemoOperatorResourceManagement.groovy │ │ ├── DemoOperatorShutdown.groovy │ │ ├── DemoOperatorStockPriceProcessing.groovy │ │ ├── DemoPrioritySelectWithOperators.groovy │ │ ├── DemoProcessingNodeUse.groovy │ │ ├── DemoWaitingForOperatorPoisson.groovy │ │ ├── DemoWaitingForOperatorPoissonTheGuruVersion.groovy │ │ ├── DemoWebPageProcessing.groovy │ │ ├── DemoWebPageProcessingWithCaching.groovy │ │ ├── chaining │ │ │ ├── DemoCombination.groovy │ │ │ ├── DemoConnectingChannelsWithInto.groovy │ │ │ ├── DemoConnectingChannelsWithSplit.groovy │ │ │ ├── DemoEncryptorPipeline.groovy │ │ │ ├── DemoEncryptorPipelineUsedInComplexNetwork.groovy │ │ │ ├── DemoOperatorChaining.groovy │ │ │ ├── DemoOperatorChainingOnBroadcastSubscription.groovy │ │ │ ├── DemoOperatorChainingOnDFV.groovy │ │ │ ├── DemoOperatorChainingOnSyncBroadcastSubscription.groovy │ │ │ ├── DemoOperatorChainingOnSyncDFV.groovy │ │ │ ├── DemoOperatorChainingOnSynchronousChannels.groovy │ │ │ ├── DemoOperatorChainingUsingOr.groovy │ │ │ ├── DemoOperatorChainingWithCustomPGroup.groovy │ │ │ ├── DemoOperatorSharedChaining.groovy │ │ │ ├── DemoPipelineBuilder.groovy │ │ │ ├── DemoPipelineBuilderAdvanced.groovy │ │ │ └── DemoPipelineBuilderWithChoices.groovy.groovy │ │ └── shutdown │ │ │ └── DemoGratefulShutdown.groovy │ ├── process │ │ ├── Copy.groovy │ │ ├── DemoCSPProcesses.groovy │ │ ├── DemoFibonacci1.groovy │ │ ├── DemoFibonacci1WithSynchronousChannels.groovy │ │ ├── DemoFibonacci2.groovy │ │ ├── DemoFibonacci2WithSynchronousChannels.groovy │ │ ├── DemoNumbers.groovy │ │ ├── DemoNumbersWithSynchronousChannels.groovy │ │ ├── Pairs.groovy │ │ ├── Plus.groovy │ │ ├── Prefix.groovy │ │ ├── Print.groovy │ │ ├── StatePairs.groovy │ │ ├── Successor.groovy │ │ └── Tail.groovy │ ├── select │ │ ├── DemoGuardedSelect.groovy │ │ ├── DemoGuardedSelector.groovy │ │ ├── DemoPrioritySelect.groovy │ │ ├── DemoSelect.groovy │ │ ├── DemoSelectRandomness.groovy │ │ ├── DemoTheWinnerTakesItAll.groovy │ │ └── DemoTheWinnerTakesItAllTheLosersStandingSmall.groovy │ ├── stream │ │ ├── DemoDataflowStreamAdaptersWithOperators.groovy │ │ ├── DemoDataflowStreamAdaptersWithSelect.groovy │ │ └── DemoSieveEratosthenesWithStreams.groovy │ ├── synchronous │ │ ├── DemoSelect.groovy │ │ ├── DemoSlowConsumer.groovy │ │ ├── DemoSlowConsumerWithOperators.groovy │ │ ├── DemoSlowConsumers.groovy │ │ ├── DemoSlowConsumersWithOperators.groovy │ │ └── DemoSyncDataflowVariable.groovy │ └── thenChaining │ │ ├── DemoAsyncDownload.groovy │ │ ├── DemoChainingActiveObjects.groovy │ │ ├── DemoChainingActiveObjectsAsFunctions.groovy │ │ ├── DemoChainingActiveObjectsWithRightShift.groovy │ │ ├── DemoChainingAndForkingFunctions.groovy.groovy │ │ ├── DemoChainingClosures.groovy │ │ ├── DemoChainingFunctions.groovy │ │ ├── DemoChainingFunctionsBenefits.groovy.groovy │ │ ├── DemoChainingFunctionsWithRightShift.groovy │ │ ├── DemoDefaultGroup.groovy │ │ ├── DemoDownloadUsingFunctionChaining.groovy │ │ ├── DemoDownloadUsingPromiseChaining.groovy │ │ ├── DemoDownloadUsingPromiseChainingWithErrorHandling.groovy │ │ ├── DemoPromiseChainingErrorHandling.groovy │ │ └── DemoWhenAllBound.groovy ├── forkjoin │ ├── DemoFJDirect.groovy │ ├── DemoFib.groovy │ ├── DemoFibWithCustomWorker.groovy │ ├── DemoForkJoinFib.groovy │ ├── DemoForkJoinFileCounter.groovy │ ├── DemoForkJoinFileCounterPolished.groovy │ ├── DemoForkJoinMergeSort.groovy │ ├── DemoQuicksortForkJoin.groovy │ ├── DemoRawForkJoinFileCounter.groovy │ ├── DemoSwingMergeSort.groovy │ └── DemoVisualForkJoinMergeSort.groovy ├── group │ └── DemoPoolToGroup.groovy ├── remote │ ├── actor │ │ ├── calculator │ │ │ ├── RemoteCalculatorAnswer.groovy │ │ │ └── RemoteCalculatorQuery.groovy │ │ ├── chat │ │ │ ├── ChatClient.groovy │ │ │ ├── ChatClientActor.groovy │ │ │ ├── ChatMessage.groovy │ │ │ ├── ChatServer.groovy │ │ │ └── ChatServerActor.groovy │ │ └── pingpong │ │ │ ├── RemotePing.groovy │ │ │ └── RemotePong.groovy │ ├── agent │ │ ├── ExampleClient.groovy │ │ └── ExampleServer.groovy │ └── dataflow │ │ ├── broadcast │ │ ├── ExampleBroadcastClient.groovy │ │ └── ExampleBroadcastServer.groovy │ │ ├── queue │ │ ├── ExampleQueueClient.groovy │ │ └── ExampleQueueServer.groovy │ │ ├── queuebalancer │ │ ├── Consumer.groovy │ │ └── Producer.groovy │ │ └── variable │ │ ├── ExampleVariableClient.groovy │ │ └── ExampleVariableServer.groovy ├── stm │ ├── DemoCustomBlocks.groovy │ ├── DemoDirectStm.groovy │ ├── DemoRetry.groovy │ └── DemoStm.groovy └── userguide │ ├── actor │ ├── DemoActor_0_1.groovy │ ├── DemoActor_0_2.groovy │ ├── DemoActor_0_3.groovy │ ├── DemoActor_0_4.groovy │ ├── DemoActor_0_5.groovy │ ├── DemoActor_0_6.groovy │ ├── DemoActor_0_7.groovy │ ├── DemoActor_0_8.groovy │ ├── DemoActor_0_9.groovy │ ├── DemoActor_1_1.groovy │ ├── DemoActor_1_2.groovy │ ├── DemoActor_1_3.groovy │ ├── DemoActor_1_4.groovy │ ├── DemoActor_1_5.groovy │ ├── DemoActor_2_1.groovy │ ├── DemoActor_2_2.groovy │ ├── DemoActor_2_3.groovy │ ├── DemoActor_2_4.groovy │ ├── DemoActor_2_5.groovy │ ├── DemoActor_3_1.groovy │ ├── DemoActor_3_2.groovy │ ├── DemoActor_3_3.groovy │ ├── DemoActor_3_4.groovy │ ├── DemoActor_3_5.groovy │ ├── DemoActor_3_6.groovy │ ├── DemoActor_3_7.groovy │ ├── DemoActor_4_1.groovy │ ├── DemoActor_4_2.groovy │ ├── DemoActor_4_3.groovy │ ├── DemoActor_4_4.groovy │ └── DemoActor_4_5.groovy │ └── geting_started │ └── DemoStart_2_1.groovy ├── stm └── TxnExecutorTest.groovy └── util ├── AbstractMessageQueueTest.groovy ├── DefaultMessageQueueTest.groovy ├── EnhancedRWLockTest.groovy ├── EnhancedSemaphoreTest.groovy ├── FQMessageQueueTest.groovy └── GParsConfigTest.groovy /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /build/ 3 | /out/ 4 | /.gradle/ 5 | /gradle-app.setting 6 | /cobertura.ser 7 | /buildSrc/.gradle/ 8 | /buildSrc/build/ 9 | /buildSrc/buildSrc.iml 10 | /*.iws 11 | /GPars.ipr 12 | /GPars.iml 13 | /.classpath 14 | /.project/ 15 | /.settings/ 16 | *~ 17 | /caliper-charts/ 18 | /caliper-results/ 19 | /.idea/ 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: groovy 2 | 3 | jdk: 4 | - openjdk8 5 | - oraclejdk8 6 | - openjdk9 7 | - oraclejdk9 8 | - oraclejdk10 9 | - openjdk10 10 | - oraclejdk11 11 | - openjdk11 12 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GPars (Groovy Parallel Systems) is licences under the Apache Software Licence v2.0. See 2 | http://www.apache.org/licenses/LICENSE-2.0 for the text of the licence. 3 | -------------------------------------------------------------------------------- /README.idea: -------------------------------------------------------------------------------- 1 | Run "./gradlew idea" to have a fresh IntelliJ IDEA project file generated. Do not use the default GPars_IDEAX project file, 2 | since you are likely to run into problems with unresolved dependencies on third-party libraries, 3 | as the default project file is primarily targeted to be used for code analysis on the Continuous Integration server (TeamCity). 4 | 5 | Find complete developer guidelines at http://gpars.codehaus.org/Developer+Zone 6 | -------------------------------------------------------------------------------- /artwork/GPars_logo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/artwork/GPars_logo.zip -------------------------------------------------------------------------------- /artwork/gpars-logo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/artwork/gpars-logo.PNG -------------------------------------------------------------------------------- /artwork/gpars_14x14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/artwork/gpars_14x14.png -------------------------------------------------------------------------------- /artwork/gpars_192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/artwork/gpars_192x192.png -------------------------------------------------------------------------------- /artwork/gpars_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/artwork/gpars_64x64.png -------------------------------------------------------------------------------- /artwork/license.txt: -------------------------------------------------------------------------------- 1 | As per the rules of the logo contest held at the end of 2009, this artwork will be licenced according to the 2 | Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 licence: 3 | 4 | http://creativecommons.org/licenses/by-nc-nd/3.0/ 5 | -------------------------------------------------------------------------------- /bambooBuild: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This script is here only for the Codehaus Bamboo build. 4 | 5 | buildTask="build zipSamples zipJavaDemo zipDist zipGuide" 6 | 7 | if [ $# -gt 0 ] 8 | then 9 | buildTask=$1 10 | fi 11 | 12 | export LC_ALL=en_GB.UTF-8 13 | 14 | ./gradlew -i clean $buildTask 15 | -------------------------------------------------------------------------------- /bambooBuildRelease: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This script is here only for the Codehaus Bamboo RELEASE build. 4 | 5 | buildTask="release" 6 | 7 | if [ $# -gt 0 ] 8 | then 9 | buildTask=$1 10 | fi 11 | 12 | export LC_ALL=en_GB.UTF-8 13 | 14 | ./gradlew -i clean $buildTask 15 | -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Author: Václav Pech 18 | // Author: Russel Winder 19 | // Author: Dierk König 20 | // Author: Hans Dockter 21 | // Author: Rene Groeschke 22 | 23 | apply plugin: 'groovy' 24 | 25 | repositories { 26 | mavenCentral() 27 | } 28 | 29 | dependencies { 30 | compile localGroovy() 31 | compile gradleApi() 32 | } 33 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version = 2.0-SNAPSHOT 2 | 3 | gpars_useMavenLocal = false 4 | 5 | gpars_groovyVersion = 2.5.0 6 | gpars_nettyVersion = 4.1.25.Final 7 | gpars_spockVersion = 1.1-groovy-2.4 8 | gpars_multiverseVersion = 0.7.0 9 | gpars_jcspVersion = 1.1.0 10 | gpars_gsonVersion = 2.8.5 11 | gpars_guavaVersion = 25.1-jre 12 | gpars_wagonhttplightweightVersion = 3.0.0 13 | gpars_coberturaVersion = 2.1.1 14 | gpars_jansiVersion = 1.17.1 15 | 16 | gpars_ascidoctorjPDFVersion = 1.5.0-alpha.16 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /java-demo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /java-demo/.project: -------------------------------------------------------------------------------- 1 | 2 | java-demo 3 | NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. 4 | 5 | 6 | 7 | org.eclipse.jdt.core.javabuilder 8 | 9 | 10 | 11 | org.eclipse.jdt.core.javanature 12 | 13 | -------------------------------------------------------------------------------- /java-demo/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Fri Nov 12 23:10:08 CET 2010 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | eclipse.preferences.version=1 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | -------------------------------------------------------------------------------- /java-demo/java-demo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /java-demo/src/test/java/org/codehaus/gpars/javademo/benchmark/DownloadStatefulDynamicDispatchActor.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package org.codehaus.gpars.javademo.benchmark; 18 | 19 | final class DownloadStatefulDynamicDispatchActor extends StatefulDynamicDispatchActor { 20 | @Override 21 | String handleMessage(final String message) { 22 | return message.replaceFirst("Requested ", "Downloaded "); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /java-demo/src/test/java/org/codehaus/gpars/javademo/benchmark/IndexStatefulDynamicDispatchActor.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package org.codehaus.gpars.javademo.benchmark; 18 | 19 | final class IndexStatefulDynamicDispatchActor extends StatefulDynamicDispatchActor { 20 | @Override 21 | String handleMessage(final String message) { 22 | return message.replaceFirst("Downloaded ", "Indexed "); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /java-demo/src/test/java/org/codehaus/gpars/javademo/benchmark/WriteStatefulDynamicDispatchActor.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package org.codehaus.gpars.javademo.benchmark; 18 | 19 | final class WriteStatefulDynamicDispatchActor extends StatefulDynamicDispatchActor { 20 | @Override 21 | String handleMessage(final String message) { 22 | return message.replaceFirst("Indexed ", "Wrote "); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/caliper-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GPars/GPars/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/lib/caliper-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /licenses/LICENSE-multiverse.txt: -------------------------------------------------------------------------------- 1 | This software is licensed under the Apache 2 license, quoted below. 2 | 3 | Copyright 2009-2011 Peter Veentjer. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in 6 | compliance with the License. You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the License is 11 | distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | express or implied. See the License for the specific language governing permissions and limitations 13 | under the License. -------------------------------------------------------------------------------- /licenses/LICENSE.slf4j.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2007 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'GPars' 2 | -------------------------------------------------------------------------------- /src/main/assembly/all.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | all 6 | 7 | tar.gz 8 | zip 9 | 10 | 11 | 12 | 13 | . 14 | target 15 | true 16 | 17 | target/ 18 | 19 | 20 | 21 | target 22 | 23 | *.jar 24 | site/** 25 | 26 | 27 | 28 | 29 | 30 | 31 | false 32 | runtime 33 | false 34 | false 35 | target/dependencies 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/activeobject/ActiveMethod.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | GPars - Groovy Parallel Systems 4 | 5 | Copyright © 2008-2013 The original author or authors 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | package groovyx.gpars.activeobject; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.SOURCE) 28 | @Target({ElementType.METHOD}) 29 | public @interface ActiveMethod { 30 | boolean blocking() default true; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/activeobject/ActorWithExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.activeobject; 2 | 3 | /** 4 | * @author Kirill Vergun (code@o-nix.me) 5 | * @since 1.3 6 | */ 7 | public interface ActorWithExceptionHandler { 8 | Object recoverFromException(String methodName, Exception e); 9 | } -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/DDAHelper.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor 18 | 19 | /** 20 | * Hooks the supplied when handlers to DDAs 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | final class DDAHelper { 25 | static final void when(final target, final closure) { 26 | target.metaClass.onMessage closure 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/DefaultActorClosure.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor; 18 | 19 | import groovy.lang.Closure; 20 | 21 | /** 22 | * Represents the DDA closure to invoke appropriate message handlers based on message runtime type 23 | * 24 | * @author Vaclav Pech 25 | */ 26 | public final class DefaultActorClosure extends Closure { 27 | 28 | private final DefaultActor myActor; 29 | private static final long serialVersionUID = 3009666814957486672L; 30 | 31 | DefaultActorClosure(final DefaultActor actor) { 32 | super(actor); 33 | this.myActor = actor; 34 | } 35 | 36 | @Override 37 | public Object call(final Object arguments) { 38 | myActor.onMessage(arguments); 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/impl/ActorStopException.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.impl; 18 | 19 | /** 20 | * An exception indicating Actor stopping request. 21 | * Implementing singleton pattern, ActorException holds the unique reference. 22 | * 23 | * @author Alex Tkachman 24 | * Date: Feb 17, 2009 25 | */ 26 | public final class ActorStopException extends ActorException { 27 | private static final long serialVersionUID = 6718779462386378739L; 28 | 29 | ActorStopException() { 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/impl/ActorTerminationException.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.impl; 18 | 19 | /** 20 | * An exception indicating Actor termination request. 21 | * Implementing singleton pattern, ActorException holds the unique reference. 22 | * 23 | * @author Vaclav Pech 24 | * Date: Feb 17, 2009 25 | */ 26 | public final class ActorTerminationException extends ActorException { 27 | private static final long serialVersionUID = -1525695043073635315L; 28 | 29 | ActorTerminationException() { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/impl/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.actor.impl.* 22 | 23 | 24 |

25 | This package holds classes some non-public aspects of actor implementation. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/actor/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.actor.* 22 | 23 | 24 |

25 | This package holds classes forming the public actor API. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/agent/AgentThreadFactory.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.agent; 18 | 19 | import java.util.concurrent.ThreadFactory; 20 | 21 | /** 22 | * Creates daemon threads for the default agent thread pools 23 | * 24 | * @author Vaclav Pech 25 | * Date: 13.4.2010 26 | */ 27 | final class AgentThreadFactory implements ThreadFactory { 28 | @Override 29 | public Thread newThread(final Runnable r) { 30 | final Thread thread = new Thread(r); 31 | thread.setDaemon(true); 32 | return thread; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/agent/remote/RemoteAgentMock.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.agent.remote; 18 | 19 | /** 20 | * Fake Agent to intercept closure calls. 21 | * 22 | * @author Rafal Slawik 23 | */ 24 | public class RemoteAgentMock { 25 | private Object state = null; 26 | 27 | public void updateValue(Object newValue) { 28 | state = newValue; 29 | } 30 | 31 | public Object getState() { 32 | return state; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/GroovyMobileProcess.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp 18 | 19 | //import org.jcsp.net.mobile.* 20 | 21 | abstract class GroovyMobileProcess {//todo extends MobileProcess implements Serializable{ 22 | 23 | abstract connect(x) 24 | 25 | abstract disconnect() 26 | 27 | } -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/MobileAgent.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp 18 | 19 | import jcsp.lang.CSProcess 20 | 21 | interface MobileAgent extends CSProcess, Serializable { 22 | 23 | abstract connect(List x) 24 | 25 | abstract disconnect() 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GConsoleStringToInteger.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GConsoleStringToInteger implements CSProcess { 24 | 25 | ChannelInput inChannel 26 | ChannelOutput outChannel 27 | 28 | def void run() { 29 | while (true) { 30 | def String s = inChannel.read().trim() 31 | def i = Integer.valueOf(s) 32 | outChannel.write(i) 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GFixedDelay.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.CSTimer 21 | import jcsp.lang.ChannelInput 22 | import jcsp.lang.ChannelOutput 23 | 24 | class GFixedDelay implements CSProcess { 25 | 26 | ChannelInput inChannel 27 | ChannelOutput outChannel 28 | long delay = 0 29 | 30 | void run() { 31 | def timer = new CSTimer() 32 | while (true) { 33 | def v = inChannel.read() 34 | timer.sleep(delay) 35 | outChannel.write(v) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GIdentity.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GIdentity implements CSProcess { 24 | 25 | ChannelOutput outChannel 26 | ChannelInput inChannel 27 | 28 | void run() { 29 | while (true) { 30 | outChannel.write(inChannel.read()) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GObjectToConsoleString.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GObjectToConsoleString implements CSProcess { 24 | 25 | ChannelInput inChannel 26 | ChannelOutput outChannel 27 | 28 | def void run() { 29 | while (true) { 30 | def o = inChannel.read() 31 | outChannel.write(o.toString() + "\n") 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GPrefix.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GPrefix implements CSProcess { 24 | 25 | int prefixValue = 0 26 | ChannelInput inChannel 27 | ChannelOutput outChannel 28 | 29 | void run() { 30 | outChannel.write(prefixValue) 31 | while (true) { 32 | outChannel.write(inChannel.read()) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GPrint.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.CSTimer 21 | import jcsp.lang.ChannelInput 22 | 23 | class GPrint implements CSProcess { 24 | 25 | ChannelInput inChannel 26 | String heading = "No Heading Provided" 27 | long delay = 200 28 | 29 | def void run() { 30 | def timer = new CSTimer() 31 | println "${heading}" 32 | while (true) { 33 | println inChannel.read().toString() 34 | if (delay != 0) { 35 | timer.sleep(delay) 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GStatePairs.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GStatePairs implements CSProcess { 24 | 25 | ChannelOutput outChannel 26 | ChannelInput inChannel 27 | 28 | void run() { 29 | 30 | def n1 = inChannel.read() 31 | def n2 = inChannel.read() 32 | while (true) { 33 | outChannel.write(n1 + n2) 34 | n1 = n2 35 | n2 = inChannel.read() 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GSuccessor.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GSuccessor implements CSProcess { 24 | 25 | ChannelInput inChannel 26 | ChannelOutput outChannel 27 | 28 | void run() { 29 | while (true) { 30 | outChannel.write(inChannel.read() + 1) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/plugAndPlay/GTail.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.plugAndPlay 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class GTail implements CSProcess { 24 | 25 | ChannelOutput outChannel 26 | ChannelInput inChannel 27 | 28 | void run() { 29 | inChannel.read() 30 | while (true) { 31 | outChannel.write(inChannel.read()) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/util/FairMultiplex.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.util 18 | 19 | import groovyx.gpars.csp.ALT 20 | import groovyx.gpars.csp.ChannelInputList 21 | 22 | import jcsp.lang.CSProcess 23 | import jcsp.lang.ChannelOutput 24 | 25 | class FairMultiplex implements CSProcess { 26 | 27 | ChannelInputList inChannels 28 | ChannelOutput outChannel 29 | 30 | def void run() { 31 | def alt = new ALT(inChannels) 32 | while (true) { 33 | def index = alt.fairSelect() 34 | outChannel.write(inChannels[index].read()) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/util/Multiplexer.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.util 18 | 19 | import groovyx.gpars.csp.ALT 20 | import groovyx.gpars.csp.ChannelInputList 21 | 22 | import jcsp.lang.CSProcess 23 | import jcsp.lang.ChannelOutput 24 | 25 | class Multiplexer implements CSProcess { 26 | 27 | ChannelInputList inChannels 28 | ChannelOutput outChannel 29 | 30 | void run() { 31 | def alt = new ALT(inChannels) 32 | while (true) { 33 | def index = alt.select() 34 | outChannel.write(inChannels[index].read()) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/csp/util/PriMultiplex.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.csp.util 18 | 19 | import groovyx.gpars.csp.ALT 20 | import groovyx.gpars.csp.ChannelInputList 21 | 22 | import jcsp.lang.CSProcess 23 | import jcsp.lang.ChannelOutput 24 | 25 | class PriMultiplex implements CSProcess { 26 | 27 | ChannelInputList inChannels 28 | ChannelOutput outChannel 29 | 30 | def void run() { 31 | def alt = new ALT(inChannels) 32 | while (true) { 33 | def index = alt.priSelect() 34 | outChannel.write(inChannels[index].read()) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/DataflowChannel.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow; 18 | 19 | /** 20 | * A common interface for all dataflow variables, streams or queues 21 | * 22 | * @author Vaclav Pech 23 | * Date: 21st Sep 2010 24 | */ 25 | public interface DataflowChannel extends DataflowReadChannel, DataflowWriteChannel { 26 | } 27 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/DataflowChannelListener.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow; 18 | 19 | /** 20 | * Gets notified about state changes inside DataflowReadChannels 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | public interface DataflowChannelListener { 25 | /** 26 | * Notifies about messages passed through the channel 27 | * 28 | * @param message The value just added to the channel 29 | */ 30 | void onMessage(T message); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/SelectableChannel.java: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.dataflow; 2 | 3 | import groovy.lang.Closure; 4 | import groovyx.gpars.actor.impl.MessageStream; 5 | import groovyx.gpars.dataflow.expression.DataflowExpression; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: Vaclav 10 | * Date: 5.7.13 11 | * Time: 22:17 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public interface SelectableChannel { 15 | /** 16 | * Send all pieces of data bound in the future to the provided stream when it becomes available. * 17 | * 18 | * @param closure closure to execute when data becomes available. The closure should take at most one argument. 19 | */ 20 | void wheneverBound(Closure closure); 21 | 22 | /** 23 | * Send all pieces of data bound in the future to the provided stream when it becomes available. 24 | * 25 | * @param stream stream where to send result 26 | */ 27 | void wheneverBound(MessageStream stream); 28 | 29 | /** 30 | * Retrieves the value at the head of the buffer. Returns null, if no value is available. 31 | * 32 | * @return The value bound to the DFV at the head of the stream or null 33 | * @throws InterruptedException If the current thread is interrupted 34 | */ 35 | @SuppressWarnings({"ClassReferencesSubclass"}) DataflowExpression poll() throws InterruptedException; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/impl/BindErrorDistributor.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.impl; 18 | 19 | /** 20 | * Fires requested events 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | public interface BindErrorDistributor { 25 | void fireBindError(T oldValue, T failedValue, boolean uniqueBind); 26 | 27 | void fireBindError(T oldValue, Throwable failedError); 28 | 29 | void fireBindError(Throwable oldError, T failedValue, boolean uniqueBind); 30 | 31 | void fireBindError(Throwable oldError, Throwable failedError); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/impl/BindErrorListenerManager.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.impl; 18 | 19 | import groovyx.gpars.dataflow.BindErrorListener; 20 | 21 | import java.util.Collection; 22 | 23 | /** 24 | * @author Vaclav Pech 25 | */ 26 | public interface BindErrorListenerManager { 27 | void addBindErrorListener(BindErrorListener listener); 28 | 29 | void addAllBindErrorListeners(Collection> listeners); 30 | 31 | void removeBindErrorListener(BindErrorListener listener); 32 | 33 | Collection> getBindErrorListeners(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/impl/DataflowChannelEventDistributor.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.impl; 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | public interface DataflowChannelEventDistributor { 23 | void fireOnMessage(T message); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/impl/DataflowChannelEventListenerManager.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.impl; 18 | 19 | import groovyx.gpars.dataflow.DataflowChannelListener; 20 | 21 | import java.util.Collection; 22 | 23 | /** 24 | * @author Vaclav Pech 25 | */ 26 | public interface DataflowChannelEventListenerManager { 27 | void addDataflowChannelListener(DataflowChannelListener listener); 28 | 29 | void addAllDataflowChannelListeners(Collection> listeners); 30 | 31 | void removeDataflowChannelListener(DataflowChannelListener listener); 32 | 33 | Collection> getListeners(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/operator/ControlMessage.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.operator; 18 | 19 | /** 20 | * A marker interface indicating control dataflow messages, which in general do not get propagated to the operator's body 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | @SuppressWarnings("MarkerInterface") 25 | public interface ControlMessage { 26 | } 27 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/operator/StopGently.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.operator; 18 | 19 | /** 20 | * A message to stop operators' actors once they handle the next round of messages. 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | @SuppressWarnings({"ALL"}) 25 | class StopGently { 26 | private static StopGently ourInstance = new StopGently(); 27 | 28 | public static StopGently getInstance() { 29 | return ourInstance; 30 | } 31 | 32 | private StopGently() { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/operator/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.dataflow.operator.* 22 | 23 | 24 |

25 | This package holds classes representing operators and channels necessary for full dataflow concurrency. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.dataflow.* 22 | 23 | 24 |

25 | This package holds classes for basic dataflow concurrency constructs, like dataflow variables, streams and threads. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/dataflow/stream/FList.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.stream; 18 | 19 | import groovy.lang.Closure; 20 | 21 | /** 22 | * Represents a list implemented as a Functional Queue. 23 | * 24 | * @param The type of values to store in the list 25 | */ 26 | public interface FList extends Iterable { 27 | 28 | T getFirst(); 29 | 30 | FList getRest(); 31 | 32 | boolean isEmpty(); 33 | 34 | FList filter(Closure filterClosure); 35 | 36 | FList map(Closure mapClosure); 37 | 38 | Object reduce(Closure reduceClosure); 39 | 40 | Object reduce(T seed, Closure reduceClosure); 41 | 42 | String appendingString(); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/forkjoin/CallAsyncTask.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.forkjoin; 18 | 19 | import groovy.lang.Closure; 20 | import java.util.concurrent.RecursiveTask; 21 | 22 | /** 23 | * A helper class to wrap closures for {@code callAsync} on {@code GParsPool} 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | public final class CallAsyncTask extends RecursiveTask { 28 | private final Closure code; 29 | 30 | public CallAsyncTask(final Closure code) { 31 | this.code = code; 32 | } 33 | 34 | @Override 35 | protected V compute() { 36 | return code.call(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/CallAsyncTask.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // package groovyx.gpars.pa; 18 | 19 | // import groovy.lang.Closure; 20 | // import java.util.concurrent.RecursiveTask; 21 | 22 | // /** 23 | // * A helper class to wrap closures for callAsync on GParsPool 24 | // * 25 | // * @author Vaclav Pech 26 | // */ 27 | // public final class CallAsyncTask extends RecursiveTask { 28 | // private final Closure code; 29 | 30 | // public CallAsyncTask(final Closure code) { 31 | // this.code = code; 32 | // } 33 | 34 | // @Override 35 | // protected V compute() { 36 | // return code.call(); 37 | // } 38 | // } 39 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/ClosureMapper.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008--2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // package groovyx.gpars.pa; 18 | 19 | // // TODO: delete 20 | // //import groovyx.gpars.extra166y.Ops; 21 | // import groovy.lang.Closure; 22 | 23 | // /** 24 | // * A PA mapper built around a closure 25 | // * 26 | // * @author Vaclav Pech 27 | // */ 28 | // public final class ClosureMapper implements Ops.Op { 29 | // private final Closure code; 30 | 31 | // public ClosureMapper(final Closure code) { 32 | // this.code = code; 33 | // } 34 | 35 | // @Override 36 | // public V op(final Object o) { 37 | // return code.call(o); 38 | // } 39 | // } 40 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/ClosureNegationPredicate.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008--2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // package groovyx.gpars.pa; 18 | 19 | // // TODO: delete 20 | // //import groovyx.gpars.extra166y.Ops; 21 | // import groovy.lang.Closure; 22 | 23 | // /** 24 | // * A PA predicate built around a closure 25 | // * 26 | // * @author Vaclav Pech 27 | // */ 28 | // public final class ClosureNegationPredicate implements Ops.Predicate { 29 | // private final Closure code; 30 | 31 | // public ClosureNegationPredicate(final Closure code) { 32 | // this.code = code; 33 | // } 34 | 35 | // @Override 36 | // public boolean op(final Object o) { 37 | // return !GParsPoolUtilHelper.convertToBoolean(code.call(o)); 38 | // } 39 | // } 40 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/ClosurePredicate.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008--2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // package groovyx.gpars.pa; 18 | 19 | // // TODO: delete 20 | // //import groovyx.gpars.extra166y.Ops; 21 | // import groovy.lang.Closure; 22 | 23 | // /** 24 | // * A PA predicate built around a closure 25 | // * 26 | // * @author Vaclav Pech 27 | // */ 28 | // public final class ClosurePredicate implements Ops.Predicate { 29 | // private final Closure code; 30 | 31 | // public ClosurePredicate(final Closure code) { 32 | // this.code = code; 33 | // } 34 | 35 | // @Override 36 | // public boolean op(final Object o) { 37 | // return GParsPoolUtilHelper.convertToBoolean(code.call(o)); 38 | // } 39 | // } 40 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/ClosureReducer.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008--2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // package groovyx.gpars.pa; 18 | 19 | // // TODO: delete 20 | // //import groovyx.gpars.extra166y.Ops; 21 | // import groovy.lang.Closure; 22 | 23 | // /** 24 | // * A PA reducer built around a closure 25 | // * 26 | // * @author Vaclav Pech 27 | // */ 28 | // public final class ClosureReducer implements Ops.Reducer { 29 | // private final Closure code; 30 | 31 | // public ClosureReducer(final Closure code) { 32 | // this.code = code; 33 | // } 34 | 35 | // @SuppressWarnings("unchecked") 36 | // @Override 37 | // public T op(final Object o, final Object o1) { 38 | // final Object[] args = {o, o1}; 39 | // return (T) code.call(args); 40 | // } 41 | // } 42 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/pa/PAWrapper.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2012, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.pa 18 | 19 | import groovy.transform.CompileStatic 20 | import groovy.transform.TypeCheckingMode 21 | 22 | /** 23 | * The default ParallelArray wrapper class 24 | */ 25 | @CompileStatic(value = TypeCheckingMode.PASS) 26 | final class PAWrapper extends AbstractPAWrapper { 27 | def PAWrapper(final pa) { super(pa) } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.* 22 | 23 | 24 |

25 | This package holds classes for asynchronous collection processing. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/RemotingContextWithUrls.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote; 18 | 19 | /** 20 | * Marker interface that describes contexts that support urls 21 | */ 22 | public interface RemotingContextWithUrls { 23 | boolean has(String url); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/message/CloseConnectionMsg.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.message; 18 | 19 | import groovyx.gpars.remote.RemoteConnection; 20 | import groovyx.gpars.serial.SerialMsg; 21 | 22 | /** 23 | * Message that triggers disconnect action. 24 | * 25 | * @author Rafal Slawik 26 | */ 27 | public class CloseConnectionMsg extends SerialMsg { 28 | 29 | @Override 30 | public void execute(RemoteConnection conn) { 31 | conn.disconnect(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/message/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.remote.message.* 22 | 23 | 24 |

25 | This package holds message classes for the remote actors implementation. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/ConnectListener.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.netty; 18 | 19 | import groovyx.gpars.remote.RemoteConnection; 20 | 21 | @FunctionalInterface 22 | public interface ConnectListener { 23 | public void onConnect(RemoteConnection connection); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/discovery/DiscoveryRequest.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.netty.discovery; 18 | 19 | public class DiscoveryRequest { 20 | private final String actorUrl; 21 | 22 | public DiscoveryRequest(String actorUrl) { 23 | this.actorUrl = actorUrl; 24 | } 25 | 26 | public String getActorUrl() { 27 | return actorUrl; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/discovery/DiscoveryRequestWithSender.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.netty.discovery; 18 | 19 | import java.net.InetSocketAddress; 20 | 21 | public class DiscoveryRequestWithSender { 22 | private final DiscoveryRequest request; 23 | private final InetSocketAddress sender; 24 | 25 | public DiscoveryRequestWithSender(DiscoveryRequest request, InetSocketAddress sender) { 26 | this.request = request; 27 | this.sender = sender; 28 | } 29 | 30 | public DiscoveryRequest getRequest() { 31 | return request; 32 | } 33 | 34 | public InetSocketAddress getSender() { 35 | return sender; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/discovery/DiscoveryResponse.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.netty.discovery; 18 | 19 | import java.net.InetSocketAddress; 20 | 21 | public class DiscoveryResponse { 22 | private final String actorUrl; 23 | private final InetSocketAddress serverSocketAddress; 24 | 25 | public DiscoveryResponse(String actorUrl, InetSocketAddress serverSocketAddress) { 26 | this.actorUrl = actorUrl; 27 | this.serverSocketAddress = serverSocketAddress; 28 | } 29 | 30 | public String getActorUrl() { 31 | return actorUrl; 32 | } 33 | 34 | public InetSocketAddress getServerSocketAddress() { 35 | return serverSocketAddress; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/discovery/DiscoveryResponseWithRecipient.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote.netty.discovery; 18 | 19 | import java.net.InetSocketAddress; 20 | 21 | public class DiscoveryResponseWithRecipient { 22 | private final DiscoveryResponse response; 23 | private final InetSocketAddress recipient; 24 | 25 | public DiscoveryResponseWithRecipient(DiscoveryResponse response, InetSocketAddress recipient) { 26 | this.response = response; 27 | this.recipient = recipient; 28 | } 29 | 30 | public DiscoveryResponse getResponse() { 31 | return response; 32 | } 33 | 34 | public InetSocketAddress getRecipient() { 35 | return recipient; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/netty/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.remote.netty.* 22 | 23 | 24 |

25 | This package holds implementation-specific classes implementing the remote actors functionality on top of Netty. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/remote/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.remote.* 22 | 23 | 24 |

25 | This package holds classes implementing the remoting interface for actors, dataflows and agents. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/scheduler/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.scheduler.* 22 | 23 | 24 |

25 | This package holds thread pools / schedulers used by actors and dataflow concurrency. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/serial/LocalHandle.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.serial; 18 | 19 | import java.io.Serializable; 20 | import java.util.UUID; 21 | 22 | /** 23 | * @author Alex Tkachman 24 | */ 25 | public final class LocalHandle implements Serializable { 26 | private static final long serialVersionUID = -8206894167996286304L; 27 | private final UUID id; 28 | 29 | public LocalHandle(final UUID id) { 30 | this.id = id; 31 | } 32 | 33 | @SuppressWarnings({"UnusedDeclaration", "ProtectedMemberInFinalClass"}) 34 | protected Object readResolve() { 35 | return SerialContext.get().get(id).get(); 36 | } 37 | 38 | public UUID getId() { 39 | return id; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/serial/RemoteSerialized.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.serial; 18 | 19 | /** 20 | * Marker interface for objects, which are proxies to objects on other nodes. 21 | * 22 | * @author Alex Tkachman 23 | */ 24 | public interface RemoteSerialized { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/serial/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.serial.* 22 | 23 | 24 |

25 | This package holds classes used for actor identification in the network. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/streams/ClosureConsumer.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.streams; 18 | 19 | import java.util.function.Consumer; 20 | 21 | import groovy.lang.Closure; 22 | 23 | /** 24 | * A wrapper around a Groovy Closure to create a Java BinaryOperator suitable for use in a Streams reduction. 25 | * 26 | * @author Russel Winder 27 | */ 28 | public class ClosureConsumer implements Consumer { 29 | 30 | private final Closure code; 31 | 32 | public ClosureConsumer(final Closure code) { 33 | this.code = code; 34 | } 35 | 36 | @Override 37 | public void accept(final T a) { 38 | final Object[] args = {a}; 39 | code.call(args); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/streams/ClosureReducer.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.streams; 18 | 19 | import java.util.function.BinaryOperator; 20 | 21 | import groovy.lang.Closure; 22 | 23 | /** 24 | * A wrapper around a Groovy Closure to create a Java BinaryOperator suitable for use in a Streams reduction. 25 | * 26 | * @author Russel Winder 27 | */ 28 | public class ClosureReducer implements BinaryOperator { 29 | 30 | private final Closure code; 31 | 32 | public ClosureReducer(final Closure code) { 33 | this.code = code; 34 | } 35 | 36 | @Override 37 | public T apply(final T a, final T b) { 38 | final Object[] args = {a, b}; 39 | return (T) code.call(args); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/GeneralTimer.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2013 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util; 18 | 19 | /** 20 | * Represents timers, either java.util.Timer or timers provided by the hosting environment, such as GAE 21 | */ 22 | public interface GeneralTimer { 23 | void schedule(Runnable task, long timeout); 24 | 25 | void shutdown(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/MessageQueue.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util; 18 | 19 | /** 20 | * The high-performance actor message queue 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | public interface MessageQueue { 25 | boolean isEmpty(); 26 | 27 | Object poll(); 28 | 29 | void add(Object element); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/PAGroovyUtils.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2011, 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //package groovyx.gpars.util 18 | // 19 | ///** 20 | // * 21 | // * @author Vaclav Pech 22 | // * Date: 6th Sep 2010 23 | // */ 24 | //abstract class PAGroovyUtils { 25 | // 26 | // static java.util.Collection createCollection(Object object) { 27 | // def collection = [] 28 | // for (element in object) collection << element 29 | // return collection 30 | // } 31 | //} 32 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/PoolFactory.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util; 18 | 19 | import groovyx.gpars.scheduler.Pool; 20 | 21 | /** 22 | * Used to create thread pools in hosted environment 23 | * 24 | * @author Vaclav Pech 25 | */ 26 | public interface PoolFactory { 27 | Pool createPool(); 28 | 29 | Pool createPool(boolean daemon); 30 | 31 | Pool createPool(int numberOfThreads); 32 | 33 | Pool createPool(boolean daemon, int numberOfThreads); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/TimerFactory.java: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util; 18 | 19 | /** 20 | * Allows customized timers to be created in managed environments such as GAE 21 | * 22 | * @author Vaclav Pech 23 | */ 24 | public interface TimerFactory { 25 | GeneralTimer createTimer(final String name, final boolean daemon); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/groovy/groovyx/gpars/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | package groovyx.gpars.util.* 22 | 23 | 24 |

25 | Various utility classes enhancing basic Java concurrency constructs. 26 |

27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*** 2 | * GPars (Groovy Parallel Systems): a groovy concurrency library. 3 | * It provides support for configuring parallel system using Groovy 4 | * The project resides at http://gpars.codehaus.org 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2008-2013 Vaclav Pech, vaclav.pech@seznam.cz 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | */ 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/NOTICE.txt: -------------------------------------------------------------------------------- 1 | GPars -- Groovy Parallel Systems 2 | Copyright 2008--2013 Vaclav Pech and the original author or authors 3 | 4 | This product includes software developed by Vaclav Pech 5 | (http://www.linkedin.com/in/vaclavpech) 6 | 7 | This product is licensed to you under the Apache License, version 2.0 (the 8 | "License"); you may not use this product except in compliance with the License. 9 | You may obtain a copy of the License at: 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software distributed 14 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 15 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations under the License. 17 | 18 | This product optionally depends on the works by JSR-166 EG, Doug Lea, 19 | and Jason T. Greene: 20 | 21 | * LICENSE: 22 | * licenses/LICENSE.jsr166y.txt (Public Domain) 23 | * HOMEPAGE: 24 | * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/ 25 | 26 | This product optionally depends on The Netty Project by Red Hat, Inc. 27 | 28 | * LICENSE: 29 | * licenses/LICENSE-netty.txt (Apache 2 license) 30 | * DEPENDENCIES: 31 | * licenses/NOTICE-netty.txt 32 | * HOMEPAGE: 33 | * http://www.jboss.org/netty/ 34 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/README: -------------------------------------------------------------------------------- 1 | *GPars* (Groovy Parallel Systems) allows Groovy code to easily handle tasks concurrently and asynchronously, leveraging either the JSR-166y _Parallel Arrays_ or Java's executor services. 2 | 3 | Please visit the project site for more information - http://gpars.codehaus.org 4 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/MapReduceSpockTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars 18 | 19 | import spock.lang.Specification 20 | import spock.lang.Unroll 21 | 22 | import static groovyx.gpars.GParsPool.withPool 23 | 24 | class MapReduceSpockTest extends Specification { 25 | @Unroll 26 | def "min of #nums is #minValue"() { 27 | expect: 28 | withPool() { 29 | nums.parallel.reduce { a, b -> Math.min(a, b) } == minValue 30 | } 31 | where: 32 | nums | minValue 33 | [1, 2, 3, 4, 5] || 1 34 | [4, 2, 3, 1, 5] || 1 35 | [4, 5, 3, 2, 1] || 1 36 | [2, 2, 3, 4, 5] || 2 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/actor/AbstractLoopingActorTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor; 18 | 19 | 20 | import groovyx.gpars.group.DefaultPGroup 21 | import spock.lang.Specification 22 | 23 | class AbstractLoopingActorTest extends Specification { 24 | def "changing parallel group on a DDA and reactor changes the core thread pool"() { 25 | given: 26 | def group = new DefaultPGroup() 27 | 28 | when: 29 | actor.parallelGroup = group 30 | then: 31 | actor.core.threadPool == group.threadPool 32 | 33 | cleanup: 34 | group.shutdown() 35 | 36 | where: 37 | actor << [new DynamicDispatchActor(), new ReactiveActor({}), Actors.messageHandler {}, Actors.reactor {}] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/actor/nonBlocking/RepeatLoopTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.nonBlocking 18 | 19 | import groovyx.gpars.actor.Actors 20 | import java.util.concurrent.CountDownLatch 21 | 22 | public class RepeatLoopTest extends GroovyTestCase { 23 | 24 | public void testLoopWithoutReact() { 25 | int count = 0 26 | final CountDownLatch latch = new CountDownLatch(1) 27 | 28 | Actors.actor { 29 | loop { 30 | if (count == 10) { 31 | latch.countDown() 32 | terminate() 33 | return 34 | } 35 | count += 1 36 | } 37 | } 38 | 39 | latch.await() 40 | assert 10 == count 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/actor/nonBlocking/SingleThreadLoopTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.nonBlocking 18 | 19 | import groovyx.gpars.group.DefaultPGroup 20 | 21 | /** 22 | * 23 | * @author Vaclav Pech 24 | * Date: Feb 18, 2009 25 | */ 26 | public class SingleThreadLoopTest extends LoopTest { 27 | 28 | protected void setUp() { 29 | group = new DefaultPGroup(1) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/actor/nonBlocking/SingleThreadedLifeCycleTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.nonBlocking 18 | 19 | import groovyx.gpars.group.DefaultPGroup 20 | 21 | /** 22 | * 23 | * @author Vaclav Pech 24 | * Date: Feb 20, 2009 25 | */ 26 | public class SingleThreadedLifeCycleTest extends LifeCycleTest { 27 | 28 | protected void setUp() { 29 | group = new DefaultPGroup(1) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/actor/nonBlocking/SingleThreadedMessagingTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.actor.nonBlocking 18 | 19 | import groovyx.gpars.group.DefaultPGroup 20 | 21 | /** 22 | * 23 | * @author Vaclav Pech 24 | * Date: Feb 20, 2009 25 | */ 26 | public class SingleThreadedMessagingTest extends MessagingTest { 27 | 28 | protected void setUp() { 29 | group = new DefaultPGroup(1) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/agent/remote/RemoteAgentsTest.groovy: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.agent.remote 2 | 3 | import groovyx.gpars.agent.Agent 4 | import groovyx.gpars.dataflow.DataflowVariable 5 | import spock.lang.Specification 6 | 7 | class RemoteAgentsTest extends Specification { 8 | RemoteAgents remoteAgents = RemoteAgents.create() 9 | 10 | def "retrieving not published Agent returns null"() { 11 | when: 12 | def agent = remoteAgents.get Agent, "test-agent" 13 | 14 | then: 15 | agent == null 16 | } 17 | 18 | def "can publish an Agent"() { 19 | setup: 20 | Agent agent = new Agent("test-agent"); 21 | def name = "test-agent" 22 | 23 | when: 24 | remoteAgents.publish agent, name 25 | def retrievedAgent = remoteAgents.get Agent, name 26 | 27 | then: 28 | retrievedAgent == agent 29 | } 30 | 31 | def "retrieving an Agent from remote host returns Future"() { 32 | setup: 33 | def PORT = 9555 34 | def name = "test-agent" 35 | 36 | when: 37 | def agentFuture = remoteAgents.get "some-host", PORT, name 38 | 39 | then: 40 | agentFuture != null 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/benchmark/actorComparison/BenchmarkSafe.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.benchmark.actorComparison 18 | 19 | import groovyx.gpars.agent.Agent 20 | 21 | import java.util.concurrent.ExecutorService 22 | import java.util.concurrent.Executors 23 | 24 | /** 25 | * @author Vaclav Pech 26 | * Date: 13.4.2010 27 | */ 28 | 29 | final ExecutorService pool = Executors.newFixedThreadPool(10) 30 | 31 | final long t1 = System.currentTimeMillis() 32 | final Agent agent = new Agent(0L) 33 | 300.times { 34 | 1000.times { 35 | pool.submit {agent << {updateValue(it + 1)}} 36 | } 37 | agent.await() 38 | } 39 | final long t2 = System.currentTimeMillis() 40 | println "Result: ${agent.val}" 41 | println "Time: ${t2 - t1}" 42 | pool.shutdown() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/benchmark/akka/Messages.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.benchmark.akka 18 | 19 | import groovy.transform.Immutable 20 | 21 | /** 22 | * @author Jiri Mares, Vaclav Pech 23 | */ 24 | 25 | @Singleton 26 | class StartMessage {} 27 | @Singleton 28 | class StopMessage {} 29 | @Singleton 30 | class CancelMessage {} 31 | @Immutable 32 | final class TokenMessage { 33 | int id 34 | int value 35 | } -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/benchmark/embarrassinglyParallel/BenchmarkCollections.groovy: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.benchmark.embarrassinglyParallel 2 | 3 | import groovyx.gpars.GParsExecutorsPool 4 | import groovyx.gpars.GParsPool 5 | 6 | final numbers = (0L..100000L).collect() {it} 7 | def sum = 1 8 | 2.times { 9 | sum = measureFJPool(numbers, sum) 10 | } 11 | 12 | final t1 = System.currentTimeMillis() 13 | 2.times { 14 | sum = measureFJPool(numbers, sum) 15 | } 16 | final t2 = System.currentTimeMillis() 17 | 18 | 2.times { 19 | sum = measurePool(numbers, sum) 20 | } 21 | 22 | final t3 = System.currentTimeMillis() 23 | 2.times { 24 | sum = measurePool(numbers, sum) 25 | } 26 | final t4 = System.currentTimeMillis() 27 | 28 | println sum 29 | println "FJ pool: " + (t2 - t1) 30 | println "Executors pool: " + (t4 - t3) 31 | 32 | private long measureFJPool(numbers, sum) { 33 | GParsPool.withPool { 34 | (numbers.everyParallel {it >= 0}) ? sum : 0 35 | } 36 | } 37 | 38 | private long measurePool(numbers, sum) { 39 | GParsExecutorsPool.withPool { 40 | (numbers.everyParallel {it >= 0}) ? sum : 0 41 | } 42 | } -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/dataflow/DFSpockTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow 18 | 19 | import spock.lang.Specification 20 | 21 | class DFSpockTest extends Specification { 22 | 23 | def "data flow variable gets assigned"() { 24 | def result = new DataflowVariable() 25 | when: result << 10 26 | then: 27 | result.val == 10 28 | result.isBound() 29 | } 30 | 31 | def "data flow variable cannot be re-assigned"() { 32 | def result = new DataflowVariable() 33 | given: result << 10 34 | when: result << 20 35 | then: 36 | thrown(IllegalStateException) 37 | result.val == 10 38 | result.isBound() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/dataflow/operator/component/TestControlMessage.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.dataflow.operator.component 18 | 19 | import groovyx.gpars.dataflow.operator.ControlMessage 20 | 21 | /** 22 | * @author Vaclav Pech 23 | */ 24 | class TestControlMessage implements ControlMessage { } 25 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/integration/remote/RemoteSpecification.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2015 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.integration.remote 18 | 19 | import spock.lang.Specification 20 | 21 | class RemoteSpecification extends Specification { 22 | String getHostAddress() { 23 | InetAddress.getLocalHost().getHostAddress() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/issues/ImmutableAct.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.issues 18 | 19 | class FailingA { 20 | protected void act() { 21 | throw new UnsupportedOperationException() 22 | } 23 | } 24 | 25 | //@groovy.transform.Immutable 26 | final class FailingB extends FailingA { 27 | public void act() { 28 | 29 | } 30 | } 31 | 32 | final def b = new FailingB() 33 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/issues/ImmutableMessageIssue.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.issues 18 | 19 | @groovy.transform.Immutable final class TestMessage { 20 | String value 21 | } 22 | 23 | final class Foo {} 24 | 25 | if (new Foo() == new TestMessage('Value')) println 'Equal' 26 | if (new TestMessage('Value') == new Foo()) println 'Equal' 27 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/issues/MixinIssue1.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.issues 18 | 19 | class A { 20 | 21 | int counter = 0 22 | 23 | protected def final foo() { 24 | bar { 25 | counter 26 | } 27 | } 28 | 29 | private final String bar(Closure code) { 30 | return "Bar " + code() 31 | } 32 | } 33 | 34 | class B extends A {} 35 | 36 | class C {} 37 | 38 | C.metaClass { 39 | mixin B 40 | } 41 | 42 | def c = new C() 43 | c.foo() 44 | 45 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/issues/MixinIssue3.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.issues 18 | 19 | class A3 { 20 | 21 | public int counter = 0 22 | 23 | 24 | } 25 | 26 | class B3 extends A3 { 27 | public void foo() { 28 | counter = 1 29 | } 30 | } 31 | 32 | class C3 {} 33 | 34 | C3.metaClass { 35 | mixin B3 36 | } 37 | 38 | def c = new C3() 39 | c.foo() 40 | 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/issues/PropertyIssues.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.issues 18 | 19 | class Parent { 20 | private String myPrivateProperty = "secret" 21 | 22 | public void foo() { 23 | Thread.start { 24 | println myPrivateProperty 25 | } 26 | } 27 | } 28 | 29 | class Child extends Parent { 30 | 31 | } 32 | 33 | final Parent item = new Child() 34 | item.foo() 35 | 36 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/remote/LocalHostMock.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.remote 18 | 19 | class LocalHostMock extends LocalHost { 20 | 21 | @Override 22 | def void registerProxy(Class klass, String name, T object) { 23 | 24 | } 25 | 26 | @Override 27 | def T get(Class klass, String name) { 28 | return null 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/activeobject/DemoBlockingActiveObject.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.activeobject 18 | 19 | import groovyx.gpars.activeobject.ActiveMethod 20 | import groovyx.gpars.activeobject.ActiveObject 21 | 22 | @ActiveObject 23 | class BlockingDecryptor { 24 | @ActiveMethod(blocking = true) 25 | String decrypt(String encryptedText) { 26 | encryptedText.reverse() 27 | } 28 | 29 | @ActiveMethod(blocking = true) 30 | Integer decrypt(Integer encryptedNumber) { 31 | -1 * encryptedNumber + 142 32 | } 33 | } 34 | 35 | final BlockingDecryptor decryptor = new BlockingDecryptor() 36 | print decryptor.decrypt(' noitcA ni yvoorG') 37 | print decryptor.decrypt(140) 38 | println decryptor.decrypt('noitide dn') -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/actors/stateful/DemoCurriedActorChain.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.actors.stateful 18 | 19 | import groovyx.gpars.actor.Actors 20 | 21 | /** 22 | * Creates a chain of actors, which pass a message from one end of the chain to the other one. 23 | */ 24 | 25 | def intermediaries = [] 26 | 27 | for (i in 1..30) { 28 | intermediaries << Actors.actor({index -> 29 | react { 30 | println('Received: ' + index + ":" + it) 31 | if (index != 29) intermediaries[index + 1].send('message') 32 | } 33 | }.curry(i)) 34 | } 35 | 36 | intermediaries[0].send 'message' 37 | sleep 2000 -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/agent/DemoThreadSafeCounter.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.agent 18 | 19 | import groovyx.gpars.agent.Agent 20 | 21 | /** 22 | * A thread-safe counter. Threads can submit commands, which increase or decrease the internal counter without fear 23 | * of mutual races or lost updates. 24 | */ 25 | final Agent counter = new Agent(0L) 26 | 27 | final Thread t1 = Thread.start { 28 | counter << {updateValue it + 1} 29 | } 30 | 31 | final Thread t2 = Thread.start { 32 | counter << {updateValue it + 6} 33 | } 34 | 35 | final Thread t3 = Thread.start { 36 | counter << {updateValue it - 2} 37 | } 38 | 39 | [t1, t2, t3]*.join() 40 | 41 | assert 5 == counter.val 42 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/collections/DemoAsynchronousProcessingr.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.collections 18 | 19 | import groovyx.gpars.GParsPool 20 | 21 | /** 22 | * Shows lazy nature of the anyParallel() method. Once a positive result is obtained no more elements are going to be processed. 23 | */ 24 | 25 | def n = [15, 4, 3, 4, 10] 26 | GParsPool.withPool(3) {pool -> 27 | def k = n.anyParallel {t -> 28 | println "$t started" 29 | sleep t * 1000 30 | println "$t ended" 31 | true 32 | } 33 | println k 34 | } 35 | println "all ended" 36 | 37 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/collections/DemoParallelMaps.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.collections 18 | 19 | import groovyx.gpars.GParsPool 20 | 21 | /** 22 | * This demo shows that maps can be processed in parallel just like other collections. 23 | * Also, the map-specific, two-argument closure can be passed to the relevant parallel methods. 24 | */ 25 | def map = [a: 1, b: 2, c: 3, d: 4, e: 5] 26 | GParsPool.withPool { 27 | map.eachParallel {item -> println "$item.key : $item.value"} 28 | map.eachParallel {k, v -> println "$k : $v"} 29 | println map.collectParallel {item -> "[$item.key : $item.value]"} 30 | println map.collectParallel {k, v -> "[$k : $v]"} 31 | 32 | println map.makeConcurrent().collect {k, v -> "[$k : $v]"} 33 | } -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/csp/DemoNumbers.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.csp 18 | 19 | import groovyx.gpars.csp.PAR 20 | import groovyx.gpars.csp.plugAndPlay.GNumbers 21 | import groovyx.gpars.csp.plugAndPlay.GPrint 22 | 23 | import jcsp.lang.Channel 24 | import jcsp.lang.One2OneChannel 25 | 26 | One2OneChannel N2P = Channel.createOne2One() 27 | 28 | def testList = [ 29 | new GNumbers(outChannel: N2P.out()), 30 | new GPrint(inChannel: N2P.in(), heading: "Numbers") 31 | ] 32 | 33 | final def par = new PAR(testList) 34 | par.run() 35 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/csp/proposed/ResetUser.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.csp.proposed 18 | 19 | //process ResetUser ( ! resetValue, ! toConsole, ? fromConverter, ! toClearOutput ) { 20 | // 21 | // toConsole.write( "Please input reset values\n" ) 22 | // while (true) { 23 | // def v = fromConverter.read() 24 | // toClearOutput.write("\n") 25 | // resetValue.write(v) 26 | // } 27 | //} -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/csp/resetexamples/ResetUser.groovy: -------------------------------------------------------------------------------- 1 | // GPars — Groovy Parallel Systems 2 | // 3 | // Copyright © 2008–2010, 2018 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.csp.resetexamples 18 | 19 | import jcsp.lang.CSProcess 20 | import jcsp.lang.ChannelInput 21 | import jcsp.lang.ChannelOutput 22 | 23 | class ResetUser implements CSProcess { 24 | 25 | ChannelOutput resetValue 26 | ChannelOutput toConsole 27 | ChannelInput fromConverter 28 | ChannelOutput toClearOutput 29 | 30 | void run() { 31 | toConsole.write("Please input reset values\n") 32 | while (true) { 33 | def v = fromConverter.read() 34 | toClearOutput.write("\n") 35 | resetValue.write(v) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/BenchmarkManyDataflowVariables.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | import java.util.concurrent.Executors 21 | 22 | final many = 1..(100) 23 | 24 | List dfs = many.collect { new DataflowVariable() } 25 | def result = new DataflowVariable() 26 | 27 | def scheduler = Executors.newFixedThreadPool(20) 28 | 29 | scheduler.execute { result << dfs.sum { it.val } } 30 | 31 | dfs.each {df -> 32 | scheduler.execute { df << 1 } 33 | } 34 | 35 | assert many.size() == result.val 36 | 37 | scheduler.shutdown() 38 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DataflowDemo1.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable as WAIT 20 | 21 | import static groovyx.gpars.dataflow.Dataflow.task 22 | 23 | /** 24 | * Basic sample showing three green threads cooperating on three variables. 25 | */ 26 | WAIT x = new WAIT() 27 | WAIT y = new WAIT() 28 | WAIT z = new WAIT() 29 | 30 | task { z << x.val + y.val } 31 | 32 | task { x << 40 } 33 | task { y << 2 } 34 | 35 | println "z=${z.val}" 36 | assert 42 == z.val 37 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DataflowDemo6.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | /** 23 | * Basic sample showing three green threads cooperating on three variables. 24 | */ 25 | 26 | final def x = new DataflowVariable() 27 | final def y = new DataflowVariable() 28 | final def z = new DataflowVariable() 29 | 30 | task { 31 | z << x.val + y.val 32 | println "Result: ${z.val}" 33 | System.exit 0 34 | } 35 | 36 | task { 37 | x << 10 38 | } 39 | 40 | task { 41 | y << 5 42 | }.join() 43 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoDataflows.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.Dataflows 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | /** 23 | * Demonstrates the use of the Dataflows class to exchange values among threads or tasks. 24 | * 25 | * @author Vaclav Pech, Dierk Koenig 26 | */ 27 | 28 | final df = new Dataflows() 29 | 30 | task { df.result = df.x + df.y } 31 | 32 | task { df.x = 10 } 33 | 34 | task { df.y = 5 } 35 | 36 | assert 15 == df.result 37 | 38 | task { //noinspection GroovyAssignmentCanBeOperatorAssignment 39 | df[0] = df[2] + df[1] 40 | } 41 | 42 | task { df[1] = 10 } 43 | 44 | task { df[2] = 5 } 45 | 46 | assert 15 == df[0] 47 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoDataflowsPolished.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.Dataflows 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | /** 23 | * Demonstrates the use of the Dataflows class to exchange values among threads or tasks. 24 | * Uses the with() method on Dataflows to simplify the DSL. 25 | * 26 | * @author Vaclav Pech, Dierk Koenig 27 | */ 28 | 29 | new Dataflows().with { 30 | task { result = x + y } 31 | 32 | task { x = 10 } 33 | 34 | task { y = 5 } 35 | 36 | assert 15 == result 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoJoinActivitiesThroughPromises.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2013 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import static groovyx.gpars.dataflow.Dataflow.task 20 | 21 | /** 22 | * Demonstrates the thenForkAndJoin() capability of promises. The thenForkAndJoin() method triggers multiple 'then' handlers, 23 | * once a promise they wait for has been bound. The method returns a promise eventually containing a list of results of all the parallel 'then' handlers. 24 | * in a list to the next 25 | */ 26 | task { 27 | 2 28 | }.thenForkAndJoin({ it ** 2 }, { it ** 3 }, { it ** 4 }, { it ** 5 }).then({ println it }).join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoLazyDataflowVariable.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.LazyDataflowVariable 20 | 21 | Closure download = { url -> 22 | println "Downloading" 23 | url.toURL().text 24 | } 25 | 26 | def pageContent = new LazyDataflowVariable(download.curry("http://gpars.codehaus.org")) 27 | 28 | println "No-one has asked for the value just yet. Bound = ${pageContent.bound}" 29 | sleep 1000 30 | println "Now going to ask for a value" 31 | println pageContent.get().size() 32 | println "Repetitive requests will receive the already calculated value. No additional downloading." 33 | println pageContent.get().size() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoLazyTask.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.Dataflow 20 | 21 | def pageContent = Dataflow.lazyTask { 22 | println "Downloading" 23 | "http://gpars.codehaus.org".toURL().text 24 | } 25 | 26 | println "No-one has asked for the value just yet. Bound = ${pageContent.bound}" 27 | sleep 1000 28 | println "Now going to ask for a value" 29 | println pageContent.get().size() 30 | println "Repetitive requests will receive the already calculated value. No additional downloading." 31 | println pageContent.get().size() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoManyDataflows.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | 18 | package groovyx.gpars.samples.dataflow 19 | 20 | import groovyx.gpars.dataflow.Dataflows 21 | import java.util.concurrent.Executors 22 | 23 | final LIMIT = 3 * 100 * 1000 24 | 25 | final df = new Dataflows(LIMIT + 1, 0.9f, 16) 26 | 27 | final many = 1..LIMIT 28 | 29 | def scheduler = Executors.newFixedThreadPool(20) 30 | 31 | scheduler.execute { df.result = many.collect { df[it] }.sum() } 32 | 33 | // each in a newly started executor: 34 | many.each {num -> 35 | scheduler.execute { 36 | df[num] = 1 37 | } 38 | } 39 | 40 | // Wait for the result to be available 41 | // This is in the main thread, which is DF unaware! 42 | assert many.size() == df.result 43 | scheduler.shutdown() 44 | println "done" 45 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoNonDeterministicDeadlockWithDataflows.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.Dataflows 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | final df = new Dataflows() 23 | 24 | task { df.x = df.y } 25 | 26 | // Example of how to introduce non-determinism into df usage. 27 | // Don't do it! 28 | task { if (Math.random() < 0.5f) df.y = 1 else df.y = df.x } 29 | 30 | assert 1 == df.x 31 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoNormalThreadDataflow.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | final DataflowVariable a = new DataflowVariable() 22 | final DataflowVariable b = new DataflowVariable() 23 | 24 | Thread.start { 25 | println "Received: $a.val" 26 | Thread.sleep 2000 27 | b << 'Thank you' 28 | } 29 | 30 | Thread.start { 31 | Thread.sleep 2000 32 | a << 'An important message from the second thread' 33 | println "Reply: $b.val" 34 | } 35 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/DemoProducerConsumer1.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow 18 | 19 | import groovyx.gpars.dataflow.DataflowQueue 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | /** 23 | * A simple producer consumer sample showing use of the DataflowQueue class. 24 | */ 25 | def words = ['Groovy', 'fantastic', 'concurrency', 'fun', 'enjoy', 'safe', 'GPars', 'data', 'flow'] 26 | final def buffer = new DataflowQueue() 27 | 28 | task { 29 | for (word in words) { 30 | buffer << word.toUpperCase() 31 | } 32 | } 33 | 34 | task { 35 | while (true) println buffer.val 36 | } 37 | 38 | System.in.read() 39 | System.exit 0 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/expression/DemoMethodDispatch.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.expression 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | import static groovyx.gpars.dataflow.Dataflow.task 21 | 22 | /** 23 | * Illustrates the capabilities of DataflowVariables to represent the values they hold. 24 | * When calling a method on a DataflowVariable, the method gets dispatched to the value bound to the variable, 25 | * potentially waiting till a value gets assigned. 26 | */ 27 | 28 | def name = new DataflowVariable() 29 | task { 30 | name << ' adam ' 31 | } 32 | println name.toUpperCase().trim().val -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/operators/chaining/DemoOperatorChaining.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.operators.chaining 18 | 19 | import groovyx.gpars.dataflow.DataflowQueue 20 | 21 | /** 22 | * The chainWith() method available on all channels allows you to build pipe-lines off the original channel. 23 | * The type of the channel gets preserved across the whole chain. 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | 28 | final DataflowQueue queue = new DataflowQueue() 29 | queue.chainWith {it * 2}.chainWith {it + 1} chainWith {println it} 30 | 31 | queue << 1 32 | queue << 2 33 | queue << 3 34 | queue << 4 35 | queue << 5 36 | 37 | sleep 1000 38 | 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/operators/chaining/DemoOperatorChainingOnDFV.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.operators.chaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * The chainWith() method available on all channels allows you to build pipe-lines off the original channel. 23 | * The type of the channel gets preserved across the whole chain - a DataflowVariable in this case. 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | 28 | final DataflowVariable variable = new DataflowVariable() 29 | variable.chainWith {it * 2}.chainWith {it + 1} chainWith {println it} 30 | 31 | variable << 1 32 | 33 | sleep 1000 -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/operators/chaining/DemoOperatorChainingOnSyncDFV.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.operators.chaining 18 | 19 | import groovyx.gpars.dataflow.SyncDataflowVariable 20 | 21 | /** 22 | * The chainWith() method available on all channels allows you to build pipe-lines off the original channel. 23 | * The type of the channel gets preserved across the whole chain - a DataflowVariable in this case. 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | 28 | final SyncDataflowVariable variable = new SyncDataflowVariable() 29 | final result = variable.chainWith {it * 2}.chainWith {it + 1} chainWith {it * 100} 30 | 31 | Thread.start { 32 | println result.val 33 | } 34 | 35 | variable << 1 36 | 37 | sleep 1000 -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/operators/chaining/DemoOperatorChainingUsingOr.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.operators.chaining 18 | 19 | import groovyx.gpars.dataflow.DataflowQueue 20 | 21 | /** 22 | * The | operator can be used as a replacement for the chainWith() method and allows you to build pipe-lines off the original channel. 23 | * The type of the channel gets preserved across the whole chain. 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | 28 | final DataflowQueue queue = new DataflowQueue() 29 | queue | {it * 2} | {it + 1} | {println it} 30 | 31 | queue << 1 32 | queue << 2 33 | queue << 3 34 | queue << 4 35 | queue << 5 36 | 37 | sleep 1000 38 | 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/operators/chaining/DemoOperatorSharedChaining.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.operators.chaining 18 | 19 | import groovyx.gpars.dataflow.DataflowQueue 20 | 21 | /** 22 | * When creating multiple chains on a single channel, they will compete for messages - each message arriving through the channel 23 | * will be passed to exactly one chain. 24 | * 25 | * @author Vaclav Pech 26 | */ 27 | 28 | final DataflowQueue queue = new DataflowQueue() 29 | queue.chainWith {it * 2}.chainWith {it + 1} chainWith {println it} 30 | queue.chainWith {it * 1000}.chainWith {it + 1} chainWith {println it} 31 | 32 | queue << 1 33 | queue << 2 34 | queue << 3 35 | queue << 4 36 | queue << 5 37 | 38 | sleep 1000 -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/DemoNumbers.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import groovyx.gpars.dataflow.DataflowQueue 21 | import groovyx.gpars.group.DefaultPGroup 22 | 23 | group = new DefaultPGroup(6) 24 | 25 | def numbers(DataflowChannel out) { 26 | group.task { 27 | def a = new DataflowQueue() 28 | def b = new DataflowQueue() 29 | def c = new DataflowQueue() 30 | group.task new Prefix(c, a, 0) 31 | group.task new Copy(a, b, out) 32 | group.task new Successor(b, c) 33 | } 34 | } 35 | 36 | final DataflowQueue ch = new DataflowQueue() 37 | group.task new Print('Numbers', ch) 38 | numbers(ch) 39 | 40 | sleep 10000 -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/Plus.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class Plus implements Callable { 23 | private final DataflowChannel inChannel1 24 | private final DataflowChannel inChannel2 25 | private final DataflowChannel outChannel 26 | 27 | def Plus(final inChannel1, final inChannel2, final outChannel) { 28 | this.inChannel1 = inChannel1; 29 | this.inChannel2 = inChannel2; 30 | this.outChannel = outChannel; 31 | } 32 | 33 | public def call() { 34 | while (true) { 35 | outChannel << (inChannel1.val + inChannel2.val) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/Prefix.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class Prefix implements Callable { 23 | private final DataflowChannel inChannel 24 | private final DataflowChannel outChannel 25 | private final def prefix 26 | 27 | def Prefix(final inChannel, final outChannel, final prefix) { 28 | this.inChannel = inChannel; 29 | this.outChannel = outChannel; 30 | this.prefix = prefix 31 | } 32 | 33 | public def call() { 34 | outChannel << prefix 35 | while (true) { 36 | sleep 200 37 | outChannel << inChannel.val 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/Print.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class Print implements Callable { 23 | private final String heading 24 | private final DataflowChannel inChannel 25 | private final long delay = 200 26 | 27 | def Print(final heading = "No Heading Provided", final inChannel) { 28 | this.heading = heading; 29 | this.inChannel = inChannel; 30 | } 31 | 32 | public def call() { 33 | println "${heading}" 34 | while (true) { 35 | println inChannel.val.toString() 36 | sleep(delay) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/StatePairs.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class StatePairs implements Callable { 23 | private final DataflowChannel inChannel 24 | private final DataflowChannel outChannel 25 | 26 | def StatePairs(final inChannel, final outChannel) { 27 | this.inChannel = inChannel; 28 | this.outChannel = outChannel; 29 | } 30 | 31 | public def call() { 32 | def n1 = inChannel.val 33 | def n2 = inChannel.val 34 | while (true) { 35 | outChannel << (n1 + n2) 36 | n1 = n2 37 | n2 = inChannel.val 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/Successor.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class Successor implements Callable { 23 | private final DataflowChannel inChannel 24 | private final DataflowChannel outChannel 25 | 26 | def Successor(final inChannel, final outChannel) { 27 | this.inChannel = inChannel; 28 | this.outChannel = outChannel; 29 | } 30 | 31 | public def call() { 32 | while (true) { 33 | outChannel << inChannel.val + 1 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/process/Tail.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.process 18 | 19 | import groovyx.gpars.dataflow.DataflowChannel 20 | import java.util.concurrent.Callable 21 | 22 | final class Tail implements Callable { 23 | private final DataflowChannel inChannel 24 | private final DataflowChannel outChannel 25 | 26 | def Tail(final inChannel, final outChannel) { 27 | this.inChannel = inChannel; 28 | this.outChannel = outChannel; 29 | } 30 | 31 | public def call() { 32 | inChannel.val 33 | while (true) { 34 | outChannel << inChannel.val 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoAsyncDownload.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-2012 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import static groovyx.gpars.dataflow.Dataflow.task 20 | 21 | /** 22 | * Chains asynchronous actions and correctly handles potential errors. 23 | */ 24 | 25 | task { 26 | 'gpars.codehaus.org'.toURL().text //should throw MalformedURLException 27 | } 28 | .then { page -> page.toUpperCase() } 29 | .then { page -> page.contains('GROOVY') } 30 | .then({ mentionsGroovy -> println "Groovy found: $mentionsGroovy" }, { error -> println "Error: $error" }).join() 31 | 32 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingActiveObjectsAsFunctions.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple calls to active objects' active methods as if they were plain functions. 23 | */ 24 | 25 | final DataflowVariable result = new DataflowVariable() 26 | final DataflowVariable variable = new DataflowVariable() 27 | final calculator = new ActiveDemoCalculator() 28 | 29 | variable.then calculator.&doubler then calculator.&adder then {result << it} 30 | 31 | Thread.start {variable << 4} 32 | assert 9 == result.val 33 | 34 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingActiveObjectsWithRightShift.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple calls to active objects' active methods. 23 | */ 24 | 25 | final DataflowVariable result = new DataflowVariable() 26 | final calculator = new ActiveDemoCalculator() 27 | calculator.doubler(4) >> {calculator.adder it} >> {result << it} 28 | assert 9 == result.val 29 | 30 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingAndForkingFunctions.groovy.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple functions. 23 | * Multiple handlers can be hooked on the same promise. 24 | */ 25 | 26 | final DataflowVariable variable = new DataflowVariable() 27 | 28 | final doubler = {it * 2} 29 | final inc = {it + 1} 30 | final dec = {it - 1} 31 | 32 | final doubled = variable.then doubler 33 | doubled.then inc then this.&println 34 | doubled.then dec then this.&println 35 | 36 | Thread.start {variable << 4} 37 | 38 | sleep 1000 39 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingClosures.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple closures. 23 | */ 24 | 25 | final DataflowVariable variable = new DataflowVariable() 26 | final DataflowVariable result = new DataflowVariable() 27 | 28 | variable.then {it * 2} then {it + 1} then {result << it} 29 | variable << 4 30 | assert 9 == result.val -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingFunctions.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple functions. 23 | */ 24 | 25 | final DataflowVariable variable = new DataflowVariable() 26 | final DataflowVariable result = new DataflowVariable() 27 | 28 | final doubler = {it * 2} 29 | final adder = {it + 1} 30 | 31 | variable.then doubler then adder then {result << it} 32 | 33 | Thread.start {variable << 4} 34 | 35 | assert 9 == result.val 36 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/dataflow/thenChaining/DemoChainingFunctionsWithRightShift.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.dataflow.thenChaining 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | 21 | /** 22 | * Uses the Promise.then() method to chain multiple functions. 23 | */ 24 | 25 | final DataflowVariable variable = new DataflowVariable() 26 | final DataflowVariable result = new DataflowVariable() 27 | 28 | final doubler = {it * 2} 29 | final adder = {it + 1} 30 | 31 | variable >> doubler >> adder >> {result << it} 32 | 33 | Thread.start {variable << 4} 34 | 35 | assert 9 == result.val 36 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/forkjoin/DemoForkJoinFib.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.forkjoin 18 | 19 | import groovyx.gpars.GParsPool 20 | import static groovyx.gpars.GParsPool.withPool 21 | 22 | /** 23 | * The simplest possible parallel implementation of naive recursive Fibonacci number calculator 24 | */ 25 | 26 | withPool { 27 | println GParsPool.runForkJoin(30) {n -> 28 | if (n <= 2) return 1 29 | forkOffChild(n - 2) 30 | forkOffChild(n - 1) 31 | getChildrenResults().sum() 32 | } 33 | } -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/actor/calculator/RemoteCalculatorAnswer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.actor.calculator 18 | 19 | import groovyx.gpars.actor.Actors 20 | import groovyx.gpars.actor.remote.RemoteActors 21 | 22 | def HOST = "localhost" 23 | def PORT = 9000 24 | 25 | def remoteActors = RemoteActors.create() 26 | remoteActors.startServer HOST, PORT 27 | 28 | def answerActor = Actors.actor { 29 | println "Remote Calculator - Answer" 30 | 31 | remoteActors.publish delegate, "remote-calculator" 32 | 33 | react { a-> 34 | react { b-> 35 | reply a + b 36 | } 37 | } 38 | } 39 | 40 | answerActor.join() 41 | 42 | remoteActors.stopServer() 43 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/actor/calculator/RemoteCalculatorQuery.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.actor.calculator 18 | 19 | import groovyx.gpars.actor.Actors 20 | import groovyx.gpars.actor.remote.RemoteActors 21 | 22 | def HOST = "localhost" 23 | def PORT = 9000 24 | 25 | def remoteActors = RemoteActors.create() 26 | 27 | def queryActor = Actors.actor { 28 | println "Remote Calculator - Query" 29 | 30 | def remoteCalculator = remoteActors.get HOST, PORT, "remote-calculator" get() 31 | 32 | remoteCalculator << 1 33 | remoteCalculator << 2 34 | 35 | react { println it } 36 | } 37 | 38 | queryActor.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/actor/chat/ChatMessage.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.actor.chat 18 | 19 | class ChatMessage implements Serializable { 20 | String action 21 | String sender 22 | Object message 23 | } 24 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/actor/chat/ChatServer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.actor.chat 18 | 19 | import groovyx.gpars.actor.remote.RemoteActors 20 | 21 | def HOST = "localhost" 22 | def PORT = 9000 23 | 24 | def remoteActors = RemoteActors.create() 25 | remoteActors.startServer HOST, PORT 26 | 27 | println "Chat server" 28 | 29 | server = new ChatServerActor() 30 | server.start() 31 | 32 | remoteActors.publish server, "chat-server" 33 | 34 | server.join() 35 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/actor/pingpong/RemotePong.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.actor.pingpong 18 | 19 | import groovyx.gpars.actor.Actors 20 | import groovyx.gpars.actor.remote.RemoteActors 21 | 22 | def HOST = "localhost" 23 | def PORT = 9000 24 | 25 | def pongActor = Actors.actor { 26 | println "Pong Actor" 27 | 28 | // handle incoming messages 29 | loop { 30 | react { 31 | println it 32 | reply "PONG" 33 | } 34 | } 35 | } 36 | 37 | def remoteActors = RemoteActors.create() 38 | remoteActors.startServer HOST, PORT 39 | 40 | // publish pongActor as a remote actor 41 | remoteActors.publish pongActor, "pong" 42 | 43 | pongActor.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/agent/ExampleClient.groovy: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.samples.remote.agent 2 | 3 | import groovyx.gpars.agent.remote.AgentClosureExecutionPolicy 4 | import groovyx.gpars.agent.remote.RemoteAgents 5 | 6 | println "Remote Agent - remote" 7 | 8 | def HOST = "localhost" 9 | def PORT = 9577 10 | 11 | def remoteAgents = RemoteAgents.create() 12 | 13 | def remoteAgent = remoteAgents.get HOST, PORT, "agent" get() 14 | remoteAgent.executionPolicy = AgentClosureExecutionPolicy.LOCAL 15 | 16 | println "Agent value: ${remoteAgent.val}" 17 | 18 | def x = "local-value" 19 | 20 | remoteAgent << { 21 | println "updating..." 22 | updateValue x 23 | } 24 | sleep 500 25 | 26 | println "Agent value: ${remoteAgent.val}" 27 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/agent/ExampleServer.groovy: -------------------------------------------------------------------------------- 1 | package groovyx.gpars.samples.remote.agent 2 | 3 | import groovyx.gpars.agent.Agent 4 | import groovyx.gpars.agent.remote.RemoteAgents 5 | 6 | println "Remote Agent - local" 7 | 8 | def HOST = "localhost" 9 | def PORT = 9577 10 | 11 | def remoteAgents = RemoteAgents.create() 12 | remoteAgents.startServer HOST, PORT 13 | 14 | def agent = new Agent("state") 15 | remoteAgents.publish agent, "agent" 16 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/broadcast/ExampleBroadcastClient.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.broadcast 18 | 19 | import groovyx.gpars.dataflow.remote.RemoteDataflows 20 | 21 | def HOST = "localhost" 22 | def PORT = 9101 23 | 24 | println "Example: DataflowBroadcast" 25 | 26 | def remoteDataflows = RemoteDataflows.create() 27 | 28 | def streamPromise = remoteDataflows.getReadChannel HOST, PORT, "broadcast" 29 | def stream = streamPromise.get() 30 | 31 | println "Value from stream: ${stream.val}" 32 | println "Value from stream: ${stream.val}" 33 | println "Value from stream: ${stream.val}" -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/broadcast/ExampleBroadcastServer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.broadcast 18 | 19 | import groovyx.gpars.dataflow.DataflowBroadcast 20 | import groovyx.gpars.dataflow.remote.RemoteDataflows 21 | 22 | def HOST = "localhost" 23 | def PORT = 9101 24 | 25 | println "Example: DataflowBroadcast" 26 | 27 | def remoteDataflows = RemoteDataflows.create() 28 | remoteDataflows.startServer HOST, PORT 29 | 30 | def broadcastStream = new DataflowBroadcast() 31 | 32 | remoteDataflows.publish broadcastStream, "broadcast" 33 | 34 | println "Waiting..." 35 | sleep 10000 36 | println "Sending..." 37 | broadcastStream << "Message 1" 38 | broadcastStream << "Message 2" 39 | broadcastStream << "Message 3" -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/queue/ExampleQueueClient.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.queue 18 | 19 | import groovyx.gpars.dataflow.remote.RemoteDataflows 20 | 21 | def HOST = "localhost" 22 | def PORT = 9101 23 | 24 | println "Example: DataflowQueue" 25 | 26 | def remoteDataflows = RemoteDataflows.create() 27 | def stream = remoteDataflows.getDataflowQueue HOST, PORT, "queue" get() 28 | 29 | println stream.val 30 | println stream.val 31 | stream << "xyz" 32 | println stream.val 33 | println stream.val -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/queue/ExampleQueueServer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.queue 18 | 19 | import groovyx.gpars.dataflow.DataflowQueue 20 | import groovyx.gpars.dataflow.remote.RemoteDataflows 21 | 22 | def HOST = "localhost" 23 | def PORT = 9101 24 | 25 | println "Example: DataflowQueue" 26 | 27 | def remoteDataflows = RemoteDataflows.create() 28 | remoteDataflows.startServer HOST, PORT 29 | 30 | def queue = new DataflowQueue() 31 | 32 | remoteDataflows.publish queue, "queue" 33 | 34 | println "Waiting..." 35 | sleep 10000 36 | println "Sending..." 37 | queue << "a" 38 | queue << "b" 39 | queue << "c" 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/queuebalancer/Consumer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.queuebalancer 18 | 19 | import groovyx.gpars.dataflow.remote.RemoteDataflows 20 | 21 | def HOST = "localhost" 22 | def PORT = 9111 23 | 24 | println "Example: DataflowQueue load balancer" 25 | 26 | def remoteDataflows = RemoteDataflows.create() 27 | def stream = remoteDataflows.getDataflowQueue HOST, PORT, "queue-balancer" get() 28 | 29 | def processedTasks = 0 30 | 31 | while (true) { 32 | def task = stream.val 33 | processedTasks += 1 34 | println "#tasks: ${processedTasks}, last-task: ${task}" 35 | } 36 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/variable/ExampleVariableClient.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.variable 18 | 19 | import groovyx.gpars.dataflow.remote.RemoteDataflows 20 | 21 | def HOST = "localhost" 22 | def PORT = 9009 23 | 24 | println "Example: DataflowVariable" 25 | 26 | def remoteDataflows = RemoteDataflows.create() 27 | 28 | def var1Promise = remoteDataflows.getVariable HOST, PORT, "variabledemo-var-GPars" 29 | def var2Promise = remoteDataflows.getVariable HOST, PORT, "variabledemo-var-Dataflows" 30 | 31 | def var1 = var1Promise.get() 32 | def var2 = var2Promise.get() 33 | 34 | println "${var1.val} supports ${var2.val}" 35 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/remote/dataflow/variable/ExampleVariableServer.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2014 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.remote.dataflow.variable 18 | 19 | import groovyx.gpars.dataflow.DataflowVariable 20 | import groovyx.gpars.dataflow.remote.RemoteDataflows 21 | 22 | def HOST = "localhost" 23 | def PORT = 9009 24 | 25 | println "Example: DataflowVariable" 26 | 27 | def remoteDataflows = RemoteDataflows.create() 28 | remoteDataflows.startServer HOST, PORT 29 | 30 | def var1 = new DataflowVariable() 31 | def var2 = new DataflowVariable() 32 | 33 | remoteDataflows.publish var1, "variabledemo-var-GPars" 34 | remoteDataflows.publish var2, "variabledemo-var-Dataflows" 35 | 36 | println "Before bind" 37 | sleep 10000 38 | var1 << "GPars" 39 | var2 << "Remote Dataflows" 40 | println "After bind" 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_0_3.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | import groovyx.gpars.actor.Actors 20 | 21 | /** 22 | * @author Jan Novotný 23 | */ 24 | 25 | def decryptor = Actors.actor { 26 | react {message -> 27 | reply message.reverse() 28 | // sender.send message.reverse() //An alternative way to send replies 29 | } 30 | } 31 | 32 | def console = Actors.actor { //This actor will print out decrypted messages, since the replies are forwarded to it 33 | react { 34 | println 'Decrypted message: ' + it 35 | } 36 | } 37 | 38 | decryptor.send 'lellarap si yvoorG', console //Specify an actor to send replies to 39 | console.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_0_8.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | import groovyx.gpars.actor.Actor 20 | import groovyx.gpars.actor.Actors 21 | 22 | /** 23 | * @author Jan Novotný 24 | */ 25 | 26 | final Actor actor = Actors.actor { 27 | def candidates = [] 28 | def printResult = {-> println "The best offer is ${candidates.max()}"} 29 | 30 | loop(3, printResult) { 31 | react { 32 | candidates << it 33 | } 34 | } 35 | } 36 | 37 | actor 10 38 | actor 30 39 | actor 20 40 | actor.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_0_9.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | import groovyx.gpars.actor.Actor 20 | import groovyx.gpars.actor.Actors 21 | 22 | /** 23 | * @author Jan Novotný 24 | */ 25 | 26 | final Actor actor = Actors.actor { 27 | def candidates = [] 28 | final Closure printResult = {-> println "Reached best offer - ${candidates.max()}"} 29 | 30 | loop({-> candidates.max() < 30}, printResult) { 31 | react { 32 | candidates << it 33 | } 34 | } 35 | } 36 | 37 | actor 10 38 | actor 20 39 | actor 25 40 | actor 31 41 | actor 20 42 | actor.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_1_1.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | 23 | import static groovyx.gpars.actor.Actors.actor 24 | 25 | final def decryptor = actor { 26 | loop { 27 | react {String message -> 28 | reply message.reverse() 29 | } 30 | } 31 | } 32 | 33 | def console = actor { 34 | decryptor.send 'lellarap si yvoorG' 35 | react { 36 | println 'Decrypted message: ' + it 37 | } 38 | } 39 | 40 | console.join() 41 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_1_4.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | 23 | import groovyx.gpars.group.DefaultPGroup 24 | 25 | //not necessary, just showing that a single-threaded pool can still handle multiple actors 26 | def group = new DefaultPGroup(1); 27 | 28 | final def console = group.actor { 29 | loop { 30 | react { 31 | println 'Result: ' + it 32 | } 33 | } 34 | } 35 | 36 | final def calculator = group.actor { 37 | react {a -> 38 | react {b -> 39 | console.send(a + b) 40 | } 41 | } 42 | } 43 | 44 | calculator.send 2 45 | calculator.send 3 46 | 47 | calculator.join() 48 | group.shutdown() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_2_2.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | 23 | import groovyx.gpars.actor.Actor 24 | import groovyx.gpars.actor.Actors 25 | import groovyx.gpars.actor.DynamicDispatchActor 26 | 27 | final Actor myActor = new DynamicDispatchActor().become { 28 | when {String msg -> println 'A String'; reply 'Thanks'} 29 | when {Double msg -> println 'A Double'; reply 'Thanks'} 30 | when {msg -> println 'A something ...'; reply 'What was that?'; stop()} 31 | } 32 | myActor.start() 33 | Actors.actor { 34 | myActor 'Hello' 35 | myActor 1.0d 36 | myActor 10 as BigDecimal 37 | myActor.join() 38 | }.join() 39 | 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_2_4.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-11 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | 23 | import groovyx.gpars.group.DefaultPGroup 24 | 25 | final def group = new DefaultPGroup(4) 26 | 27 | final def doubler = group.reactor { 28 | 2 * it 29 | } 30 | 31 | group.actor { 32 | println 'Double of 10 = ' + doubler.sendAndWait(10) 33 | } 34 | 35 | group.actor { 36 | println 'Double of 20 = ' + doubler.sendAndWait(20) 37 | } 38 | 39 | group.actor { 40 | println 'Double of 30 = ' + doubler.sendAndWait(30) 41 | } 42 | 43 | for (i in (1..10)) { 44 | println "Double of $i = ${doubler.sendAndWait(i)}" 45 | } 46 | 47 | doubler.stop() 48 | doubler.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_2_5.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | /** 20 | * @author Vaclav Pech 21 | */ 22 | 23 | import groovyx.gpars.actor.Actor 24 | import groovyx.gpars.actor.Actors 25 | 26 | final def doubler = Actors.reactor { 27 | 2 * it 28 | } 29 | 30 | Actor actor = Actors.actor { 31 | (1..10).each {doubler << it} 32 | int i = 0 33 | loop { 34 | i += 1 35 | if (i > 10) stop() 36 | else { 37 | react {message -> 38 | println "Double of $i = $message" 39 | } 40 | } 41 | } 42 | } 43 | 44 | actor.join() 45 | doubler.stop() 46 | doubler.join() -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/actor/DemoActor_3_3.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.actor 18 | 19 | import groovyx.gpars.actor.Actor 20 | import groovyx.gpars.actor.Actors 21 | 22 | /** 23 | * @author Vaclav Pech 24 | */ 25 | 26 | Closure handleB = {a -> 27 | react {b -> 28 | println a + b 29 | reply a + b 30 | } 31 | } 32 | 33 | Closure handleA = {-> 34 | react {a -> 35 | handleB(a) 36 | } 37 | } 38 | 39 | Actor demoActor = Actors.actor { 40 | handleA.delegate = delegate 41 | handleB.delegate = delegate 42 | 43 | handleA() 44 | } 45 | 46 | Actors.actor { 47 | demoActor 10 48 | demoActor 20 49 | react { 50 | println "Result: $it" 51 | } 52 | }.join() 53 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/samples/userguide/geting_started/DemoStart_2_1.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.samples.userguide.geting_started 18 | 19 | import static groovyx.gpars.actor.Actors.actor 20 | 21 | def decryptor = actor { 22 | loop { 23 | react {message -> 24 | if (message instanceof String) reply message.reverse() 25 | else stop() 26 | } 27 | } 28 | } 29 | 30 | def console = actor { 31 | decryptor.send 'lellarap si yvoorG' 32 | react { 33 | println 'Decrypted message: ' + it 34 | decryptor.send false 35 | } 36 | } 37 | 38 | [decryptor, console]*.join() 39 | 40 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/util/DefaultMessageQueueTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util 18 | 19 | class DefaultMessageQueueTest extends AbstractMessageQueueTest { 20 | 21 | protected DefaultMessageQueue createMessageQueue() { 22 | return new DefaultMessageQueue() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/util/EnhancedSemaphoreTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util 18 | 19 | import java.util.concurrent.Semaphore 20 | 21 | /** 22 | * 23 | * @author Vaclav Pech 24 | * Date: Jan 15, 2010 25 | */ 26 | class EnhancedSemaphoreTest extends GroovyTestCase { 27 | public void testSemaphore() { 28 | final Semaphore semaphore = new EnhancedSemaphore(3) 29 | semaphore.withSemaphore { 30 | assertFalse semaphore.tryAcquire(3) 31 | assertTrue semaphore.tryAcquire(2) 32 | semaphore.release 2 33 | } 34 | assertTrue semaphore.tryAcquire(3) 35 | semaphore.release 3 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/groovy/groovyx/gpars/util/FQMessageQueueTest.groovy: -------------------------------------------------------------------------------- 1 | // GPars - Groovy Parallel Systems 2 | // 3 | // Copyright © 2008-10 The original author or authors 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package groovyx.gpars.util 18 | 19 | class FQMessageQueueTest extends AbstractMessageQueueTest { 20 | 21 | protected MessageQueue createMessageQueue() { 22 | return new FQMessageQueue() 23 | } 24 | } 25 | --------------------------------------------------------------------------------