From 3828d702d0756b4def757bf7b0c21eb3795fc2d4 Mon Sep 17 00:00:00 2001 From: Petr Chalupa Date: Mon, 13 Aug 2018 21:58:18 +0200 Subject: [PATCH] Finalize release tasks, add documentation for 1.1.0, fix 1.0.5 docs --- .travis.yml | 2 +- CHANGELOG.md | 2 +- LICENSE.txt | 21 - README.md | 14 +- Rakefile | 155 +- docs-source/dataflow.md | 2 +- docs-source/signpost.md | 1 + docs-source/thread_pools.md | 28 +- docs/1.0.5/Atomic.html | 307 - docs/1.0.5/BlockedByManyPromise.html | 148 - docs/1.0.5/BlockedByOnePromise.html | 226 - docs/1.0.5/BlockedByOneTaskPromise.html | 152 - docs/1.0.5/BlockedPromise.html | 303 - docs/1.0.5/Concurrent.html | 3424 --------- .../Concurrent/AbstractThreadLocalVar.html | 473 -- .../ThreadLocalJavaStorage.html | 289 - .../ThreadLocalRubyStorage.html | 309 - docs/1.0.5/Concurrent/Actor.html | 4 +- .../Concurrent/Actor/AbstractContext.html | 4 +- .../Concurrent/Actor/ActorTerminated.html | 4 +- docs/1.0.5/Concurrent/Actor/AdHoc.html | 378 - docs/1.0.5/Concurrent/Actor/Behaviour.html | 4 +- .../Concurrent/Actor/Behaviour/Abstract.html | 4 +- .../Concurrent/Actor/Behaviour/Awaits.html | 4 +- .../Concurrent/Actor/Behaviour/Buffer.html | 4 +- .../Concurrent/Actor/Behaviour/DoContext.html | 349 - .../Actor/Behaviour/ErrorHandling.html | 506 -- .../Behaviour/ErrorOnUnknownMessage.html | 349 - .../Behaviour/ErrorsOnUnknownMessage.html | 4 +- .../Actor/Behaviour/ExecutesContext.html | 4 +- .../Concurrent/Actor/Behaviour/Linking.html | 4 +- .../Concurrent/Actor/Behaviour/Pausing.html | 4 +- .../Actor/Behaviour/RemoveChild.html | 357 - .../Actor/Behaviour/RemovesChild.html | 4 +- .../Actor/Behaviour/RestartAndResets.html | 280 - .../Actor/Behaviour/SetResults.html | 4 +- .../Actor/Behaviour/Supervised.html | 703 -- .../Actor/Behaviour/Supervising.html | 4 +- .../Actor/Behaviour/TerminatesChildren.html | 362 - .../Actor/Behaviour/Termination.html | 4 +- docs/1.0.5/Concurrent/Actor/ClassMethods.html | 262 - docs/1.0.5/Concurrent/Actor/Context.html | 4 +- .../Actor/Context/ClassMethods.html | 377 - .../Concurrent/Actor/ContextDelegations.html | 1024 --- docs/1.0.5/Concurrent/Actor/Core.html | 4 +- .../Actor/DefaultDeadLetterHandler.html | 4 +- docs/1.0.5/Concurrent/Actor/Envelope.html | 4 +- .../Concurrent/Actor/InstanceMethods.html | 1972 ----- .../Concurrent/Actor/InternalDelegations.html | 4 +- .../Concurrent/Actor/PublicDelegations.html | 4 +- docs/1.0.5/Concurrent/Actor/Reference.html | 4 +- .../Concurrent/Actor/RestartingContext.html | 4 +- docs/1.0.5/Concurrent/Actor/Root.html | 4 +- docs/1.0.5/Concurrent/Actor/TypeCheck.html | 4 +- .../Concurrent/Actor/UnknownMessage.html | 4 +- docs/1.0.5/Concurrent/Actor/Utils.html | 4 +- .../Actor/Utils/AbstractWorker.html | 435 -- docs/1.0.5/Concurrent/Actor/Utils/AdHoc.html | 4 +- .../1.0.5/Concurrent/Actor/Utils/AsAdHoc.html | 4 +- .../Concurrent/Actor/Utils/Balancer.html | 4 +- .../Concurrent/Actor/Utils/Broadcast.html | 4 +- docs/1.0.5/Concurrent/Actor/Utils/Pool.html | 4 +- docs/1.0.5/Concurrent/Actress.html | 1006 --- docs/1.0.5/Concurrent/Actress/AdHoc.html | 1389 ---- docs/1.0.5/Concurrent/Actress/Behaviour.html | 127 - .../Actress/Behaviour/Abstract.html | 1723 ----- .../Concurrent/Actress/Behaviour/Buffer.html | 688 -- .../Actress/Behaviour/DoContext.html | 349 - .../Behaviour/ErrorOnUnknownMessage.html | 133 - .../Actress/Behaviour/RemoveChild.html | 357 - .../Actress/Behaviour/Termination.html | 591 -- docs/1.0.5/Concurrent/Actress/Context.html | 1445 ---- .../Actress/Context/ClassMethods.html | 258 - .../Actress/ContextDelegations.html | 854 --- docs/1.0.5/Concurrent/Actress/Core.html | 1936 ----- .../Concurrent/Actress/CoreDelegations.html | 596 -- .../Actress/DefaultDeadLetterHandler.html | 1458 ---- .../Concurrent/Actress/LazyRegister.html | 497 -- docs/1.0.5/Concurrent/Actress/Reference.html | 1409 ---- docs/1.0.5/Concurrent/Actress/Root.html | 1325 ---- docs/1.0.5/Concurrent/Agent.html | 4 +- docs/1.0.5/Concurrent/Agent/Error.html | 4 +- docs/1.0.5/Concurrent/Agent/Rescuer.html | 313 - .../Concurrent/Agent/ValidationError.html | 4 +- docs/1.0.5/Concurrent/Array.html | 4 +- docs/1.0.5/Concurrent/Async.html | 4 +- .../Concurrent/Async/AsyncDelegator.html | 533 -- docs/1.0.5/Concurrent/Atom.html | 4 +- docs/1.0.5/Concurrent/Atomic.html | 199 - docs/1.0.5/Concurrent/AtomicBoolean.html | 4 +- docs/1.0.5/Concurrent/AtomicDirectUpdate.html | 422 -- docs/1.0.5/Concurrent/AtomicFixnum.html | 4 +- .../AtomicNumericCompareAndSetWrapper.html | 296 - docs/1.0.5/Concurrent/AtomicReference.html | 4 +- docs/1.0.5/Concurrent/BlockingRingBuffer.html | 828 --- docs/1.0.5/Concurrent/BufferedChannel.html | 563 -- docs/1.0.5/Concurrent/CAtomic.html | 808 -- docs/1.0.5/Concurrent/CAtomicBoolean.html | 739 -- docs/1.0.5/Concurrent/CAtomicFixnum.html | 732 -- docs/1.0.5/Concurrent/CachedThreadPool.html | 4 +- docs/1.0.5/Concurrent/Cancellation.html | 4 +- docs/1.0.5/Concurrent/Cancellation/Token.html | 4 +- docs/1.0.5/Concurrent/Channel.html | 4 +- .../Channel/BlockingRingBuffer.html | 845 --- docs/1.0.5/Concurrent/Channel/Buffer.html | 4 +- .../1.0.5/Concurrent/Channel/Buffer/Base.html | 4 +- .../Concurrent/Channel/Buffer/Buffered.html | 4 +- .../Concurrent/Channel/Buffer/Dropping.html | 4 +- .../Concurrent/Channel/Buffer/Sliding.html | 4 +- .../Concurrent/Channel/Buffer/Ticker.html | 4 +- .../Concurrent/Channel/Buffer/Timer.html | 4 +- .../Concurrent/Channel/Buffer/Unbuffered.html | 4 +- .../Concurrent/Channel/BufferedChannel.html | 628 -- docs/1.0.5/Concurrent/Channel/Probe.html | 516 -- docs/1.0.5/Concurrent/Channel/RingBuffer.html | 836 --- .../Channel/Selector/AfterClause.html | 4 +- .../Channel/Selector/DefaultClause.html | 4 +- .../Channel/Selector/ErrorClause.html | 4 +- .../Channel/Selector/PutClause.html | 4 +- .../Channel/Selector/TakeClause.html | 4 +- docs/1.0.5/Concurrent/Channel/Tick.html | 4 +- .../Concurrent/Channel/UnbufferedChannel.html | 547 -- .../Concurrent/Channel/ValidationError.html | 4 +- .../Concurrent/Channel/WaitableList.html | 572 -- docs/1.0.5/Concurrent/Collection.html | 131 - .../Collection/CopyOnNotifyObserverSet.html | 4 +- .../Collection/CopyOnWriteObserverSet.html | 4 +- .../JavaNonConcurrentPriorityQueue.html | 4 +- docs/1.0.5/Concurrent/Concern.html | 4 +- .../Concurrent/Concern/Dereferenceable.html | 4 +- docs/1.0.5/Concurrent/Concern/Obligation.html | 4 +- docs/1.0.5/Concurrent/Concern/Observable.html | 4 +- .../Concurrent/ConcurrentUpdateError.html | 4 +- docs/1.0.5/Concurrent/Condition.html | 770 -- docs/1.0.5/Concurrent/Condition/Result.html | 467 -- docs/1.0.5/Concurrent/Configuration.html | 1246 ---- docs/1.0.5/Concurrent/CountDownLatch.html | 4 +- docs/1.0.5/Concurrent/CyclicBarrier.html | 4 +- .../Concurrent/CyclicBarrier/Generation.html | 228 - docs/1.0.5/Concurrent/Delay.html | 4 +- docs/1.0.5/Concurrent/DependencyCounter.html | 274 - docs/1.0.5/Concurrent/Dereferenceable.html | 688 -- docs/1.0.5/Concurrent/Edge.html | 4 +- .../Edge/AtomicMarkableReference.html | 4 +- .../ImmutableArray.html | 4 +- docs/1.0.5/Concurrent/Edge/Channel.html | 550 -- .../Concurrent/Edge/CompletableEvent.html | 304 - .../Concurrent/Edge/CompletableFuture.html | 711 -- docs/1.0.5/Concurrent/Edge/Event.html | 1864 ----- docs/1.0.5/Concurrent/Edge/Future.html | 2546 ------- .../Concurrent/Edge/FutureShortcuts.html | 1749 ----- .../Concurrent/Edge/LockFreeLinkedSet.html | 4 +- .../Edge/LockFreeLinkedSet/Head.html | 4 +- .../Edge/LockFreeLinkedSet/Node.html | 4 +- .../Edge/LockFreeLinkedSet/Tail.html | 4 +- .../Edge/LockFreeLinkedSet/Window.html | 4 +- docs/1.0.5/Concurrent/Edge/LockFreeStack.html | 937 --- .../Concurrent/Edge/LockFreeStack/Empty.html | 358 - .../1.0.5/Concurrent/EnsureNewVisibility.html | 189 - docs/1.0.5/Concurrent/Event.html | 4 +- docs/1.0.5/Concurrent/Exchanger.html | 4 +- docs/1.0.5/Concurrent/Executor.html | 654 -- docs/1.0.5/Concurrent/FixedThreadPool.html | 4 +- docs/1.0.5/Concurrent/Future.html | 4 +- docs/1.0.5/Concurrent/Hash.html | 4 +- docs/1.0.5/Concurrent/IVar.html | 4 +- docs/1.0.5/Concurrent/ImmediateExecutor.html | 4 +- docs/1.0.5/Concurrent/ImmutableStruct.html | 4 +- .../Concurrent/IndirectImmediateExecutor.html | 4 +- docs/1.0.5/Concurrent/JavaAtomic.html | 445 -- docs/1.0.5/Concurrent/JavaAtomicBoolean.html | 769 -- docs/1.0.5/Concurrent/JavaAtomicFixnum.html | 791 -- .../Concurrent/JavaCachedThreadPool.html | 469 -- docs/1.0.5/Concurrent/JavaExecutor.html | 1352 ---- .../1.0.5/Concurrent/JavaFixedThreadPool.html | 638 -- docs/1.0.5/Concurrent/JavaPriorityQueue.html | 1158 --- docs/1.0.5/Concurrent/JavaSemaphore.html | 964 --- .../Concurrent/JavaSingleThreadExecutor.html | 1492 ---- .../Concurrent/JavaThreadPoolExecutor.html | 4 +- docs/1.0.5/Concurrent/LazyReference.html | 426 -- docs/1.0.5/Concurrent/LazyRegister.html | 4 +- docs/1.0.5/Concurrent/LockFreeQueue.html | 548 -- docs/1.0.5/Concurrent/LockFreeQueue/Node.html | 4 +- docs/1.0.5/Concurrent/LockFreeStack.html | 1141 --- .../1.0.5/Concurrent/LockFreeStack/Empty.html | 4 +- docs/1.0.5/Concurrent/LockFreeStack/Node.html | 4 +- docs/1.0.5/Concurrent/Logging.html | 289 - docs/1.0.5/Concurrent/MVar.html | 4 +- docs/1.0.5/Concurrent/Map.html | 4 +- docs/1.0.5/Concurrent/Maybe.html | 4 +- .../Concurrent/MultipleAssignmentError.html | 4 +- docs/1.0.5/Concurrent/MultipleErrors.html | 4 +- docs/1.0.5/Concurrent/MutableStruct.html | 4 +- docs/1.0.5/Concurrent/MutexAtomic.html | 1072 --- docs/1.0.5/Concurrent/MutexAtomicBoolean.html | 821 -- docs/1.0.5/Concurrent/MutexAtomicFixnum.html | 847 --- .../1.0.5/Concurrent/MutexCountDownLatch.html | 553 -- docs/1.0.5/Concurrent/MutexPriorityQueue.html | 1126 --- docs/1.0.5/Concurrent/MutexSemaphore.html | 974 --- docs/1.0.5/Concurrent/OptionsParser.html | 1112 --- docs/1.0.5/Concurrent/PerThreadExecutor.html | 372 - docs/1.0.5/Concurrent/Postable.html | 707 -- docs/1.0.5/Concurrent/PriorityQueue.html | 192 - docs/1.0.5/Concurrent/ProcessingActor.html | 4 +- docs/1.0.5/Concurrent/ProcessorCounter.html | 439 -- docs/1.0.5/Concurrent/Promise.html | 4 +- docs/1.0.5/Concurrent/Promises.html | 4 +- .../Promises/AbstractEventFuture.html | 4 +- .../ThrottleIntegration.html | 4 +- docs/1.0.5/Concurrent/Promises/Channel.html | 4 +- docs/1.0.5/Concurrent/Promises/Event.html | 4 +- .../Concurrent/Promises/FactoryMethods.html | 4 +- .../FactoryMethods/Configuration.html | 4 +- .../FactoryMethods/NewChannelIntegration.html | 4 +- docs/1.0.5/Concurrent/Promises/Future.html | 4 +- .../Promises/Future/ActorIntegration.html | 4 +- .../Future/NewChannelIntegration.html | 4 +- .../Promises/Future/ThrottleIntegration.html | 4 +- .../1.0.5/Concurrent/Promises/Resolvable.html | 4 +- .../Concurrent/Promises/ResolvableEvent.html | 4 +- .../Concurrent/Promises/ResolvableFuture.html | 4 +- docs/1.0.5/Concurrent/RbxAtomic.html | 573 -- docs/1.0.5/Concurrent/ReadWriteLock.html | 4 +- .../Concurrent/ReentrantReadWriteLock.html | 4 +- docs/1.0.5/Concurrent/RingBuffer.html | 826 --- .../Concurrent/RubyCachedThreadPool.html | 1124 --- docs/1.0.5/Concurrent/RubyExecutor.html | 1954 ----- .../1.0.5/Concurrent/RubyFixedThreadPool.html | 1144 --- .../Concurrent/RubySingleThreadExecutor.html | 1868 ----- .../Concurrent/RubyThreadPoolExecutor.html | 2880 ------- .../Concurrent/RubyThreadPoolWorker.html | 694 -- docs/1.0.5/Concurrent/Runnable.html | 518 -- docs/1.0.5/Concurrent/Runnable/Context.html | 370 - docs/1.0.5/Concurrent/SafeTaskExecutor.html | 4 +- docs/1.0.5/Concurrent/ScheduledTask.html | 4 +- docs/1.0.5/Concurrent/Semaphore.html | 4 +- docs/1.0.5/Concurrent/SerialExecutor.html | 615 -- .../1.0.5/Concurrent/SerializedExecution.html | 4 +- .../Concurrent/SerializedExecution/Job.html | 4 +- .../SerializedExecutionDelegator.html | 4 +- docs/1.0.5/Concurrent/SettableStruct.html | 4 +- .../Concurrent/SimpleExecutorService.html | 4 +- .../Concurrent/SingleThreadExecutor.html | 4 +- docs/1.0.5/Concurrent/Stoppable.html | 264 - docs/1.0.5/Concurrent/Supervisor.html | 1531 ---- .../Concurrent/Supervisor/WorkerContext.html | 398 - .../Concurrent/Supervisor/WorkerCounts.html | 398 - docs/1.0.5/Concurrent/Synchronization.html | 4 +- .../Concurrent/Synchronization/Condition.html | 4 +- .../Synchronization/JRubyAttrVolatile.html | 4 +- .../JRubyAttrVolatile/ClassMethods.html | 4 +- .../Concurrent/Synchronization/Lock.html | 4 +- .../Synchronization/LockableObject.html | 602 -- .../Synchronization/MriAttrVolatile.html | 4 +- .../MriAttrVolatile/ClassMethods.html | 4 +- .../Concurrent/Synchronization/Object.html | 4 +- .../Synchronization/RbxAttrVolatile.html | 4 +- .../RbxAttrVolatile/ClassMethods.html | 4 +- .../Synchronization/TruffleAttrVolatile.html | 4 +- .../TruffleAttrVolatile/ClassMethods.html | 4 +- .../TruffleLockableObject.html | 4 +- docs/1.0.5/Concurrent/Synchronized.html | 226 - docs/1.0.5/Concurrent/TVar.html | 4 +- .../Concurrent/ThreadLocalJavaStorage.html | 292 - .../Concurrent/ThreadLocalNewStorage.html | 345 - .../Concurrent/ThreadLocalOldStorage.html | 345 - .../Concurrent/ThreadLocalRubyStorage.html | 292 - .../ThreadLocalSymbolAllocator.html | 202 - docs/1.0.5/Concurrent/ThreadLocalVar.html | 4 +- docs/1.0.5/Concurrent/ThreadPoolExecutor.html | 4 +- .../ThreadSafe/Util/XorShiftRandom.html | 4 +- docs/1.0.5/Concurrent/Throttle.html | 4 +- .../Throttle/PromisesIntegration.html | 4 +- docs/1.0.5/Concurrent/TimerSet.html | 4 +- docs/1.0.5/Concurrent/TimerSet/Task.html | 411 - docs/1.0.5/Concurrent/TimerTask.html | 4 +- docs/1.0.5/Concurrent/Transaction.html | 4 +- .../Concurrent/Transaction/ReadLogEntry.html | 4 +- docs/1.0.5/Concurrent/Tuple.html | 4 +- docs/1.0.5/Concurrent/UnbufferedChannel.html | 485 -- docs/1.0.5/Concurrent/Utility.html | 4 +- docs/1.0.5/Concurrent/WaitableList.html | 517 -- docs/1.0.5/Counter.html | 288 - docs/1.0.5/Event.html | 2238 ------ docs/1.0.5/InnerPromise.html | 242 - docs/1.0.5/ProcessingActor.html | 731 -- docs/1.0.5/_index.html | 4 +- docs/1.0.5/file.CHANGELOG.html | 4 +- docs/1.0.5/file.LICENSE.html | 4 +- docs/1.0.5/file.README.html | 108 +- docs/1.0.5/file.agent.html | 164 - docs/1.0.5/file.async.html | 216 - docs/1.0.5/file.dataflow.html | 259 - docs/1.0.5/file.dataflow_top_stock_calc.html | 167 - docs/1.0.5/file.future.html | 173 - docs/1.0.5/file.promise.html | 204 - docs/1.0.5/file.promises.out.html | 172 +- docs/1.0.5/file.scheduled_task.html | 223 - docs/1.0.5/file.thread_pools.html | 4 +- docs/1.0.5/file.tvar.html | 273 - docs/1.0.5/index.html | 108 +- docs/1.0.5/root/Concurrent.html | 4 +- docs/1.0.5/root/ProcessingActor.html | 732 -- docs/1.0.5/top-level-namespace.html | 4 +- docs/1.1.0/Concurrent.html | 3020 ++++++++ docs/1.1.0/Concurrent/Actor.html | 1302 ++++ .../Concurrent/Actor/AbstractContext.html | 2554 +++++++ .../Concurrent/Actor/ActorTerminated.html} | 307 +- docs/1.1.0/Concurrent/Actor/Behaviour.html | 830 +++ .../Concurrent/Actor/Behaviour/Abstract.html | 2019 +++++ .../Concurrent/Actor/Behaviour/Awaits.html | 248 + .../Concurrent/Actor/Behaviour/Buffer.html | 540 ++ .../Behaviour/ErrorsOnUnknownMessage.html | 248 + .../Actor/Behaviour/ExecutesContext.html | 298 + .../Concurrent/Actor/Behaviour/Linking.html | 553 ++ .../Concurrent/Actor/Behaviour/Pausing.html | 757 ++ .../Actor/Behaviour/RemovesChild.html | 243 + .../Actor/Behaviour/SetResults.html | 414 ++ .../Actor/Behaviour/Supervising.html | 350 + .../Actor/Behaviour/Termination.html | 756 ++ docs/1.1.0/Concurrent/Actor/Context.html | 239 + docs/1.1.0/Concurrent/Actor/Core.html | 2538 +++++++ .../Actor/DefaultDeadLetterHandler.html | 232 + .../Concurrent/Actor}/Envelope.html | 328 +- .../Concurrent/Actor/InternalDelegations.html | 1143 +++ .../Concurrent/Actor/PublicDelegations.html} | 394 +- docs/1.1.0/Concurrent/Actor/Reference.html | 1626 ++++ .../Concurrent/Actor/RestartingContext.html | 239 + docs/1.1.0/Concurrent/Actor/Root.html | 448 ++ .../Concurrent/Actor}/TypeCheck.html | 179 +- .../Concurrent/Actor/UnknownMessage.html | 669 ++ docs/1.1.0/Concurrent/Actor/Utils.html | 137 + docs/1.1.0/Concurrent/Actor/Utils/AdHoc.html | 299 + .../1.1.0/Concurrent/Actor/Utils/AsAdHoc.html | 267 + .../Concurrent/Actor/Utils/Balancer.html | 408 + .../Concurrent/Actor/Utils/Broadcast.html | 414 ++ docs/1.1.0/Concurrent/Actor/Utils/Pool.html | 420 ++ docs/1.1.0/Concurrent/Agent.html | 3768 ++++++++++ docs/1.1.0/Concurrent/Agent/Error.html | 229 + .../Concurrent/Agent/ValidationError.html | 230 + docs/1.1.0/Concurrent/Array.html | 162 + docs/1.1.0/Concurrent/Async.html | 774 ++ docs/1.1.0/Concurrent/Atom.html | 1473 ++++ docs/1.1.0/Concurrent/AtomicBoolean.html | 959 +++ docs/1.1.0/Concurrent/AtomicFixnum.html | 1105 +++ .../Concurrent/AtomicMarkableReference.html | 1268 ++++ docs/1.1.0/Concurrent/AtomicReference.html | 1258 ++++ docs/1.1.0/Concurrent/CachedThreadPool.html | 392 + docs/1.1.0/Concurrent/Cancellation.html | 671 ++ docs/1.1.0/Concurrent/Cancellation/Token.html | 814 ++ docs/1.1.0/Concurrent/Channel.html | 2325 ++++++ docs/1.1.0/Concurrent/Channel/Buffer.html | 135 + .../1.1.0/Concurrent/Channel/Buffer/Base.html | 1399 ++++ .../Concurrent/Channel/Buffer/Buffered.html | 727 ++ .../Concurrent/Channel/Buffer/Dropping.html | 546 ++ .../Concurrent/Channel/Buffer/Sliding.html | 546 ++ .../Concurrent/Channel/Buffer/Ticker.html | 157 + .../Concurrent/Channel/Buffer/Timer.html | 505 ++ .../Concurrent/Channel/Buffer/Unbuffered.html | 1011 +++ .../Channel/Selector/AfterClause.html | 313 + .../Channel/Selector/DefaultClause.html | 286 + .../Channel/Selector/ErrorClause.html | 294 + .../Channel/Selector/PutClause.html | 300 + .../Channel/Selector/TakeClause.html | 296 + docs/1.1.0/Concurrent/Channel/Tick.html | 624 ++ .../Concurrent/Channel/ValidationError.html | 219 + .../Collection}/CopyOnNotifyObserverSet.html | 354 +- .../Collection}/CopyOnWriteObserverSet.html | 325 +- docs/1.1.0/Concurrent/Concern.html | 126 + .../Concurrent/Concern/Dereferenceable.html | 276 + .../Concurrent/Concern}/Obligation.html | 865 +-- .../Concurrent/Concern}/Observable.html | 383 +- .../Concurrent/ConcurrentUpdateError.html | 176 + .../Concurrent/CountDownLatch.html} | 207 +- docs/1.1.0/Concurrent/CyclicBarrier.html | 788 ++ docs/1.1.0/Concurrent/Delay.html | 1738 +++++ docs/1.1.0/Concurrent/Edge.html | 165 + .../Concurrent/Edge/LockFreeLinkedSet.html | 921 +++ .../Edge/LockFreeLinkedSet/Head.html | 234 + .../Edge/LockFreeLinkedSet/Node.html | 698 ++ .../Edge/LockFreeLinkedSet/Tail.html | 301 + .../Edge/LockFreeLinkedSet/Window.html | 497 ++ docs/1.1.0/Concurrent/Event.html | 697 ++ docs/1.1.0/Concurrent/Exchanger.html | 684 ++ docs/1.1.0/Concurrent/FixedThreadPool.html | 412 ++ docs/1.1.0/Concurrent/Future.html | 1326 ++++ docs/1.1.0/Concurrent/Hash.html | 150 + docs/1.1.0/Concurrent/IVar.html | 2378 ++++++ docs/1.1.0/Concurrent/ImmediateExecutor.html | 923 +++ docs/1.1.0/Concurrent/ImmutableStruct.html | 1344 ++++ .../Concurrent/IndirectImmediateExecutor.html | 425 ++ docs/1.1.0/Concurrent/LazyRegister.html | 706 ++ docs/1.1.0/Concurrent/LockFreeQueue/Node.html | 278 + .../1.1.0/Concurrent/LockFreeStack/Empty.html | 209 + .../Concurrent}/LockFreeStack/Node.html | 174 +- docs/1.1.0/Concurrent/MVar.html | 1433 ++++ docs/1.1.0/Concurrent/Map.html | 1799 +++++ docs/1.1.0/Concurrent/Maybe.html | 1215 +++ .../Concurrent/MultipleAssignmentError.html | 361 + docs/1.1.0/Concurrent/MultipleErrors.html | 306 + docs/1.1.0/Concurrent/MutableStruct.html | 1497 ++++ docs/1.1.0/Concurrent/ProcessingActor.html | 1186 +++ docs/1.1.0/Concurrent/Promise.html | 3037 ++++++++ docs/1.1.0/Concurrent/Promises.html | 3043 ++++++++ .../Promises/AbstractEventFuture.html | 2096 ++++++ .../ThrottleIntegration.html | 327 + docs/1.1.0/Concurrent/Promises/Channel.html | 620 ++ docs/1.1.0/Concurrent/Promises/Event.html | 768 ++ .../Concurrent/Promises/FactoryMethods.html | 3191 ++++++++ .../FactoryMethods/Configuration.html | 220 + .../FactoryMethods/NewChannelIntegration.html | 261 + docs/1.1.0/Concurrent/Promises/Future.html | 3756 ++++++++++ .../Promises/Future/ActorIntegration.html | 241 + .../Promises/Future/FlatShortcuts.html | 469 ++ .../Future/NewChannelIntegration.html | 262 + .../Promises/Future/ThrottleIntegration.html | 325 + .../1.1.0/Concurrent/Promises/Resolvable.html | 129 + .../Concurrent/Promises/ResolvableEvent.html | 358 + .../Concurrent/Promises/ResolvableFuture.html | 814 ++ docs/1.1.0/Concurrent/ReInclude.html | 164 + docs/1.1.0/Concurrent/ReadWriteLock.html | 1199 +++ .../Concurrent/ReentrantReadWriteLock.html | 1364 ++++ docs/1.1.0/Concurrent/SafeTaskExecutor.html | 337 + docs/1.1.0/Concurrent/ScheduledTask.html | 1591 ++++ docs/1.1.0/Concurrent/Semaphore.html | 814 ++ .../1.1.0/Concurrent/SerializedExecution.html | 520 ++ .../Concurrent/SerializedExecution/Job.html | 467 ++ .../SerializedExecutionDelegator.html | 388 + docs/1.1.0/Concurrent/Set.html | 162 + docs/1.1.0/Concurrent/SettableStruct.html | 1524 ++++ .../Concurrent/SimpleExecutorService.html | 1196 +++ .../Concurrent/SingleThreadExecutor.html | 1885 +++++ docs/1.1.0/Concurrent/Synchronization.html | 197 + .../Concurrent/Synchronization/Condition.html | 648 ++ .../Synchronization/JRubyAttrVolatile.html | 124 + .../JRubyAttrVolatile/ClassMethods.html | 213 + .../Concurrent/Synchronization/Lock.html | 369 + .../Synchronization/MriAttrVolatile.html | 195 + .../MriAttrVolatile/ClassMethods.html | 207 + .../Concurrent/Synchronization/Object.html | 927 +++ .../Synchronization/RbxAttrVolatile.html | 197 + .../RbxAttrVolatile/ClassMethods.html | 211 + .../TruffleRubyAttrVolatile.html | 193 + .../TruffleRubyAttrVolatile/ClassMethods.html | 215 + docs/1.1.0/Concurrent/TVar.html | 644 ++ docs/1.1.0/Concurrent/ThreadLocalVar.html | 622 ++ docs/1.1.0/Concurrent/ThreadPoolExecutor.html | 3810 ++++++++++ .../ThreadSafe/Util/XorShiftRandom.html | 452 ++ docs/1.1.0/Concurrent/Throttle.html | 1062 +++ .../Throttle/PromisesIntegration.html | 381 + docs/1.1.0/Concurrent/TimerSet.html | 565 ++ docs/1.1.0/Concurrent/TimerTask.html | 1875 +++++ docs/1.1.0/Concurrent/Transaction.html | 801 ++ .../Concurrent/Transaction/ReadLogEntry.html} | 135 +- docs/1.1.0/Concurrent/Tuple.html | 818 ++ docs/1.1.0/Concurrent/Utility.html | 116 + docs/1.1.0/_index.html | 1351 ++++ docs/1.1.0/class_list.html | 51 + docs/1.1.0/css/common.css | 135 + docs/1.1.0/css/full_list.css | 58 + docs/1.1.0/css/style.css | 496 ++ docs/1.1.0/file.CHANGELOG.html | 614 ++ docs/1.1.0/file.LICENSE.html | 101 + docs/1.1.0/file.README.html | 447 ++ docs/1.1.0/file.promises.out.html | 1242 ++++ docs/1.1.0/file.thread_pools.html | 257 + docs/1.1.0/file_list.html | 76 + docs/1.1.0/frames.html | 17 + docs/1.1.0/index.html | 447 ++ docs/1.1.0/js/app.js | 292 + docs/1.1.0/js/full_list.js | 216 + docs/1.1.0/js/jquery.js | 4 + docs/1.1.0/method_list.html | 6587 +++++++++++++++++ docs/1.1.0/top-level-namespace.html | 119 + docs/file.signpost.html | 1 + docs/index.html | 1 + docs/master/Concurrent.html | 303 +- .../Concurrent/Actor/Behaviour/Linking.html | 2 +- .../Concurrent/Actor/Utils/Broadcast.html | 2 +- docs/master/Concurrent/Promises/Channel.html | 57 +- .../FactoryMethods/NewChannelIntegration.html | 35 +- .../Promises/Future/ActorIntegration.html | 31 +- .../Promises/Future/FlatShortcuts.html | 24 +- .../Future/NewChannelIntegration.html | 33 +- docs/master/Concurrent/Set.html | 162 + docs/master/_index.html | 7 + docs/master/class_list.html | 2 +- docs/master/file.CHANGELOG.html | 2 +- docs/master/file.LICENSE.html | 24 +- docs/master/file.README.html | 90 +- docs/master/file.thread_pools.html | 28 +- docs/master/index.html | 90 +- lib-edge/concurrent/edge/promises.rb | 5 +- lib/concurrent/array.rb | 2 - lib/concurrent/dataflow.rb | 1 + lib/concurrent/hash.rb | 3 - lib/concurrent/set.rb | 112 +- support/cross_building.sh | 14 +- 498 files changed, 131159 insertions(+), 98544 deletions(-) delete mode 100644 LICENSE.txt delete mode 100644 docs/1.0.5/Atomic.html delete mode 100644 docs/1.0.5/BlockedByManyPromise.html delete mode 100644 docs/1.0.5/BlockedByOnePromise.html delete mode 100644 docs/1.0.5/BlockedByOneTaskPromise.html delete mode 100644 docs/1.0.5/BlockedPromise.html delete mode 100644 docs/1.0.5/Concurrent.html delete mode 100644 docs/1.0.5/Concurrent/AbstractThreadLocalVar.html delete mode 100644 docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalJavaStorage.html delete mode 100644 docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalRubyStorage.html delete mode 100644 docs/1.0.5/Concurrent/Actor/AdHoc.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/DoContext.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/ErrorHandling.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/ErrorOnUnknownMessage.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/RemoveChild.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/RestartAndResets.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/Supervised.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Behaviour/TerminatesChildren.html delete mode 100644 docs/1.0.5/Concurrent/Actor/ClassMethods.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Context/ClassMethods.html delete mode 100644 docs/1.0.5/Concurrent/Actor/ContextDelegations.html delete mode 100644 docs/1.0.5/Concurrent/Actor/InstanceMethods.html delete mode 100644 docs/1.0.5/Concurrent/Actor/Utils/AbstractWorker.html delete mode 100644 docs/1.0.5/Concurrent/Actress.html delete mode 100644 docs/1.0.5/Concurrent/Actress/AdHoc.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/Abstract.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/Buffer.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/DoContext.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/ErrorOnUnknownMessage.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/RemoveChild.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Behaviour/Termination.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Context.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Context/ClassMethods.html delete mode 100644 docs/1.0.5/Concurrent/Actress/ContextDelegations.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Core.html delete mode 100644 docs/1.0.5/Concurrent/Actress/CoreDelegations.html delete mode 100644 docs/1.0.5/Concurrent/Actress/DefaultDeadLetterHandler.html delete mode 100644 docs/1.0.5/Concurrent/Actress/LazyRegister.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Reference.html delete mode 100644 docs/1.0.5/Concurrent/Actress/Root.html delete mode 100644 docs/1.0.5/Concurrent/Agent/Rescuer.html delete mode 100644 docs/1.0.5/Concurrent/Async/AsyncDelegator.html delete mode 100644 docs/1.0.5/Concurrent/Atomic.html delete mode 100644 docs/1.0.5/Concurrent/AtomicDirectUpdate.html delete mode 100644 docs/1.0.5/Concurrent/AtomicNumericCompareAndSetWrapper.html delete mode 100644 docs/1.0.5/Concurrent/BlockingRingBuffer.html delete mode 100644 docs/1.0.5/Concurrent/BufferedChannel.html delete mode 100644 docs/1.0.5/Concurrent/CAtomic.html delete mode 100644 docs/1.0.5/Concurrent/CAtomicBoolean.html delete mode 100644 docs/1.0.5/Concurrent/CAtomicFixnum.html delete mode 100644 docs/1.0.5/Concurrent/Channel/BlockingRingBuffer.html delete mode 100644 docs/1.0.5/Concurrent/Channel/BufferedChannel.html delete mode 100644 docs/1.0.5/Concurrent/Channel/Probe.html delete mode 100644 docs/1.0.5/Concurrent/Channel/RingBuffer.html delete mode 100644 docs/1.0.5/Concurrent/Channel/UnbufferedChannel.html delete mode 100644 docs/1.0.5/Concurrent/Channel/WaitableList.html delete mode 100644 docs/1.0.5/Concurrent/Collection.html delete mode 100644 docs/1.0.5/Concurrent/Condition.html delete mode 100644 docs/1.0.5/Concurrent/Condition/Result.html delete mode 100644 docs/1.0.5/Concurrent/Configuration.html delete mode 100644 docs/1.0.5/Concurrent/CyclicBarrier/Generation.html delete mode 100644 docs/1.0.5/Concurrent/DependencyCounter.html delete mode 100644 docs/1.0.5/Concurrent/Dereferenceable.html delete mode 100644 docs/1.0.5/Concurrent/Edge/Channel.html delete mode 100644 docs/1.0.5/Concurrent/Edge/CompletableEvent.html delete mode 100644 docs/1.0.5/Concurrent/Edge/CompletableFuture.html delete mode 100644 docs/1.0.5/Concurrent/Edge/Event.html delete mode 100644 docs/1.0.5/Concurrent/Edge/Future.html delete mode 100644 docs/1.0.5/Concurrent/Edge/FutureShortcuts.html delete mode 100644 docs/1.0.5/Concurrent/Edge/LockFreeStack.html delete mode 100644 docs/1.0.5/Concurrent/Edge/LockFreeStack/Empty.html delete mode 100644 docs/1.0.5/Concurrent/EnsureNewVisibility.html delete mode 100644 docs/1.0.5/Concurrent/Executor.html delete mode 100644 docs/1.0.5/Concurrent/JavaAtomic.html delete mode 100644 docs/1.0.5/Concurrent/JavaAtomicBoolean.html delete mode 100644 docs/1.0.5/Concurrent/JavaAtomicFixnum.html delete mode 100644 docs/1.0.5/Concurrent/JavaCachedThreadPool.html delete mode 100644 docs/1.0.5/Concurrent/JavaExecutor.html delete mode 100644 docs/1.0.5/Concurrent/JavaFixedThreadPool.html delete mode 100644 docs/1.0.5/Concurrent/JavaPriorityQueue.html delete mode 100644 docs/1.0.5/Concurrent/JavaSemaphore.html delete mode 100644 docs/1.0.5/Concurrent/JavaSingleThreadExecutor.html delete mode 100644 docs/1.0.5/Concurrent/LazyReference.html delete mode 100644 docs/1.0.5/Concurrent/LockFreeQueue.html delete mode 100644 docs/1.0.5/Concurrent/LockFreeStack.html delete mode 100644 docs/1.0.5/Concurrent/Logging.html delete mode 100644 docs/1.0.5/Concurrent/MutexAtomic.html delete mode 100644 docs/1.0.5/Concurrent/MutexAtomicBoolean.html delete mode 100644 docs/1.0.5/Concurrent/MutexAtomicFixnum.html delete mode 100644 docs/1.0.5/Concurrent/MutexCountDownLatch.html delete mode 100644 docs/1.0.5/Concurrent/MutexPriorityQueue.html delete mode 100644 docs/1.0.5/Concurrent/MutexSemaphore.html delete mode 100644 docs/1.0.5/Concurrent/OptionsParser.html delete mode 100644 docs/1.0.5/Concurrent/PerThreadExecutor.html delete mode 100644 docs/1.0.5/Concurrent/Postable.html delete mode 100644 docs/1.0.5/Concurrent/PriorityQueue.html delete mode 100644 docs/1.0.5/Concurrent/ProcessorCounter.html delete mode 100644 docs/1.0.5/Concurrent/RbxAtomic.html delete mode 100644 docs/1.0.5/Concurrent/RingBuffer.html delete mode 100644 docs/1.0.5/Concurrent/RubyCachedThreadPool.html delete mode 100644 docs/1.0.5/Concurrent/RubyExecutor.html delete mode 100644 docs/1.0.5/Concurrent/RubyFixedThreadPool.html delete mode 100644 docs/1.0.5/Concurrent/RubySingleThreadExecutor.html delete mode 100644 docs/1.0.5/Concurrent/RubyThreadPoolExecutor.html delete mode 100644 docs/1.0.5/Concurrent/RubyThreadPoolWorker.html delete mode 100644 docs/1.0.5/Concurrent/Runnable.html delete mode 100644 docs/1.0.5/Concurrent/Runnable/Context.html delete mode 100644 docs/1.0.5/Concurrent/SerialExecutor.html delete mode 100644 docs/1.0.5/Concurrent/Stoppable.html delete mode 100644 docs/1.0.5/Concurrent/Supervisor.html delete mode 100644 docs/1.0.5/Concurrent/Supervisor/WorkerContext.html delete mode 100644 docs/1.0.5/Concurrent/Supervisor/WorkerCounts.html delete mode 100644 docs/1.0.5/Concurrent/Synchronization/LockableObject.html delete mode 100644 docs/1.0.5/Concurrent/Synchronized.html delete mode 100644 docs/1.0.5/Concurrent/ThreadLocalJavaStorage.html delete mode 100644 docs/1.0.5/Concurrent/ThreadLocalNewStorage.html delete mode 100644 docs/1.0.5/Concurrent/ThreadLocalOldStorage.html delete mode 100644 docs/1.0.5/Concurrent/ThreadLocalRubyStorage.html delete mode 100644 docs/1.0.5/Concurrent/ThreadLocalSymbolAllocator.html delete mode 100644 docs/1.0.5/Concurrent/TimerSet/Task.html delete mode 100644 docs/1.0.5/Concurrent/UnbufferedChannel.html delete mode 100644 docs/1.0.5/Concurrent/WaitableList.html delete mode 100644 docs/1.0.5/Counter.html delete mode 100644 docs/1.0.5/Event.html delete mode 100644 docs/1.0.5/InnerPromise.html delete mode 100644 docs/1.0.5/ProcessingActor.html delete mode 100644 docs/1.0.5/file.agent.html delete mode 100644 docs/1.0.5/file.async.html delete mode 100644 docs/1.0.5/file.dataflow.html delete mode 100644 docs/1.0.5/file.dataflow_top_stock_calc.html delete mode 100644 docs/1.0.5/file.future.html delete mode 100644 docs/1.0.5/file.promise.html delete mode 100644 docs/1.0.5/file.scheduled_task.html delete mode 100644 docs/1.0.5/file.tvar.html delete mode 100644 docs/1.0.5/root/ProcessingActor.html create mode 100644 docs/1.1.0/Concurrent.html create mode 100644 docs/1.1.0/Concurrent/Actor.html create mode 100644 docs/1.1.0/Concurrent/Actor/AbstractContext.html rename docs/{1.0.5/Concurrent/Actress/ActressTerminated.html => 1.1.0/Concurrent/Actor/ActorTerminated.html} (50%) create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Abstract.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Awaits.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Buffer.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/ExecutesContext.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Linking.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Pausing.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/RemovesChild.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/SetResults.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Supervising.html create mode 100644 docs/1.1.0/Concurrent/Actor/Behaviour/Termination.html create mode 100644 docs/1.1.0/Concurrent/Actor/Context.html create mode 100644 docs/1.1.0/Concurrent/Actor/Core.html create mode 100644 docs/1.1.0/Concurrent/Actor/DefaultDeadLetterHandler.html rename docs/{1.0.5/Concurrent/Actress => 1.1.0/Concurrent/Actor}/Envelope.html (57%) create mode 100644 docs/1.1.0/Concurrent/Actor/InternalDelegations.html rename docs/{1.0.5/Concurrent/Actor/CoreDelegations.html => 1.1.0/Concurrent/Actor/PublicDelegations.html} (52%) create mode 100644 docs/1.1.0/Concurrent/Actor/Reference.html create mode 100644 docs/1.1.0/Concurrent/Actor/RestartingContext.html create mode 100644 docs/1.1.0/Concurrent/Actor/Root.html rename docs/{1.0.5/Concurrent/Actress => 1.1.0/Concurrent/Actor}/TypeCheck.html (59%) create mode 100644 docs/1.1.0/Concurrent/Actor/UnknownMessage.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils/AdHoc.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils/AsAdHoc.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils/Balancer.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils/Broadcast.html create mode 100644 docs/1.1.0/Concurrent/Actor/Utils/Pool.html create mode 100644 docs/1.1.0/Concurrent/Agent.html create mode 100644 docs/1.1.0/Concurrent/Agent/Error.html create mode 100644 docs/1.1.0/Concurrent/Agent/ValidationError.html create mode 100644 docs/1.1.0/Concurrent/Array.html create mode 100644 docs/1.1.0/Concurrent/Async.html create mode 100644 docs/1.1.0/Concurrent/Atom.html create mode 100644 docs/1.1.0/Concurrent/AtomicBoolean.html create mode 100644 docs/1.1.0/Concurrent/AtomicFixnum.html create mode 100644 docs/1.1.0/Concurrent/AtomicMarkableReference.html create mode 100644 docs/1.1.0/Concurrent/AtomicReference.html create mode 100644 docs/1.1.0/Concurrent/CachedThreadPool.html create mode 100644 docs/1.1.0/Concurrent/Cancellation.html create mode 100644 docs/1.1.0/Concurrent/Cancellation/Token.html create mode 100644 docs/1.1.0/Concurrent/Channel.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Base.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Buffered.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Dropping.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Sliding.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Ticker.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Timer.html create mode 100644 docs/1.1.0/Concurrent/Channel/Buffer/Unbuffered.html create mode 100644 docs/1.1.0/Concurrent/Channel/Selector/AfterClause.html create mode 100644 docs/1.1.0/Concurrent/Channel/Selector/DefaultClause.html create mode 100644 docs/1.1.0/Concurrent/Channel/Selector/ErrorClause.html create mode 100644 docs/1.1.0/Concurrent/Channel/Selector/PutClause.html create mode 100644 docs/1.1.0/Concurrent/Channel/Selector/TakeClause.html create mode 100644 docs/1.1.0/Concurrent/Channel/Tick.html create mode 100644 docs/1.1.0/Concurrent/Channel/ValidationError.html rename docs/{1.0.5/Concurrent => 1.1.0/Concurrent/Collection}/CopyOnNotifyObserverSet.html (59%) rename docs/{1.0.5/Concurrent => 1.1.0/Concurrent/Collection}/CopyOnWriteObserverSet.html (61%) create mode 100644 docs/1.1.0/Concurrent/Concern.html create mode 100644 docs/1.1.0/Concurrent/Concern/Dereferenceable.html rename docs/{1.0.5/Concurrent => 1.1.0/Concurrent/Concern}/Obligation.html (54%) rename docs/{1.0.5/Concurrent => 1.1.0/Concurrent/Concern}/Observable.html (54%) create mode 100644 docs/1.1.0/Concurrent/ConcurrentUpdateError.html rename docs/{1.0.5/Concurrent/JavaCountDownLatch.html => 1.1.0/Concurrent/CountDownLatch.html} (52%) create mode 100644 docs/1.1.0/Concurrent/CyclicBarrier.html create mode 100644 docs/1.1.0/Concurrent/Delay.html create mode 100644 docs/1.1.0/Concurrent/Edge.html create mode 100644 docs/1.1.0/Concurrent/Edge/LockFreeLinkedSet.html create mode 100644 docs/1.1.0/Concurrent/Edge/LockFreeLinkedSet/Head.html create mode 100644 docs/1.1.0/Concurrent/Edge/LockFreeLinkedSet/Node.html create mode 100644 docs/1.1.0/Concurrent/Edge/LockFreeLinkedSet/Tail.html create mode 100644 docs/1.1.0/Concurrent/Edge/LockFreeLinkedSet/Window.html create mode 100644 docs/1.1.0/Concurrent/Event.html create mode 100644 docs/1.1.0/Concurrent/Exchanger.html create mode 100644 docs/1.1.0/Concurrent/FixedThreadPool.html create mode 100644 docs/1.1.0/Concurrent/Future.html create mode 100644 docs/1.1.0/Concurrent/Hash.html create mode 100644 docs/1.1.0/Concurrent/IVar.html create mode 100644 docs/1.1.0/Concurrent/ImmediateExecutor.html create mode 100644 docs/1.1.0/Concurrent/ImmutableStruct.html create mode 100644 docs/1.1.0/Concurrent/IndirectImmediateExecutor.html create mode 100644 docs/1.1.0/Concurrent/LazyRegister.html create mode 100644 docs/1.1.0/Concurrent/LockFreeQueue/Node.html create mode 100644 docs/1.1.0/Concurrent/LockFreeStack/Empty.html rename docs/{1.0.5/Concurrent/Edge => 1.1.0/Concurrent}/LockFreeStack/Node.html (55%) create mode 100644 docs/1.1.0/Concurrent/MVar.html create mode 100644 docs/1.1.0/Concurrent/Map.html create mode 100644 docs/1.1.0/Concurrent/Maybe.html create mode 100644 docs/1.1.0/Concurrent/MultipleAssignmentError.html create mode 100644 docs/1.1.0/Concurrent/MultipleErrors.html create mode 100644 docs/1.1.0/Concurrent/MutableStruct.html create mode 100644 docs/1.1.0/Concurrent/ProcessingActor.html create mode 100644 docs/1.1.0/Concurrent/Promise.html create mode 100644 docs/1.1.0/Concurrent/Promises.html create mode 100644 docs/1.1.0/Concurrent/Promises/AbstractEventFuture.html create mode 100644 docs/1.1.0/Concurrent/Promises/AbstractEventFuture/ThrottleIntegration.html create mode 100644 docs/1.1.0/Concurrent/Promises/Channel.html create mode 100644 docs/1.1.0/Concurrent/Promises/Event.html create mode 100644 docs/1.1.0/Concurrent/Promises/FactoryMethods.html create mode 100644 docs/1.1.0/Concurrent/Promises/FactoryMethods/Configuration.html create mode 100644 docs/1.1.0/Concurrent/Promises/FactoryMethods/NewChannelIntegration.html create mode 100644 docs/1.1.0/Concurrent/Promises/Future.html create mode 100644 docs/1.1.0/Concurrent/Promises/Future/ActorIntegration.html create mode 100644 docs/1.1.0/Concurrent/Promises/Future/FlatShortcuts.html create mode 100644 docs/1.1.0/Concurrent/Promises/Future/NewChannelIntegration.html create mode 100644 docs/1.1.0/Concurrent/Promises/Future/ThrottleIntegration.html create mode 100644 docs/1.1.0/Concurrent/Promises/Resolvable.html create mode 100644 docs/1.1.0/Concurrent/Promises/ResolvableEvent.html create mode 100644 docs/1.1.0/Concurrent/Promises/ResolvableFuture.html create mode 100644 docs/1.1.0/Concurrent/ReInclude.html create mode 100644 docs/1.1.0/Concurrent/ReadWriteLock.html create mode 100644 docs/1.1.0/Concurrent/ReentrantReadWriteLock.html create mode 100644 docs/1.1.0/Concurrent/SafeTaskExecutor.html create mode 100644 docs/1.1.0/Concurrent/ScheduledTask.html create mode 100644 docs/1.1.0/Concurrent/Semaphore.html create mode 100644 docs/1.1.0/Concurrent/SerializedExecution.html create mode 100644 docs/1.1.0/Concurrent/SerializedExecution/Job.html create mode 100644 docs/1.1.0/Concurrent/SerializedExecutionDelegator.html create mode 100644 docs/1.1.0/Concurrent/Set.html create mode 100644 docs/1.1.0/Concurrent/SettableStruct.html create mode 100644 docs/1.1.0/Concurrent/SimpleExecutorService.html create mode 100644 docs/1.1.0/Concurrent/SingleThreadExecutor.html create mode 100644 docs/1.1.0/Concurrent/Synchronization.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/Condition.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/JRubyAttrVolatile.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/JRubyAttrVolatile/ClassMethods.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/Lock.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/MriAttrVolatile.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/MriAttrVolatile/ClassMethods.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/Object.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/RbxAttrVolatile.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/RbxAttrVolatile/ClassMethods.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/TruffleRubyAttrVolatile.html create mode 100644 docs/1.1.0/Concurrent/Synchronization/TruffleRubyAttrVolatile/ClassMethods.html create mode 100644 docs/1.1.0/Concurrent/TVar.html create mode 100644 docs/1.1.0/Concurrent/ThreadLocalVar.html create mode 100644 docs/1.1.0/Concurrent/ThreadPoolExecutor.html create mode 100644 docs/1.1.0/Concurrent/ThreadSafe/Util/XorShiftRandom.html create mode 100644 docs/1.1.0/Concurrent/Throttle.html create mode 100644 docs/1.1.0/Concurrent/Throttle/PromisesIntegration.html create mode 100644 docs/1.1.0/Concurrent/TimerSet.html create mode 100644 docs/1.1.0/Concurrent/TimerTask.html create mode 100644 docs/1.1.0/Concurrent/Transaction.html rename docs/{1.0.5/Concurrent/Transaction/UndoLogEntry.html => 1.1.0/Concurrent/Transaction/ReadLogEntry.html} (61%) create mode 100644 docs/1.1.0/Concurrent/Tuple.html create mode 100644 docs/1.1.0/Concurrent/Utility.html create mode 100644 docs/1.1.0/_index.html create mode 100644 docs/1.1.0/class_list.html create mode 100644 docs/1.1.0/css/common.css create mode 100644 docs/1.1.0/css/full_list.css create mode 100644 docs/1.1.0/css/style.css create mode 100644 docs/1.1.0/file.CHANGELOG.html create mode 100644 docs/1.1.0/file.LICENSE.html create mode 100644 docs/1.1.0/file.README.html create mode 100644 docs/1.1.0/file.promises.out.html create mode 100644 docs/1.1.0/file.thread_pools.html create mode 100644 docs/1.1.0/file_list.html create mode 100644 docs/1.1.0/frames.html create mode 100644 docs/1.1.0/index.html create mode 100644 docs/1.1.0/js/app.js create mode 100644 docs/1.1.0/js/full_list.js create mode 100644 docs/1.1.0/js/jquery.js create mode 100644 docs/1.1.0/method_list.html create mode 100644 docs/1.1.0/top-level-namespace.html create mode 100644 docs/master/Concurrent/Set.html diff --git a/.travis.yml b/.travis.yml index 79036ed06..2afa73f55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: rvm: 2.5.1 script: - bundle install --with documentation - - bundle exec rake spec:docs_uptodate + - bundle exec rake yard:master:uptodate - name: MRI 2.4.4 rvm: 2.4.4 diff --git a/CHANGELOG.md b/CHANGELOG.md index a1afafcb8..13d02b730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ concurrent-ruby: -* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Promises.html) +* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/1.1.0/Concurrent/Promises.html) are moved from `concurrent-ruby-edge` to `concurrent-ruby` * Add support for TruffleRuby * (#734) Fix Array/Hash/Set construction broken on TruffleRuby diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 47474f192..000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Jerry D'Antonio -- released under the MIT license. - -http://www.opensource.org/licenses/mit-license.php - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.md b/README.md index aef815544..66a494f19 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ We also have a [IRC (gitter)](https://gitter.im/ruby-concurrency/concurrent-ruby Like a Future scheduled for a specific future time. * [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TimerTask.html): A Thread that periodically wakes up to perform work at regular intervals. -* [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html): +* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html): Unified implementation of futures and promises which combines features of previous `Future`, `Promise`, `IVar`, `Event`, `dataflow`, `Delay`, and (partially) `TimerTask` into a single framework. It extensively uses the new synchronization layer to make all the features @@ -186,21 +186,21 @@ Deprecated features are still available and bugs are being fixed, but new featur * ~~[Future](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Future.html): An asynchronous operation that produces a value.~~ Replaced by - [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). - * ~~[Dataflow](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#dataflow-class_method): + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + * ~~[.dataflow](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#dataflow-class_method): Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.~~ Replaced by - [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). * ~~[Promise](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promise.html): Similar to Futures, with more features.~~ Replaced by - [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). * ~~[Delay](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Delay.html) Lazy evaluation of a block yielding an immutable result. Based on Clojure's [delay](https://clojuredocs.org/clojure.core/delay).~~ Replaced by - [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). * ~~[IVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/IVar.html) Similar to a "future" but can be manually assigned once, after which it becomes immutable.~~ Replaced by - [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). + [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html). ### Edge Features diff --git a/Rakefile b/Rakefile index 627023731..3385c3e9e 100644 --- a/Rakefile +++ b/Rakefile @@ -29,10 +29,12 @@ end require 'rake_compiler_dock' namespace :repackage do - desc '- with Windows fat distributions' + desc '* with Windows fat distributions' task :all do Dir.chdir(__dir__) do sh 'bundle package' + # needed only if the jar is built outside of docker + Rake::Task['lib/concurrent/concurrent_ruby.jar'].invoke RakeCompilerDock.exec 'support/cross_building.sh' end end @@ -60,19 +62,19 @@ begin --tag ~notravis ] namespace :spec do - desc '- Configured for ci' + desc '* Configured for ci' RSpec::Core::RakeTask.new(:ci) do |t| t.rspec_opts = [*options].join(' ') end - desc '- test packaged and installed gems instead of local files' - task :installed => :repackage do + desc '* test packaged and installed gems instead of local files' + task :installed do Dir.chdir(__dir__) do sh 'gem install pkg/concurrent-ruby-1.1.0.pre1.gem' sh 'gem install pkg/concurrent-ruby-ext-1.1.0.pre1.gem' if Concurrent.on_cruby? sh 'gem install pkg/concurrent-ruby-edge-0.4.0.pre1.gem' ENV['NO_PATH'] = 'true' - sh 'bundle install' + sh 'bundle update' sh 'bundle exec rake spec:ci' end end @@ -86,6 +88,8 @@ rescue LoadError => e puts 'RSpec is not installed, skipping test task definitions: ' + e.message end +current_yard_version_name = Concurrent::VERSION.split('.')[0..2].join('.') + begin require 'yard' require 'md_ruby_eval' @@ -99,25 +103,45 @@ begin '--title', 'Concurrent Ruby', '--template', 'default', '--template-path', 'yard-template', - '--default-return', 'undocumented',] + '--default-return', 'undocumented'] desc 'Generate YARD Documentation (signpost, master)' task :yard => ['yard:signpost', 'yard:master'] namespace :yard do - desc '- eval markdown files' + desc '* eval markdown files' task :eval_md do Dir.chdir File.join(__dir__, 'docs-source') do sh 'bundle exec md-ruby-eval --auto' end end + task :update_readme do + Dir.chdir __dir__ do + content = File.read(File.join('README.md')). + gsub(/\[([\w ]+)\]\(http:\/\/ruby-concurrency\.github\.io\/concurrent-ruby\/master\/.*\)/) do |_| + case $1 + when 'LockFreeLinkedSet' + "{Concurrent::Edge::#{$1} #{$1}}" + when '.dataflow' + '{Concurrent.dataflow Concurrent.dataflow}' + when 'thread pool' + '{file:thread_pools.md thread pool}' + else + "{Concurrent::#{$1} #{$1}}" + end + end + File.write 'tmp/README.md', content + end + end + define_yard_task = -> name do - desc "- of #{name} into subdir #{name}" + desc "* of #{name} into subdir #{name}" YARD::Rake::YardocTask.new(name) do |yard| yard.options.push( '--output-dir', "docs/#{name}", + '--main', 'tmp/README.md', *common_yard_options) yard.files = ['./lib/**/*.rb', './lib-edge/**/*.rb', @@ -125,17 +149,16 @@ begin '-', 'docs-source/thread_pools.md', 'docs-source/promises.out.md', - 'README.md', - 'LICENSE.txt', + 'LICENSE.md', 'CHANGELOG.md'] end - Rake::Task[name].prerequisites.push 'yard:eval_md' + Rake::Task[name].prerequisites.push 'yard:eval_md', 'yard:update_readme' end - define_yard_task.call(Concurrent::VERSION.split('.')[0..2].join('.')) - define_yard_task.call('master') + define_yard_task.call current_yard_version_name + define_yard_task.call 'master' - desc "- signpost for versions" + desc "* signpost for versions" YARD::Rake::YardocTask.new(:signpost) do |yard| yard.options.push( '--output-dir', 'docs', @@ -143,35 +166,59 @@ begin *common_yard_options) yard.files = ['no-lib'] end - end - namespace :spec do - desc '- ensure that generated documentation is matching the source code' - task :docs_uptodate do - Dir.chdir(__dir__) do - begin - FileUtils.cp_r 'docs', 'docs-copy', verbose: true - Rake::Task[:yard].invoke - sh 'diff -r docs/ docs-copy/' - ensure - FileUtils.rm_rf 'docs-copy', verbose: true + define_uptodate_task = -> name do + namespace name do + desc "** ensure that #{name} generated documentation is matching the source code" + task :uptodate do + Dir.chdir(__dir__) do + begin + FileUtils.cp_r 'docs', 'docs-copy', verbose: true + Rake::Task["yard:#{name}"].invoke + sh 'diff -r docs/ docs-copy/' + ensure + FileUtils.rm_rf 'docs-copy', verbose: true + end + end end end end + + define_uptodate_task.call current_yard_version_name + define_uptodate_task.call 'master' end rescue LoadError => e puts 'YARD is not installed, skipping documentation task definitions: ' + e.message end +desc 'build, test, and publish the gem' +task :release => ['release:checks', 'release:build', 'release:test', 'release:publish'] + namespace :release do # Depends on environment of @pitr-ch - mri_version = '2.4.3' + mri_version = '2.5.1' jruby_version = 'jruby-9.1.17.0' + task :checks => "yard:#{current_yard_version_name}:uptodate" do + Dir.chdir(__dir__) do + begin + STDOUT.puts "Is this a final release build? (Do git checks?) (y/n)" + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + if input == 'y' + sh 'test -z "$(git status --porcelain)"' + sh 'git fetch' + sh 'test $(git show-ref --verify --hash refs/heads/master) = $(git show-ref --verify --hash refs/remotes/github/master)' + end + end + end + + desc '* build all *.gem files necessary for release' task :build => 'repackage:all' + desc '* test actual installed gems instead of cloned repository on MRI and JRuby' task :test do Dir.chdir(__dir__) do old = ENV['RBENV_VERSION'] @@ -190,27 +237,43 @@ namespace :release do end end - task :push do - Dir.chdir(__dir__) do - sh 'git fetch' - sh 'test $(git show-ref --verify --hash refs/heads/master) = $(git show-ref --verify --hash refs/remotes/github/master)' - - sh "git tag v#{Concurrent::VERSION}" - sh "git tag edge-v#{Concurrent::EDGE_VERSION}" - sh "git push github v#{Concurrent::VERSION} edge-v#{Concurrent::EDGE_VERSION}" - - sh "gem push pkg/concurrent-ruby-#{Concurrent::VERSION}.gem" - sh "gem push pkg/concurrent-ruby-edge-#{Concurrent::EDGE_VERSION}.gem" - sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}.gem" - sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x64-mingw32.gem" - sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x86-mingw32.gem" + desc '* do all nested steps' + task :publish => ['publish:ask', 'publish:tag', 'publish:rubygems', 'publish:post_steps'] + + namespace :publish do + task :ask do + begin + STDOUT.puts "Do you want to publish? (y/n)" + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + raise 'reconsidered' if input == 'n' end - end - task :notify do - puts 'Manually: create a release on GitHub with relevant changelog part' - puts 'Manually: send email same as release with relevant changelog part' - puts 'Manually: update documentation' - puts ' $ bundle exec rake yard:push' + desc '** tag HEAD with current version and push to github' + task :tag do + Dir.chdir(__dir__) do + sh "git tag v#{Concurrent::VERSION}" + sh "git tag edge-v#{Concurrent::EDGE_VERSION}" + sh "git push github v#{Concurrent::VERSION} edge-v#{Concurrent::EDGE_VERSION}" + end + end + + desc '** push all *.gem files to rubygems' + task :rubygems do + Dir.chdir(__dir__) do + sh "gem push pkg/concurrent-ruby-#{Concurrent::VERSION}.gem" + sh "gem push pkg/concurrent-ruby-edge-#{Concurrent::EDGE_VERSION}.gem" + sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}.gem" + sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x64-mingw32.gem" + sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x86-mingw32.gem" + end + end + + desc '** print post release steps' + task :post_steps do + puts 'Manually: create a release on GitHub with relevant changelog part' + puts 'Manually: send email same as release with relevant changelog part' + puts 'Manually: tweet' + end end end diff --git a/docs-source/dataflow.md b/docs-source/dataflow.md index 7ffa914dc..a34207ee3 100644 --- a/docs-source/dataflow.md +++ b/docs-source/dataflow.md @@ -1,4 +1,4 @@ -Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available. Data dependencies are `Future` values. The dataflow task itself is also a `Future` value, so you can build up a graph of these tasks, each of which is run when all the data and other tasks it depends on are available or completed. +Data dependencies are `Future` values. The dataflow task itself is also a `Future` value, so you can build up a graph of these tasks, each of which is run when all the data and other tasks it depends on are available or completed. Our syntax is somewhat related to that of Akka's `flow` and Habanero Java's `DataDrivenFuture`. However unlike Akka we don't schedule a task at all until it is ready to run, and unlike Habanero Java we pass the data values into the task instead of dereferencing them again in the task. diff --git a/docs-source/signpost.md b/docs-source/signpost.md index 3cc9282e3..7748b94a4 100644 --- a/docs-source/signpost.md +++ b/docs-source/signpost.md @@ -3,4 +3,5 @@ Pick a version: * [master](./master/index.html) +* [1.1.0.pre1](./1.1.0/index.html) * [1.0.5](./1.0.5/index.html) diff --git a/docs-source/thread_pools.md b/docs-source/thread_pools.md index f9cb74319..8f4ed20fa 100644 --- a/docs-source/thread_pools.md +++ b/docs-source/thread_pools.md @@ -2,7 +2,7 @@ A Thread Pool is an abstraction that you can give a unit of work to, and the work will be executed by one of possibly several threads in the pool. One motivation for using thread pools is the overhead of creating and destroying threads. Creating a pool of reusable worker threads then repeatedly re-using threads from the pool can have huge performance benefits for a long-running application like a service. -`concurrent-ruby` also offers some higher level abstractions than thread pools. For many problems, you will be better served by using one of these -- if you are thinking of using a thread pool, we especially recommend you look at and understand [Future](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Future.html)s before deciding to use thread pools directly instead. Futures are implemented using thread pools, but offer a higher level abstraction. +`concurrent-ruby` also offers some higher level abstractions than thread pools. For many problems, you will be better served by using one of these -- if you are thinking of using a thread pool, we especially recommend you look at and understand {Concurrent::Future}s before deciding to use thread pools directly instead. Futures are implemented using thread pools, but offer a higher level abstraction. But there are some problems for which directly using a thread pool is an appropriate solution. Or, you may wish to make your own thread pool to run Futures on, to be separate or have different characteristics than the global thread pool that Futures run on by default. @@ -10,7 +10,7 @@ Thread pools are considered 'executors' -- an object you can give a unit of work ## FixedThreadPool -A [FixedThreadPool](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/FixedThreadPool.html) contains a fixed number of threads. When you give a unit of work to it, an available thread will be used to execute. +A {Concurrent::FixedThreadPool} contains a fixed number of threads. When you give a unit of work to it, an available thread will be used to execute. ~~~ruby pool = Concurrent::FixedThreadPool.new(5) # 5 threads @@ -29,7 +29,7 @@ The `FixedThreadPool` is based on the semantics used in Java for [java.util.conc ## CachedThreadPool -A [CachedThreadPool](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CachedThreadPool.html) will create as many threads as necessary for work posted to it. If you post work to a `CachedThreadPool` when all its existing threads are busy, it will create a new thread to execute that work, and then keep that thread cached for future work. Cached threads are reclaimed (destroyed) after they are idle for a while. +A {Concurrent::CachedThreadPool} will create as many threads as necessary for work posted to it. If you post work to a `CachedThreadPool` when all its existing threads are busy, it will create a new thread to execute that work, and then keep that thread cached for future work. Cached threads are reclaimed (destroyed) after they are idle for a while. CachedThreadPools typically improve the performance of programs that execute many short-lived asynchronous tasks. @@ -46,7 +46,7 @@ If you'd like to configure a maximum number of threads, you can use the more gen ## ThreadPoolExecutor -A [ThreadPoolExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadPoolExecutor.html) is a general-purpose thread pool that can be configured to have various behaviors. +A {Concurrent::ThreadPoolExecutor} is a general-purpose thread pool that can be configured to have various behaviors. A `ThreadPoolExecutor` will automatically adjust the pool size according to the bounds set by `min-threads` and `max-threads`. When a new task is submitted and fewer than `min-threads` threads are running, a new thread is created to handle the request, even if other worker threads are idle. @@ -130,16 +130,16 @@ The `shutdown?` method will return true for a stopped pool, regardless of whethe There are several other thread pools and executors in the `concurrent-ruby` library. See the API documentation for more information: - * [CachedThreadPool](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CachedThreadPool.html) - * [FixedThreadPool](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/FixedThreadPool.html) - * [ImmediateExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ImmediateExecutor.html) - * [PerThreadExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/PerThreadExecutor.html) - * [SafeTaskExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/SafeTaskExecutor.html) - * [SerializedExecution](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/SerializedExecution.html) - * [SerializedExecutionDelegator](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/SerializedExecutionDelegator.html) - * [SingleThreadExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/SingleThreadExecutor.html) - * [ThreadPoolExecutor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadPoolExecutor.html) - * [TimerSet](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TimerSet.html) + * {Concurrent::CachedThreadPool} + * {Concurrent::FixedThreadPool} + * {Concurrent::ImmediateExecutor} + * {Concurrent::SimpleExecutorService} + * {Concurrent::SafeTaskExecutor} + * {Concurrent::SerializedExecution} + * {Concurrent::SerializedExecutionDelegator} + * {Concurrent::SingleThreadExecutor} + * {Concurrent::ThreadPoolExecutor} + * {Concurrent::TimerSet} ## Global Thread Pools diff --git a/docs/1.0.5/Atomic.html b/docs/1.0.5/Atomic.html deleted file mode 100644 index d101f3553..000000000 --- a/docs/1.0.5/Atomic.html +++ /dev/null @@ -1,307 +0,0 @@ - - - - - - Class: Atomic - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Atomic - - - -

- -
- -
Inherits:
-
- Concurrent::Atomic - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic.rb
- -
-
- -

Overview

-
-

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
- -

Constant Summary

- -
- -
ConcurrentUpdateError = - -
-
Class.new(Concurrent::ConcurrentUpdateError)
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Atomic) initialize(value) - - - - - -

-
-

Creates a new Atomic reference with null initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Object) - - - - — -

    the initial value

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-93
-94
-95
-96
-
-
# File 'lib/concurrent/atomic.rb', line 93
-
-def initialize(value)
-  warn "[DEPRECATED] Please use Concurrent::Atomic instead."
-  super
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/BlockedByManyPromise.html b/docs/1.0.5/BlockedByManyPromise.html deleted file mode 100644 index 7b63d27d3..000000000 --- a/docs/1.0.5/BlockedByManyPromise.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - Class: BlockedByManyPromise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: BlockedByManyPromise - - - -

- -
- -
Inherits:
-
- BlockedPromise - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from BlockedPromise

- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/BlockedByOnePromise.html b/docs/1.0.5/BlockedByOnePromise.html deleted file mode 100644 index 11cc90ce6..000000000 --- a/docs/1.0.5/BlockedByOnePromise.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - Class: BlockedByOnePromise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: BlockedByOnePromise - - - -

- -
- -
Inherits:
-
- BlockedPromise - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- -
-

Direct Known Subclasses

-

BlockedByOneTaskPromise

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - -
-

Constructor Details

- -
-

- - - (BlockedByOnePromise) initialize(blocked_by_future, default_executor = :fast) - - - - - -

-
-

Returns a new instance of BlockedByOnePromise

- - -
-
-
- - -
- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/next2.rb', line 39
-
-def initialize(blocked_by_future, default_executor = :fast)
-  super [blocked_by_future], default_executor
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/BlockedByOneTaskPromise.html b/docs/1.0.5/BlockedByOneTaskPromise.html deleted file mode 100644 index c9b338879..000000000 --- a/docs/1.0.5/BlockedByOneTaskPromise.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - Class: BlockedByOneTaskPromise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: BlockedByOneTaskPromise - - - -

- -
- -
Inherits:
-
- BlockedByOnePromise - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- - - - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from BlockedByOnePromise

- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/BlockedPromise.html b/docs/1.0.5/BlockedPromise.html deleted file mode 100644 index d23ebea19..000000000 --- a/docs/1.0.5/BlockedPromise.html +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - Class: BlockedPromise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: BlockedPromise - - - -

- -
- -
Inherits:
-
- InnerPromise - -
    -
  • Object
  • - - - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- -
-

Direct Known Subclasses

-

BlockedByManyPromise, BlockedByOnePromise

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Constructor Details

- -
-

- - - (BlockedPromise) initialize(blocked_by_futures, default_executor = :fast) - - - - - -

-
-

Returns a new instance of BlockedPromise

- - -
-
-
- - -
- - - - -
-
-
-
-13
-14
-15
-16
-17
-18
-
-
# File 'lib/concurrent/next2.rb', line 13
-
-def initialize(blocked_by_futures, default_executor = :fast)
-  raise if blocked_by_futures.empty?
-  super blocked_by_futures, default_executor
-  synchronize { @countdown = Concurrent::AtomicFixnum.new blocked_by_futures.size }
-  blocked_by_futures.each { |f| f.add_callback :notify_blocked, self }
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) done(future) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-21
-22
-23
-24
-25
-
-
# File 'lib/concurrent/next2.rb', line 21
-
-def done(future) # TODO pass in success/value/reason to avoid locking
-  # futures could be deleted from blocked_by one by one here, but that would too expensive,
-  # it's done once when all are done to free the reference
-  resolvable if synchronize { @countdown }.decrement.zero?
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent.html b/docs/1.0.5/Concurrent.html deleted file mode 100644 index e8642befb..000000000 --- a/docs/1.0.5/Concurrent.html +++ /dev/null @@ -1,3424 +0,0 @@ - - - - - - Module: Concurrent - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent - - - -

- -
- - - -
Extended by:
-
Logging
- - - - - - - -
Defined in:
-
lib/concurrent.rb,
- lib/concurrent/mvar.rb,
lib/concurrent/ivar.rb,
lib/concurrent/tvar.rb,
lib/concurrent/agent.rb,
lib/concurrent/actor.rb,
lib/concurrent/async.rb,
lib/concurrent/delay.rb,
lib/extension_helper.rb,
lib/concurrent/future.rb,
lib/concurrent/errors.rb,
lib/concurrent/logging.rb,
lib/concurrent/promise.rb,
lib/concurrent/version.rb,
lib/concurrent/dataflow.rb,
lib/concurrent/exchanger.rb,
lib/concurrent/observable.rb,
lib/concurrent/actor/core.rb,
lib/concurrent/actor/root.rb,
lib/concurrent/obligation.rb,
lib/concurrent/timer_task.rb,
lib/concurrent/actor/utils.rb,
lib/concurrent/actor/errors.rb,
lib/concurrent/atomic/event.rb,
lib/concurrent/configuration.rb,
lib/concurrent/actor/context.rb,
lib/concurrent/utility/timer.rb,
lib/concurrent/lazy_register.rb,
lib/concurrent/lazy_reference.rb,
lib/concurrent/actor/envelope.rb,
lib/concurrent/scheduled_task.rb,
lib/concurrent/channel/channel.rb,
lib/concurrent/actor/reference.rb,
lib/concurrent/actor/behaviour.rb,
lib/concurrent/dereferenceable.rb,
lib/concurrent/utility/timeout.rb,
lib/concurrent/actor/utils/pool.rb,
lib/concurrent/atomic/semaphore.rb,
lib/concurrent/atomic/condition.rb,
lib/concurrent/actor/type_check.rb,
lib/concurrent/executor/executor.rb,
lib/concurrent/actor/utils/ad_hoc.rb,
lib/concurrent/executor/timer_set.rb,
lib/concurrent/atomic/atomic_fixnum.rb,
lib/concurrent/actor/utils/balancer.rb,
lib/concurrent/atomic_reference/rbx.rb,
lib/concurrent/atomic/cyclic_barrier.rb,
lib/concurrent/atomic_reference/ruby.rb,
lib/concurrent/atomic/atomic_boolean.rb,
lib/concurrent/channel/waitable_list.rb,
lib/concurrent/actor/utils/broadcast.rb,
lib/concurrent/actor/behaviour/buffer.rb,
lib/concurrent/actor/behaviour/awaits.rb,
lib/concurrent/collection/ring_buffer.rb,
lib/concurrent/utility/monotonic_time.rb,
lib/concurrent/atomic/synchronization.rb,
lib/concurrent/atomic/read_write_lock.rb,
lib/concurrent/atomic_reference/jruby.rb,
lib/concurrent/atomic/thread_local_var.rb,
lib/concurrent/actor/behaviour/pausing.rb,
lib/concurrent/actor/behaviour/linking.rb,
lib/concurrent/utility/processor_count.rb,
lib/concurrent/atomic/count_down_latch.rb,
lib/concurrent/channel/buffered_channel.rb,
lib/concurrent/actor/public_delegations.rb,
lib/concurrent/actor/behaviour/abstract.rb,
lib/concurrent/collection/priority_queue.rb,
lib/concurrent/executor/executor_options.rb,
lib/concurrent/actor/behaviour/supervised.rb,
lib/concurrent/executor/fixed_thread_pool.rb,
lib/concurrent/actor/internal_delegations.rb,
lib/concurrent/channel/unbuffered_channel.rb,
lib/concurrent/executor/immediate_executor.rb,
lib/concurrent/executor/cached_thread_pool.rb,
lib/concurrent/actor/behaviour/termination.rb,
lib/concurrent/actor/behaviour/supervising.rb,
lib/concurrent/executor/safe_task_executor.rb,
lib/concurrent/actor/behaviour/sets_results.rb,
lib/concurrent/executor/per_thread_executor.rb,
lib/concurrent/actor/behaviour/removes_child.rb,
lib/concurrent/executor/serialized_execution.rb,
lib/concurrent/atomic_reference/mutex_atomic.rb,
lib/concurrent/executor/thread_pool_executor.rb,
lib/concurrent/atomic_reference/direct_update.rb,
lib/concurrent/executor/java_fixed_thread_pool.rb,
lib/concurrent/executor/ruby_fixed_thread_pool.rb,
lib/concurrent/collection/blocking_ring_buffer.rb,
lib/concurrent/executor/single_thread_executor.rb,
lib/concurrent/executor/ruby_cached_thread_pool.rb,
lib/concurrent/executor/ruby_thread_pool_worker.rb,
lib/concurrent/actor/behaviour/executes_context.rb,
lib/concurrent/executor/java_cached_thread_pool.rb,
lib/concurrent/actor/default_dead_letter_handler.rb,
lib/concurrent/atomic/copy_on_write_observer_set.rb,
lib/concurrent/atomic/copy_on_notify_observer_set.rb,
lib/concurrent/executor/java_thread_pool_executor.rb,
lib/concurrent/executor/ruby_thread_pool_executor.rb,
lib/concurrent/actor/behaviour/terminates_children.rb,
lib/concurrent/atomic_reference/numeric_cas_wrapper.rb,
lib/concurrent/executor/java_single_thread_executor.rb,
lib/concurrent/executor/ruby_single_thread_executor.rb,
lib/concurrent/executor/indirect_immediate_executor.rb,
lib/concurrent/atomic_reference/concurrent_update_error.rb,
lib/concurrent/actor/behaviour/errors_on_unknown_message.rb
-
- -
-
- -

Overview

-
-

Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell, -F#, C#, Java, and classic concurrency patterns.

- -

The design goals of this gem are:

- -
    -
  • Stay true to the spirit of the languages providing inspiration
  • -
  • But implement in a way that makes sense for Ruby
  • -
  • Keep the semantics as idiomatic Ruby as possible
  • -
  • Support features that make sense in Ruby
  • -
  • Exclude features that don't make sense in Ruby
  • -
  • Be small, lean, and loosely coupled
  • -
- - -
-
-
- - -

Defined Under Namespace

-

- - - Modules: Actor, Async, AtomicDirectUpdate, AtomicNumericCompareAndSetWrapper, Channel, Dereferenceable, Executor, JavaExecutor, Logging, Obligation, Observable, RubyExecutor, SerialExecutor, Synchronization - - - - Classes: AbstractThreadLocalVar, Agent, Atomic, AtomicBoolean, AtomicFixnum, BlockingRingBuffer, BufferedChannel, CAtomic, CAtomicBoolean, CAtomicFixnum, CachedThreadPool, ConcurrentUpdateError, Condition, Configuration, CopyOnNotifyObserverSet, CopyOnWriteObserverSet, CountDownLatch, CyclicBarrier, Delay, Event, Exchanger, FixedThreadPool, Future, IVar, ImmediateExecutor, IndirectImmediateExecutor, JavaAtomic, JavaCachedThreadPool, JavaCountDownLatch, JavaFixedThreadPool, JavaPriorityQueue, JavaSingleThreadExecutor, JavaThreadPoolExecutor, LazyReference, LazyRegister, MVar, MutexAtomic, MutexAtomicBoolean, MutexAtomicFixnum, MutexCountDownLatch, MutexPriorityQueue, MutexSemaphore, PerThreadExecutor, PriorityQueue, ProcessorCounter, Promise, RbxAtomic, ReadWriteLock, RingBuffer, RubyCachedThreadPool, RubyFixedThreadPool, RubySingleThreadExecutor, RubyThreadPoolExecutor, SafeTaskExecutor, ScheduledTask, Semaphore, SerializedExecution, SerializedExecutionDelegator, SingleThreadExecutor, TVar, ThreadLocalVar, ThreadPoolExecutor, TimerSet, TimerTask, Transaction, UnbufferedChannel, WaitableList - - -

- -

Constant Summary

- -
- -
ConfigurationError = -
-
-

Raised when errors occur during configuration.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
LifecycleError = -
-
-

Raised when a lifecycle method (such as stop) is called in an improper -sequence or when the object is in an inappropriate state.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
InitializationError = -
-
-

Raised when an object's methods are called when it has not been -properly initialized.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
MaxRestartFrequencyError = -
-
-

Raised when an object with a start/stop lifecycle has been started an -excessive number of times. Often used in conjunction with a restart -policy or strategy.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
MultipleAssignmentError = -
-
-

Raised when an attempt is made to modify an immutable object -(such as an IVar) after its final state has been set.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
RejectedExecutionError = -
-
-

Raised by an Executor when it is unable to process a given task, -possibly because of a reject policy or other internal error.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
ResourceLimitError = -
-
-

Raised when any finite resource, such as a lock counter, exceeds its -maximum limit/threshold.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
TimeoutError = -
-
-

Raised when an operation times out.

- - -
-
-
- - -
-
-
Class.new(StandardError)
- -
PromiseExecutionError = - -
-
Class.new(StandardError)
- -
VERSION = - -
-
'0.8.0'
- -
NULL_LOGGER = -
-
-

Suppresses all output when used for logging.

- - -
-
-
- - -
-
-
lambda { |level, progname, message = nil, &block| }
- -
- - - - - - - - - -

- Class Method Summary - (collapse) -

- - - - - - - - - -
-

Class Method Details

- - -
-

- - + (Object) abort_transaction - - - - - -

-
-

Abort a currently running transaction - see Concurrent::atomically.

- - -
-
-
- -

Raises:

- - -
- - - - -
-
-
-
-143
-144
-145
-
-
# File 'lib/concurrent/tvar.rb', line 143
-
-def abort_transaction
-  raise Transaction::AbortError.new
-end
-
-
- -
-

- - + (Object) atomically - - - - - -

-
-

Run a block that reads and writes TVars as a single atomic transaction. -With respect to the value of TVar objects, the transaction is atomic, in -that it either happens or it does not, consistent, in that the TVar -objects involved will never enter an illegal state, and isolated, in that -transactions never interfere with each other. You may recognise these -properties from database transactions.

- -

There are some very important and unusual semantics that you must be aware of:

- -
    -
  • Most importantly, the block that you pass to atomically may be executed -more than once. In most cases your code should be free of -side-effects, except for via TVar.

  • -
  • If an exception escapes an atomically block it will abort the transaction.

  • -
  • It is undefined behaviour to use callcc or Fiber with atomically.

  • -
  • If you create a new thread within an atomically, it will not be part of -the transaction. Creating a thread counts as a side-effect.

  • -
- -

Transactions within transactions are flattened to a single transaction.

- - -
-
-
- -
-

Examples:

- - -
a = new TVar(100_000)
-b = new TVar(100)
-
-Concurrent::atomically do
-  a.value -= 10
-  b.value += 10
-end
- -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
-101
-102
-103
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-123
-124
-125
-126
-127
-128
-129
-130
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140
-
-
# File 'lib/concurrent/tvar.rb', line 89
-
-def atomically
-  raise ArgumentError.new('no block given') unless block_given?
-
-  # Get the current transaction
-
-  transaction = Transaction::current
-
-  # Are we not already in a transaction (not nested)?
-
-  if transaction.nil?
-    # New transaction
-
-    begin
-      # Retry loop
-
-      loop do
-
-        # Create a new transaction
-
-        transaction = Transaction.new
-        Transaction::current = transaction
-
-        # Run the block, aborting on exceptions
-
-        begin
-          result = yield
-        rescue Transaction::AbortError => e
-          transaction.abort
-          result = Transaction::ABORTED
-        rescue => e
-          transaction.abort
-          raise e
-        end
-        # If we can commit, break out of the loop
-
-        if result != Transaction::ABORTED
-          if transaction.commit
-            break result
-          end
-        end
-      end
-    ensure
-      # Clear the current transaction
-
-      Transaction::current = nil
-    end
-  else
-    # Nested transaction - flatten it and just run the block
-
-    yield
-  end
-end
-
-
- -
-

- - + (Boolean) auto_terminate_all_executors? - - - - - -

-
- -
- Note: -

Only change this option if you know what you are doing! -When this is set to true (the default) then at_exit handlers -will be registered automatically for all thread pools to -ensure that they are shutdown when the application ends. When -changed to false, the at_exit handlers will be circumvented -for all Concurrent Ruby thread pools running within the -application. Even those created within other gems used by the -application. This method should never be called from within a -gem. It should only be used from within the main application. -And even then it should be used only when necessary.

-
-
- -

Defines if ALL executors should be auto-terminated with an -at_exit callback. When set to false it will be the application -programmer's responsibility to ensure that all thread pools, -including the global thread pools, are shutdown properly prior to -application exit.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when all thread pools will auto-terminate on -application exit using an at_exit handler; false when no auto-termination -will occur.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-131
-132
-133
-
-
# File 'lib/concurrent/configuration.rb', line 131
-
-def self.auto_terminate_all_executors?
-  @@auto_terminate_all_executors.value
-end
-
-
- -
-

- - + (Boolean) auto_terminate_global_executors? - - - - - -

-
- -
- Note: -

Only change this option if you know what you are doing! -When this is set to true (the default) then at_exit handlers -will be registered automatically for the global thread pools -to ensure that they are shutdown when the application ends. When -changed to false, the at_exit handlers will be circumvented -for all global thread pools. This method should never be called -from within a gem. It should only be used from within the main -application and even then it should be used only when necessary.

-
-
- -

Defines if global executors should be auto-terminated with an -at_exit callback. When set to false it will be the application -programmer's responsibility to ensure that the global thread pools -are shutdown properly prior to application exit.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when global thread pools will auto-terminate on -application exit using an at_exit handler; false when no auto-termination -will occur.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-87
-88
-89
-
-
# File 'lib/concurrent/configuration.rb', line 87
-
-def self.auto_terminate_global_executors?
-  @@auto_terminate_global_executors.value
-end
-
-
- -
-

- - + (Object) call_dataflow(method, executor, *inputs, &block) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-
-
# File 'lib/concurrent/dataflow.rb', line 56
-
-def call_dataflow(method, executor, *inputs, &block)
-  raise ArgumentError.new('an executor must be provided') if executor.nil?
-  raise ArgumentError.new('no block given') unless block_given?
-  raise ArgumentError.new('not all dependencies are IVars') unless inputs.all? { |input| input.is_a? IVar }
-
-  result = Future.new(executor: executor) do
-    values = inputs.map { |input| input.send(method) }
-    block.call(*values)
-  end
-
-  if inputs.empty?
-    result.execute
-  else
-    counter = DependencyCounter.new(inputs.size) { result.execute }
-
-    inputs.each do |input|
-      input.add_observer counter
-    end
-  end
-
-  result
-end
-
-
- -
-

- - + (Configuration) configuration - - - - - -

-
- - -
-
-
- -

Returns:

- - -
- - - - -
-
-
-
-296
-297
-298
-
-
# File 'lib/concurrent/configuration.rb', line 296
-
-def self.configuration
-  @configuration.value
-end
-
-
- -
-

- - + (Object) configure {|the| ... } - - - - - -

-
-

Perform gem-level configuration.

- - -
-
-
- -

Yields:

-
    - -
  • - - - - - - - -

    the configuration commands

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - the - - - (Configuration) - - - - — -

    current configuration object

    -
    - -
  • - -
- -
- - - - -
-
-
-
-304
-305
-306
-
-
# File 'lib/concurrent/configuration.rb', line 304
-
-def self.configure
-  yield(configuration)
-end
-
-
- -
-

- - + (Object) dataflow(*inputs) {|inputs| ... } - - - - - -

-
-

Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available. Data dependencies are Future values. The dataflow task itself is also a Future value, so you can build up a graph of these tasks, each of which is run when all the data and other tasks it depends on are available or completed.

- -

Our syntax is somewhat related to that of Akka's flow and Habanero Java's DataDrivenFuture. However unlike Akka we don't schedule a task at all until it is ready to run, and unlike Habanero Java we pass the data values into the task instead of dereferencing them again in the task.

- -

The theory of dataflow goes back to the 70s. In the terminology of the literature, our implementation is coarse-grained, in that each task can be many instructions, and dynamic in that you can create more tasks within other tasks.

- -

Example

- -

A dataflow task is created with the dataflow method, passing in a block.

- -
task = Concurrent::dataflow { 14 }
-
- -

This produces a simple Future value. The task will run immediately, as it has no dependencies. We can also specify Future values that must be available before a task will run. When we do this we get the value of those futures passed to our block.

- -
a = Concurrent::dataflow { 1 }
-b = Concurrent::dataflow { 2 }
-c = Concurrent::dataflow(a, b) { |av, bv| av + bv }
-
- -

Using the dataflow method you can build up a directed acyclic graph (DAG) of tasks that depend on each other, and have the tasks run as soon as their dependencies are ready and there is CPU capacity to schedule them. This can help you create a program that uses more of the CPU resources available to you.

- -

Derivation

- -

This section describes how we could derive dataflow from other primitives in this library.

- -

Consider a naive fibonacci calculator.

- -
def fib(n)
-  if n < 2
-    n
-  else
-    fib(n - 1) + fib(n - 2)
-  end
-end
-
-puts fib(14) #=> 377
-
- -

We could modify this to use futures.

- -
def fib(n)
-  if n < 2
-    Concurrent::Future.new { n }
-  else
-    n1 = fib(n - 1).execute
-    n2 = fib(n - 2).execute
-    Concurrent::Future.new { n1.value + n2.value }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x000001019ef5a0 ...
-f.execute   #=> #<Concurrent::Future:0x000001019ef5a0 ...
-
-sleep(0.5)
-
-puts f.value #=> 377
-
- -

One of the drawbacks of this approach is that all the futures start, and then most of them immediately block on their dependencies. We know that there's no point executing those futures until their dependencies are ready, so let's not execute each future until all their dependencies are ready.

- -

To do this we'll create an object that counts the number of times it observes a future finishing before it does something - and for us that something will be to execute the next future.

- -
class CountingObserver
-
-  def initialize(count, &block)
-    @count = count
-    @block = block
-  end
-
-  def update(time, value, reason)
-    @count -= 1
-
-    if @count <= 0
-      @block.call()
-    end
-  end
-
-end
-
-def fib(n)
-  if n < 2
-    Concurrent::Future.new { n }.execute
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-
-    result = Concurrent::Future.new { n1.value + n2.value }
-
-    barrier = CountingObserver.new(2) { result.execute }
-    n1.add_observer barrier
-    n2.add_observer barrier
-
-    n1.execute
-    n2.execute
-
-    result
-  end
-end
-
- -

We can wrap this up in a dataflow utility.

- -
f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
-def dataflow(*inputs, &block)
-  result = Concurrent::Future.new(&block)
-
-  if inputs.empty?
-    result.execute
-  else
-    barrier = CountingObserver.new(inputs.size) { result.execute }
-
-    inputs.each do |input|
-      input.add_observer barrier
-    end
-  end
-
-  result
-end
-
-def fib(n)
-  if n < 2
-    dataflow { n }
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-    dataflow(n1, n2) { n1.value + n2.value }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
- -

Since we know that the futures the dataflow computation depends on are already going to be available when the future is executed, we might as well pass the values into the block so we don't have to reference the futures inside the block. This allows us to write the dataflow block as straight non-concurrent code without reference to futures.

- -
def dataflow(*inputs, &block)
-  result = Concurrent::Future.new do
-    values = inputs.map { |input| input.value }
-    block.call(*values)
-  end
-
-  if inputs.empty?
-    result.execute
-  else
-    barrier = CountingObserver.new(inputs.size) { result.execute }
-
-    inputs.each do |input|
-      input.add_observer barrier
-    end
-  end
-
-  result
-end
-
-def fib(n)
-  if n < 2
-    Concurrent::dataflow { n }
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-    Concurrent::dataflow(n1, n2) { |v1, v2| v1 + v2 }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x000001019a26d8 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
-

- - -
-
-
-

Parameters:

-
    - -
  • - - inputs - - - (Future) - - - - — -

    zero or more Future operations that this dataflow depends upon

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    The operation to perform once all the dependencies are met

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - inputs - - - (Future) - - - - — -

    each of the Future inputs to the dataflow

    -
    - -
  • - -
-

Yield Returns:

-
    - -
  • - - - (Object) - - - - — -

    the result of the block operation

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the result of all the operations

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no block is given

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if any of the inputs are not IVars

    -
    - -
  • - -
- -
- - - - -
-
-
-
-34
-35
-36
-
-
# File 'lib/concurrent/dataflow.rb', line 34
-
-def dataflow(*inputs, &block)
-  dataflow_with(Concurrent.global_io_executor, *inputs, &block)
-end
-
-
- -
-

- - + (Object) dataflow!(*inputs, &block) - - - - - -

- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/dataflow.rb', line 44
-
-def dataflow!(*inputs, &block)
-  dataflow_with!(Concurrent.global_io_executor, *inputs, &block)
-end
-
-
- -
-

- - + (Object) dataflow_with(executor, *inputs, &block) - - - - - -

- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/dataflow.rb', line 39
-
-def dataflow_with(executor, *inputs, &block)
-  call_dataflow(:value, executor, *inputs, &block)
-end
-
-
- -
-

- - + (Object) dataflow_with!(executor, *inputs, &block) - - - - - -

- - - - -
-
-
-
-49
-50
-51
-
-
# File 'lib/concurrent/dataflow.rb', line 49
-
-def dataflow_with!(executor, *inputs, &block)
-  call_dataflow(:value!, executor, *inputs, &block)
-end
-
-
- -
-

- - + (Object) disable_auto_termination_of_all_executors! - - - - - -

-
- -
- Note: -

Only change this option if you know what you are doing! -When this is set to true (the default) then at_exit handlers -will be registered automatically for all thread pools to -ensure that they are shutdown when the application ends. When -changed to false, the at_exit handlers will be circumvented -for all Concurrent Ruby thread pools running within the -application. Even those created within other gems used by the -application. This method should never be called from within a -gem. It should only be used from within the main application. -And even then it should be used only when necessary.

-
-
- -

Defines if ALL executors should be auto-terminated with an -at_exit callback. When set to false it will be the application -programmer's responsibility to ensure that all thread pools, -including the global thread pools, are shutdown properly prior to -application exit.

- - -
-
-
- - -
- - - - -
-
-
-
-107
-108
-109
-
-
# File 'lib/concurrent/configuration.rb', line 107
-
-def self.disable_auto_termination_of_all_executors!
-  @@auto_terminate_all_executors.make_false
-end
-
-
- -
-

- - + (Object) disable_auto_termination_of_global_executors! - - - - - -

-
- -
- Note: -

Only change this option if you know what you are doing! -When this is set to true (the default) then at_exit handlers -will be registered automatically for the global thread pools -to ensure that they are shutdown when the application ends. When -changed to false, the at_exit handlers will be circumvented -for all global thread pools. This method should never be called -from within a gem. It should only be used from within the main -application and even then it should be used only when necessary.

-
-
- -

Defines if global executors should be auto-terminated with an -at_exit callback. When set to false it will be the application -programmer's responsibility to ensure that the global thread pools -are shutdown properly prior to application exit.

- - -
-
-
- - -
- - - - -
-
-
-
-66
-67
-68
-
-
# File 'lib/concurrent/configuration.rb', line 66
-
-def self.disable_auto_termination_of_global_executors!
-  @@auto_terminate_global_executors.make_false
-end
-
-
- -
-

- - + (ThreadPoolExecutor) global_fast_executor - - - - - -

-
-

Global thread pool optimized for short, fast operations.

- - -
-
-
- -

Returns:

- - -
- - - - -
-
-
-
-138
-139
-140
-
-
# File 'lib/concurrent/configuration.rb', line 138
-
-def self.global_fast_executor
-  @@global_fast_executor.value
-end
-
-
- -
-

- - + (ThreadPoolExecutor) global_io_executor - - - - - -

-
-

Global thread pool optimized for long, blocking (IO) tasks.

- - -
-
-
- -

Returns:

- - -
- - - - -
-
-
-
-145
-146
-147
-
-
# File 'lib/concurrent/configuration.rb', line 145
-
-def self.global_io_executor
-  @@global_io_executor.value
-end
-
-
- -
-

- - + (Object) global_logger - - - - - -

- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/configuration.rb', line 44
-
-def self.global_logger
-  @@global_logger.value
-end
-
-
- -
-

- - + (Object) global_logger=(value) - - - - - -

- - - - -
-
-
-
-48
-49
-50
-
-
# File 'lib/concurrent/configuration.rb', line 48
-
-def self.global_logger=(value)
-  @@global_logger.value = value
-end
-
-
- -
-

- - + (Concurrent::TimerSet) global_timer_set - - - - - -

-
-

Global thread pool user for global timers.

- - -
-
-
- -

Returns:

- - -

See Also:

-
    - -
  • timer
  • - -
- -
- - - - -
-
-
-
-154
-155
-156
-
-
# File 'lib/concurrent/configuration.rb', line 154
-
-def self.global_timer_set
-  @@global_timer_set.value
-end
-
-
- -
-

- - + (Object) kill_global_executors - - - - - -

- - - - -
-
-
-
-164
-165
-166
-167
-168
-
-
# File 'lib/concurrent/configuration.rb', line 164
-
-def self.kill_global_executors
-  global_fast_executor.kill
-  global_io_executor.kill
-  global_timer_set.kill
-end
-
-
- -
-

- - + (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Logging - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - + (Float) monotonic_interval { ... } - - - - - -

-
- -
- Note: -

Time calculations one all platforms and languages are sensitive to -changes to the system clock. To alleviate the potential problems -associated with changing the system clock while an application is running, -most modern operating systems provide a monotonic clock that operates -independently of the system clock. A monotonic clock cannot be used to -determine human-friendly clock times. A monotonic clock is used exclusively -for calculating time intervals. Not all Ruby platforms provide access to an -operating system monotonic clock. On these platforms a pure-Ruby monotonic -clock will be used as a fallback. An operating system monotonic clock is both -faster and more reliable than the pure-Ruby implementation. The pure-Ruby -implementation should be fast and reliable enough for most non-realtime -operations. At this time the common Ruby platforms that provide access to an -operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

-
-
- -

Runs the given block and returns the number of seconds that elapsed.

- - -
-
-
- -

Yields:

-
    - -
  • - - - - - - - -

    the block to run and time

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Float) - - - - — -

    the number of seconds the block took to run

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    when no block given

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-67
-68
-69
-70
-71
-72
-
-
# File 'lib/concurrent/utility/monotonic_time.rb', line 67
-
-def monotonic_interval
-  raise ArgumentError.new('no block given') unless block_given?
-  start_time = GLOBAL_MONOTONIC_CLOCK.get_time
-  yield
-  GLOBAL_MONOTONIC_CLOCK.get_time - start_time
-end
-
-
- -
-

- - + (Float) monotonic_time - - - - - -

-
- -
- Note: -

Time calculations one all platforms and languages are sensitive to -changes to the system clock. To alleviate the potential problems -associated with changing the system clock while an application is running, -most modern operating systems provide a monotonic clock that operates -independently of the system clock. A monotonic clock cannot be used to -determine human-friendly clock times. A monotonic clock is used exclusively -for calculating time intervals. Not all Ruby platforms provide access to an -operating system monotonic clock. On these platforms a pure-Ruby monotonic -clock will be used as a fallback. An operating system monotonic clock is both -faster and more reliable than the pure-Ruby implementation. The pure-Ruby -implementation should be fast and reliable enough for most non-realtime -operations. At this time the common Ruby platforms that provide access to an -operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

-
-
- -

Returns the current time a tracked by the application monotonic clock.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Float) - - - - — -

    The current monotonic time when since not given else -the elapsed monotonic time between since and the current time

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-54
-55
-56
-
-
# File 'lib/concurrent/utility/monotonic_time.rb', line 54
-
-def monotonic_time
-  GLOBAL_MONOTONIC_CLOCK.get_time
-end
-
-
- -
-

- - + (Object) new_fast_executor(opts = {}) - - - - - -

- - - - -
-
-
-
-178
-179
-180
-181
-182
-183
-184
-185
-186
-
-
# File 'lib/concurrent/configuration.rb', line 178
-
-def self.new_fast_executor(opts = {})
-  FixedThreadPool.new(
-    [2, Concurrent.processor_count].max,
-    stop_on_exit:    opts.fetch(:stop_on_exit, true),
-    idletime:        60,          # 1 minute
-    max_queue:       0,           # unlimited
-    fallback_policy: :caller_runs # shouldn't matter -- 0 max queue
-  )
-end
-
-
- -
-

- - + (Object) new_io_executor(opts = {}) - - - - - -

- - - - -
-
-
-
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-
-
# File 'lib/concurrent/configuration.rb', line 188
-
-def self.new_io_executor(opts = {})
-  ThreadPoolExecutor.new(
-    min_threads: [2, Concurrent.processor_count].max,
-    max_threads: Concurrent.processor_count * 100,
-    stop_on_exit:    opts.fetch(:stop_on_exit, true),
-    idletime:        60,          # 1 minute
-    max_queue:       0,           # unlimited
-    fallback_policy: :caller_runs # shouldn't matter -- 0 max queue
-  )
-end
-
-
- -
-

- - + (Object) physical_processor_count - - - - - -

- - - - -
-
-
-
-150
-151
-152
-
-
# File 'lib/concurrent/utility/processor_count.rb', line 150
-
-def self.physical_processor_count
-  processor_counter.physical_processor_count
-end
-
-
- -
-

- - + (Object) processor_count - - - - - -

- - - - -
-
-
-
-146
-147
-148
-
-
# File 'lib/concurrent/utility/processor_count.rb', line 146
-
-def self.processor_count
-  processor_counter.processor_count
-end
-
-
- -
-

- - + (Object) shutdown_global_executors - - - - - -

- - - - -
-
-
-
-158
-159
-160
-161
-162
-
-
# File 'lib/concurrent/configuration.rb', line 158
-
-def self.shutdown_global_executors
-  global_fast_executor.shutdown
-  global_io_executor.shutdown
-  global_timer_set.shutdown
-end
-
-
- -
-

- - + (Object) timeout(seconds) - - - - - -

-
- -
- Note: -

Time calculations one all platforms and languages are sensitive to -changes to the system clock. To alleviate the potential problems -associated with changing the system clock while an application is running, -most modern operating systems provide a monotonic clock that operates -independently of the system clock. A monotonic clock cannot be used to -determine human-friendly clock times. A monotonic clock is used exclusively -for calculating time intervals. Not all Ruby platforms provide access to an -operating system monotonic clock. On these platforms a pure-Ruby monotonic -clock will be used as a fallback. An operating system monotonic clock is both -faster and more reliable than the pure-Ruby implementation. The pure-Ruby -implementation should be fast and reliable enough for most non-realtime -operations. At this time the common Ruby platforms that provide access to an -operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

-
-
- -

Wait the given number of seconds for the block operation to complete. -Intended to be a simpler and more reliable replacement to the Ruby -standard library Timeout::timeout method.

- - -
-
-
-

Parameters:

-
    - -
  • - - seconds - - - (Integer) - - - - — -

    The number of seconds to wait

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    The result of the block operation

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (Concurrent::TimeoutError) - - - - — -

    when the block operation does not complete -in the allotted number of seconds.

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-
-
# File 'lib/concurrent/utility/timeout.rb', line 22
-
-def timeout(seconds)
-
-  thread = Thread.new do
-    Thread.current[:result] = yield
-  end
-  success = thread.join(seconds)
-
-  if success
-    return thread[:result]
-  else
-    raise TimeoutError
-  end
-ensure
-  Thread.kill(thread) unless thread.nil?
-end
-
-
- -
-

- - + (Boolean) timer(seconds, *args) { ... } - - - - - -

-
- -
- Note: -

Time calculations one all platforms and languages are sensitive to -changes to the system clock. To alleviate the potential problems -associated with changing the system clock while an application is running, -most modern operating systems provide a monotonic clock that operates -independently of the system clock. A monotonic clock cannot be used to -determine human-friendly clock times. A monotonic clock is used exclusively -for calculating time intervals. Not all Ruby platforms provide access to an -operating system monotonic clock. On these platforms a pure-Ruby monotonic -clock will be used as a fallback. An operating system monotonic clock is both -faster and more reliable than the pure-Ruby implementation. The pure-Ruby -implementation should be fast and reliable enough for most non-realtime -operations. At this time the common Ruby platforms that provide access to an -operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

-
-
- -

Perform the given operation asynchronously after the given number of seconds.

- - -
-
-
-

Parameters:

-
    - -
  • - - seconds - - - (Fixnum) - - - - — -

    the interval in seconds to wait before executing the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the task to execute

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-15
-16
-17
-18
-19
-20
-21
-
-
# File 'lib/concurrent/utility/timer.rb', line 15
-
-def timer(seconds, *args, &block)
-  raise ArgumentError.new('no block given') unless block_given?
-  raise ArgumentError.new('interval must be greater than or equal to zero') if seconds < 0
-
-  Concurrent.configuration.global_timer_set.post(seconds, *args, &block)
-  true
-end
-
-
- -
-

- - + (Object) wait_for_global_executors_termination(timeout = nil) - - - - - -

- - - - -
-
-
-
-170
-171
-172
-173
-174
-175
-176
-
-
# File 'lib/concurrent/configuration.rb', line 170
-
-def self.wait_for_global_executors_termination(timeout = nil)
-  latch = CountDownLatch.new(3)
-  [ global_fast_executor, global_io_executor, global_timer_set ].each do |executor|
-    Thread.new{ executor.wait_for_termination(timeout); latch.count_down }
-  end
-  latch.wait(timeout)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AbstractThreadLocalVar.html b/docs/1.0.5/Concurrent/AbstractThreadLocalVar.html deleted file mode 100644 index 317b83382..000000000 --- a/docs/1.0.5/Concurrent/AbstractThreadLocalVar.html +++ /dev/null @@ -1,473 +0,0 @@ - - - - - - Class: Concurrent::AbstractThreadLocalVar - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::AbstractThreadLocalVar - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- -

Overview

-
-

A ThreadLocalVar is a variable where the value is different for each thread. -Each variable may have a default value, but when you modify the variable only -the current thread will ever see that change.

- - -
-
-
- -
-

Examples:

- - -
v = ThreadLocalVar.new(14)
-v.value #=> 14
-v.value = 2
-v.value #=> 2
- - -
v = ThreadLocalVar.new(14)
-
-t1 = Thread.new do
-  v.value #=> 14
-  v.value = 1
-  v.value #=> 1
-end
-
-t2 = Thread.new do
-  v.value #=> 14
-  v.value = 2
-  v.value #=> 2
-end
-
-v.value #=> 14
- -
- - -
-

Direct Known Subclasses

-

ThreadLocalVar

-
-

Defined Under Namespace

-

- - - Modules: ThreadLocalJavaStorage, ThreadLocalRubyStorage - - - - -

- -

Constant Summary

- -
- -
NIL_SENTINEL = - -
-
Object.new
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (AbstractThreadLocalVar) initialize(default = nil) - - - - - -

-
-

Returns a new instance of AbstractThreadLocalVar

- - -
-
-
- - -
- - - - -
-
-
-
-85
-86
-87
-88
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 85
-
-def initialize(default = nil)
-  @default = default
-  allocate_storage
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) bind(value, &block) - - - - - -

- - - - -
-
-
-
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 106
-
-def bind(value, &block)
-  if value.nil?
-    stored_value = NIL_SENTINEL
-  else
-    stored_value = value
-  end
-
-  set stored_value, &block
-
-  value
-end
-
-
- -
-

- - - (Object) value - - - - - -

- - - - -
-
-
-
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 90
-
-def value
-  value = get
-
-  if value.nil?
-    @default
-  elsif value == NIL_SENTINEL
-    nil
-  else
-    value
-  end
-end
-
-
- -
-

- - - (Object) value=(value) - - - - - -

- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 102
-
-def value=(value)
-  bind value
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalJavaStorage.html b/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalJavaStorage.html deleted file mode 100644 index 6cbbd0024..000000000 --- a/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalJavaStorage.html +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - Module: Concurrent::AbstractThreadLocalVar::ThreadLocalJavaStorage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::AbstractThreadLocalVar::ThreadLocalJavaStorage - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage (protected) - - - - - -

- - - - -
-
-
-
-69
-70
-71
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 69
-
-def allocate_storage
-  @var = java.lang.ThreadLocal.new
-end
-
-
- -
-

- - - (Object) get (protected) - - - - - -

- - - - -
-
-
-
-73
-74
-75
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 73
-
-def get
-  @var.get
-end
-
-
- -
-

- - - (Object) set(value) (protected) - - - - - -

- - - - -
-
-
-
-77
-78
-79
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 77
-
-def set(value)
-  @var.set(value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalRubyStorage.html b/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalRubyStorage.html deleted file mode 100644 index 4208acdca..000000000 --- a/docs/1.0.5/Concurrent/AbstractThreadLocalVar/ThreadLocalRubyStorage.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - Module: Concurrent::AbstractThreadLocalVar::ThreadLocalRubyStorage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::AbstractThreadLocalVar::ThreadLocalRubyStorage - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage (protected) - - - - - -

- - - - -
-
-
-
-42
-43
-44
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 42
-
-def allocate_storage
-  @storage = Ref::WeakKeyMap.new
-end
-
-
- -
-

- - - (Object) get (protected) - - - - - -

- - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 46
-
-def get
-  @storage[Thread.current]
-end
-
-
- -
-

- - - (Object) set(value, &block) (protected) - - - - - -

- - - - -
-
-
-
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 50
-
-def set(value, &block)
-  key = Thread.current
-
-  @storage[key] = value
-
-  if block_given?
-    begin
-      block.call
-    ensure
-      @storage.delete key
-    end
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor.html b/docs/1.0.5/Concurrent/Actor.html index 98f69a16c..d447c248d 100644 --- a/docs/1.0.5/Concurrent/Actor.html +++ b/docs/1.0.5/Concurrent/Actor.html @@ -1292,9 +1292,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::AdHoc - - - -

- -
- -
Inherits:
-
- Context - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/ad_hoc.rb
- -
-
- -

Overview

-
-

Allows quick creation of actors with behaviour defined by blocks.

- - -
-
-
- -
-

Examples:

- - -

ping

-

- -
AdHoc.spawn :forward, an_actor do |where|
-  # this block has to return proc defining #on_message behaviour
-  -> message { where.tell message  }
-end
- -
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from AbstractContext - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (AdHoc) initialize(*args, &initializer) - - - - - -

-
-

Returns a new instance of AdHoc

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/actor/ad_hoc.rb', line 10
-
-def initialize(*args, &initializer)
-  @on_message = Type! initializer.call(*args), Proc
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - AbstractContext - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_message(message) - - - - - -

- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/actor/ad_hoc.rb', line 14
-
-def on_message(message)
-  instance_exec message, &@on_message
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour.html b/docs/1.0.5/Concurrent/Actor/Behaviour.html index 4362d1b73..153b80306 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour.html @@ -815,9 +815,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::DoContext - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-271
-272
-273
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 271
-
-def on_envelope(envelope)
-  context.on_envelope envelope or pass envelope
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorHandling.html b/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorHandling.html deleted file mode 100644 index a37eefa3e..000000000 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorHandling.html +++ /dev/null @@ -1,506 +0,0 @@ - - - - - - Class: Concurrent::Actor::Behaviour::ErrorHandling - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::ErrorHandling - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (ErrorHandling) initialize(core, subsequent) - - - - - -

-
-

pause on error ask its parent -handling -:continue -:reset will only rebuild context -:restart drops messaged and as :reset

- - -
-
-
- - -
- - - - -
-
-
-
-166
-167
-168
-169
-170
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 166
-
-def initialize(core, subsequent)
-  super core, subsequent
-  @paused = false
-  @buffer = []
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-172
-173
-174
-175
-176
-177
-178
-179
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 172
-
-def on_envelope(envelope)
-  case envelope.message
-    # only from supervisor?
-  when :reset!
-  when :restart!
-  when :continue!
-  else
-    if @paused
-      @buffer << envelope
-    else
-      begin
-        pass envelope
-      rescue => error
-        #
-      end
-    end
-  end
-end
-
-
- -
-

- - - (Object) reject_messages - - - - - -

- - - - -
-
-
-
-191
-192
-193
-194
-195
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 191
-
-def reject_messages
-  @buffer.each { |envelope| reject_envelope envelope }
-  @buffer.clear
-  super
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorOnUnknownMessage.html b/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorOnUnknownMessage.html deleted file mode 100644 index c41b3baf8..000000000 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorOnUnknownMessage.html +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - Class: Concurrent::Actor::Behaviour::ErrorOnUnknownMessage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::ErrorOnUnknownMessage - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-277
-278
-279
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 277
-
-def on_envelope(envelope)
-  raise "unknown message #{envelope.message.inspect}"
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html b/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html index 06b604518..8c9b2e114 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html @@ -359,9 +359,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::RemoveChild - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-203
-204
-205
-206
-207
-208
-209
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 203
-
-def on_envelope(envelope)
-  if envelope.message == :remove_child
-    core.remove_child envelope.sender
-  else
-    pass envelope
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/RemovesChild.html b/docs/1.0.5/Concurrent/Actor/Behaviour/RemovesChild.html index cdad73de3..b4260d2fa 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/RemovesChild.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour/RemovesChild.html @@ -354,9 +354,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::RestartAndResets - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/SetResults.html b/docs/1.0.5/Concurrent/Actor/Behaviour/SetResults.html index 3831acfb0..c7bb82f16 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/SetResults.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour/SetResults.html @@ -515,9 +515,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::Supervised - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour/supervised.rb
- -
-
- -

Overview

-
-

Sets and holds the supervisor of the actor if any. There is at most one supervisor -for each actor. Each supervisor is automatically linked. Messages: -:pause!, :resume!, :reset!, :restart! are accepted only from supervisor.

- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
  • - - - - (Object) supervisor - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute supervisor.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Supervised) initialize(core, subsequent) - - - - - -

-
-

Returns a new instance of Supervised

- - -
-
-
- - -
- - - - -
-
-
-
-11
-12
-13
-14
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 11
-
-def initialize(core, subsequent)
-  super core, subsequent
-  @supervisor = nil
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- - - -
-

- - - (Object) supervisor (readonly) - - - - - -

-
-

Returns the value of attribute supervisor

- - -
-
-
- - -
- - - - -
-
-
-
-9
-10
-11
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 9
-
-def supervisor
-  @supervisor
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 16
-
-def on_envelope(envelope)
-  case envelope.message
-  when :supervise
-    supervise envelope.sender
-  when :supervisor
-    supervisor
-  when :un_supervise
-    un_supervise envelope.sender
-  when :pause!, :resume!, :reset!, :restart!
-    # allow only supervisor to control the actor
-    if @supervisor == envelope.sender
-      pass envelope
-    else
-      false
-    end
-  else
-    pass envelope
-  end
-end
-
-
- -
-

- - - (Object) on_event(event) - - - - - -

- - - - -
-
-
-
-52
-53
-54
-55
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 52
-
-def on_event(event)
-  @supervisor = nil if event == :terminated
-  super event
-end
-
-
- -
-

- - - (Object) supervise(ref) - - - - - -

- - - - -
-
-
-
-36
-37
-38
-39
-40
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 36
-
-def supervise(ref)
-  @supervisor = ref
-  behaviour!(Linking).link ref
-  true
-end
-
-
- -
-

- - - (Object) un_supervise(ref) - - - - - -

- - - - -
-
-
-
-42
-43
-44
-45
-46
-47
-48
-49
-50
-
-
# File 'lib/concurrent/actor/behaviour/supervised.rb', line 42
-
-def un_supervise(ref)
-  if @supervisor == ref
-    behaviour!(Linking).unlink ref
-    @supervisor = nil
-    true
-  else
-    false
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/Supervising.html b/docs/1.0.5/Concurrent/Actor/Behaviour/Supervising.html index 4c23445ee..c4411db0a 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/Supervising.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour/Supervising.html @@ -461,9 +461,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Behaviour::TerminatesChildren - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour/terminates_children.rb
- -
-
- -

Overview

-
-

Terminates all children when the actor terminates.

- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_event(event) - - - - - -

- - - - -
-
-
-
-6
-7
-8
-9
-
-
# File 'lib/concurrent/actor/behaviour/terminates_children.rb', line 6
-
-def on_event(event)
-  children.map { |ch| ch.ask :terminate! }.each(&:wait) if event == :terminated
-  super event
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Behaviour/Termination.html b/docs/1.0.5/Concurrent/Actor/Behaviour/Termination.html index 822031640..92d528ec2 100644 --- a/docs/1.0.5/Concurrent/Actor/Behaviour/Termination.html +++ b/docs/1.0.5/Concurrent/Actor/Behaviour/Termination.html @@ -857,9 +857,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Actor::ClassMethods - - - -

- -
- - - - - - - -
Included in:
-
Context
- - - -
Defined in:
-
lib/concurrent/actor/context.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) spawn(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actor.spawn but :class is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-83
-84
-85
-
-
# File 'lib/concurrent/actor/context.rb', line 83
-
-def spawn(name_or_opts, *args, &block)
-  Actor.spawn spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
-

- - - (Object) spawn!(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actor.spawn! but :class is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-88
-89
-90
-
-
# File 'lib/concurrent/actor/context.rb', line 88
-
-def spawn!(name_or_opts, *args, &block)
-  Actor.spawn! spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Context.html b/docs/1.0.5/Concurrent/Actor/Context.html index 8f064977d..bd2298352 100644 --- a/docs/1.0.5/Concurrent/Actor/Context.html +++ b/docs/1.0.5/Concurrent/Actor/Context.html @@ -290,9 +290,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Actor::Context::ClassMethods - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/actor/context.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) spawn(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actor.spawn but class_name is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-85
-86
-87
-
-
# File 'lib/concurrent/actor/context.rb', line 85
-
-def spawn(name_or_opts, *args, &block)
-  Actor.spawn spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
-

- - - (Object) spawn!(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actor.spawn! but class_name is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-99
-100
-101
-
-
# File 'lib/concurrent/actor/context.rb', line 99
-
-def spawn!(name_or_opts, *args, &block)
-  Actor.spawn! spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
-
-
-

TODO hash version -TODO There needs to be a way how to ensure that spawn and link is atomic operation, -meaning: the :link will be the first message received. -Reference cannot escape before spawn is complete? add after_start callback? -spawn

- - -
-
-
- - -
- - - - -
-
-
-
-94
-95
-96
-
-
# File 'lib/concurrent/actor/context.rb', line 94
-
-def spawn_link(name_or_opts, *args, &block)
-  spawn(name_or_opts, *args, &block).link(:link)
-end
-
-
- -
-

- - - (Object) spawn_link!(name_or_opts, *args, &block) - - - - - -

- - - - -
-
-
-
-103
-104
-105
-
-
# File 'lib/concurrent/actor/context.rb', line 103
-
-def spawn_link!(name_or_opts, *args, &block)
-  spawn!(name_or_opts, *args, &block).link(:link)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/ContextDelegations.html b/docs/1.0.5/Concurrent/Actor/ContextDelegations.html deleted file mode 100644 index cdbb166e3..000000000 --- a/docs/1.0.5/Concurrent/Actor/ContextDelegations.html +++ /dev/null @@ -1,1024 +0,0 @@ - - - - - - Module: Concurrent::Actor::ContextDelegations - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actor::ContextDelegations - - - -

- -
- - - - - -
Includes:
-
CoreDelegations
- - - - -
Included in:
-
Behaviour::Abstract, Context
- - - -
Defined in:
-
lib/concurrent/actor/behaviour.rb
- -
-
- -

Overview

-
-

TODO split this into files

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) broadcast(event) - - - - - -

- - - - -
-
-
-
-42
-43
-44
-45
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 42
-
-def broadcast(event)
-  linking = core.behaviour(Behaviour::Linking) and
-      linking.broadcast(event)
-end
-
-
- -
-

- - - (Object) children - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 14
-
-def children
-  core.children
-end
-
-
- -
-

- - - (Object) context - - - - - -

- - - - -
-
-
-
-38
-39
-40
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 38
-
-def context
-  core.context
-end
-
-
- -
-

- - - (Object) context_class - - - - Also known as: - actor_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) dead_letter_routing - - - - - -

- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 29
-
-def dead_letter_routing
-  context.dead_letter_routing
-end
-
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, message = nil, &block) - - - - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-25
-26
-27
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 25
-
-def log(level, message = nil, &block)
-  core.log(level, message, &block)
-end
-
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) redirect(reference, envelope = self.envelope) - - - - - -

- - - - -
-
-
-
-33
-34
-35
-36
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 33
-
-def redirect(reference, envelope = self.envelope)
-  reference.message(envelope.message, envelope.ivar)
-  Behaviour::NOT_PROCESSED
-end
-
-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-9
-10
-11
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 9
-
-def spawn(*args, &block)
-  Actor.spawn(*args, &block)
-end
-
-
- -
-

- - - (Object) terminate! - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/actor/behaviour.rb', line 19
-
-def terminate!
-  core.terminate!
-end
-
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Core.html b/docs/1.0.5/Concurrent/Actor/Core.html index 9532d76fa..df8612939 100644 --- a/docs/1.0.5/Concurrent/Actor/Core.html +++ b/docs/1.0.5/Concurrent/Actor/Core.html @@ -2516,9 +2516,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Actor::InstanceMethods - - - -

- -
- - - - - -
Includes:
-
InternalDelegations, TypeCheck
- - - - -
Included in:
-
Context
- - - -
Defined in:
-
lib/concurrent/actor/context.rb
- -
-
- -

Overview

-
-

This module is used to define actors. It can be included in any class, -only requirement is to override Context#on_message method.

- - -
-
-
- -
-

Examples:

- - -

ping

-

- -
class Ping
-  include Context
-  def on_message(message)
-    message
-  end
-end
-
-Ping.spawn(:ping1).ask(:m).value #=> :m
- -
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
- - - - -
-
-
-
-20
-21
-22
-
-
# File 'lib/concurrent/actor/context.rb', line 20
-
-def core
-  @core
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) behaviour(behaviour_class) - - - - - - - Originally defined in module - InternalDelegations - - -

-
- -
-

- - - (Object) behaviour!(behaviour_class) - - - - - - - Originally defined in module - InternalDelegations - - -

-
- -
-

- - - (Array<Array(Behavior::Abstract, Array<Object>)>) behaviour_definition - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Array(Behavior::Abstract, Array<Object>)>) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/actor/context.rb', line 59
-
-def behaviour_definition
-  raise NotImplementedError
-end
-
-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - - - Originally defined in module - InternalDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) context - - - - - - - Originally defined in module - InternalDelegations - - -

-
- -
-

- - - (Object) context_class - - - - Also known as: - actor_class - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Reference) dead_letter_routing - - - - - -

-
-

Defines an actor responsible for dead letters. Any rejected message send with -Reference#tell is sent there, a message with ivar is considered already monitored for -failures. Default behaviour is to use Context#dead_letter_routing of the parent, -so if no Context#dead_letter_routing method is overridden in parent-chain the message ends up in -Actor.root.dead_letter_routing agent which will log warning.

- - -
-
-
- -

Returns:

- - -
- - - - -
-
-
-
-54
-55
-56
-
-
# File 'lib/concurrent/actor/context.rb', line 54
-
-def dead_letter_routing
-  parent.dead_letter_routing
-end
-
-
- -
-

- - - (CLass) default_reference_class - - - - - -

-
-

override if different class for reference is needed

- - -
-
-
- -

Returns:

-
    - -
  • - - - (CLass) - - - - — -

    descendant of Reference

    -
    - -
  • - -
- -
- - - - -
-
-
-
-70
-71
-72
-
-
# File 'lib/concurrent/actor/context.rb', line 70
-
-def default_reference_class
-  Reference
-end
-
-
- -
-

- - - (Envelope) envelope - - - - - -

-
-

Returns current envelope, accessible inside #on_message processing

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Envelope) - - - - — -

    current envelope, accessible inside #on_message processing

    -
    - -
  • - -
- -
- - - - -
-
-
-
-64
-65
-66
-
-
# File 'lib/concurrent/actor/context.rb', line 64
-
-def envelope
-  @envelope or raise 'envelope not set'
-end
-
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Object) log(level, message = nil, &block) - - - - - - - Originally defined in module - InternalDelegations - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-36
-37
-38
-39
-40
-41
-
-
# File 'lib/concurrent/actor/context.rb', line 36
-
-def on_envelope(envelope)
-  @envelope = envelope
-  on_message envelope.message
-ensure
-  @envelope = nil
-end
-
-
- -
-

- - - (Object) on_event(event) - - - - - -

-
-

override to add custom code invocation on events like :terminated, :resumed, anError.

- - -
-
-
- - -
- - - - -
-
-
-
-32
-33
-
-
# File 'lib/concurrent/actor/context.rb', line 32
-
-def on_event(event)
-end
-
-
- -
-

- - - (Object) on_message(message) - - - - - -

-
-
- This method is abstract. -

override to define Actor's behaviour

-
-
- -
- Note: -

self should not be returned (or sent to other actors), PublicDelegations#reference should be used -instead

-
-
- -

Returns a result which will be used to set the IVar supplied to Reference#ask

- - -
-
-
-

Parameters:

-
    - -
  • - - message - - - (Object) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    a result which will be used to set the IVar supplied to Reference#ask

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-27
-28
-29
-
-
# File 'lib/concurrent/actor/context.rb', line 27
-
-def on_message(message)
-  raise NotImplementedError
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Object) pass - - - - - -

-
-

if you want to pass the message to next behaviour, usually Behaviour::ErrorOnUnknownMessage

- - -
-
-
- - -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/actor/context.rb', line 44
-
-def pass
-  core.behaviour!(Behaviour::ExecutesContext).pass envelope
-end
-
-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Object) redirect(reference, envelope = self.envelope) - - - - - - - Originally defined in module - InternalDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Object) terminate! - - - - - - - Originally defined in module - InternalDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - PublicDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - PublicDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/InternalDelegations.html b/docs/1.0.5/Concurrent/Actor/InternalDelegations.html index 6bc525791..49cb3845f 100644 --- a/docs/1.0.5/Concurrent/Actor/InternalDelegations.html +++ b/docs/1.0.5/Concurrent/Actor/InternalDelegations.html @@ -1123,9 +1123,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Actor::Utils::AbstractWorker - - - -

- -
- -
Inherits:
-
- RestartingContext - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/utils/pool.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - inherited - from AbstractContext - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (AbstractWorker) initialize(balancer) - - - - - -

-
-

Returns a new instance of AbstractWorker

- - -
-
-
- - -
- - - - -
-
-
-
-42
-43
-44
-45
-
-
# File 'lib/concurrent/actor/utils/pool.rb', line 42
-
-def initialize(balancer)
-  @balancer = balancer
-  @balancer << :subscribe
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in class - AbstractContext - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_message(message) - - - - - -

- - - - -
-
-
-
-47
-48
-49
-50
-51
-
-
# File 'lib/concurrent/actor/utils/pool.rb', line 47
-
-def on_message(message)
-  work message
-ensure
-  @balancer << :subscribe
-end
-
-
- -
-

- - - (Object) work(message) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-53
-54
-55
-
-
# File 'lib/concurrent/actor/utils/pool.rb', line 53
-
-def work(message)
-  raise NotImplementedError
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/Utils/AdHoc.html b/docs/1.0.5/Concurrent/Actor/Utils/AdHoc.html index b7734cbe0..46876837b 100644 --- a/docs/1.0.5/Concurrent/Actor/Utils/AdHoc.html +++ b/docs/1.0.5/Concurrent/Actor/Utils/AdHoc.html @@ -349,9 +349,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Actress - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/actress.rb,
- lib/concurrent/actress/core.rb,
lib/concurrent/actress/ad_hoc.rb,
lib/concurrent/actress/errors.rb,
lib/concurrent/actress/context.rb,
lib/concurrent/actress/envelope.rb,
lib/concurrent/actress/reference.rb,
lib/concurrent/actress/type_check.rb,
lib/concurrent/actress/core_delegations.rb
-
- -
-
- -

Overview

-
-

Actor model

- -
    -
  • Light-weighted.
  • -
  • Inspired by Akka and Erlang.
  • -
- -

Actors are sharing a thread-pool by default which makes them very cheap to create and discard. -Thousands of actors can be created allowing to brake the program to small maintainable pieces -without breaking single responsibility principles.

- -

What is an actor model?

- -

Wiki says: -The actor model in computer science is a mathematical model of concurrent computation -that treats actors as the universal primitives of concurrent digital computation: -in response to a message that it receives, an actor can make local decisions, -create more actors, send more messages, and determine how to respond to the next -message received.

- -

Why?

- -

Concurrency is hard this is one of many ways how to simplify the problem. -It is simpler to reason about actors then about locks (and all their possible states).

- -

How to use it

- -

class Counter
-  # Include context of an actor which gives this class access to reference and other information
-  # about the actor, see CoreDelegations.
-  include Concurrent::Actress::Context
-
-  # use initialize as you wish
-  def initialize(initial_value)
-    @count = initial_value
-  end
-
-  # override on_message to define actor's behaviour
-  def on_message(message)
-    case message
-    when Integer
-      @count += message
-    when :terminate
-      terminate!
-    else
-      raise 'unknown'
-    end
-  end
-end                                                # => :on_message
-
-# Create new actor naming the instance 'first'.
-# Return value is a reference to the actor, the actual actor is never returned.
-counter = Counter.spawn(:first, 5)
-    # => #<Concurrent::Actress::Reference /first (Counter)>
-
-# Tell a message and forget returning self.
-counter.tell(1)
-    # => #<Concurrent::Actress::Reference /first (Counter)>
-counter << 1
-    # => #<Concurrent::Actress::Reference /first (Counter)>
-# (First counter now contains 7.)
-
-# Send a messages asking for a result.
-counter.ask(0).class                               # => Concurrent::IVar
-counter.ask(0).value                               # => 7
-
-# Terminate the actor.
-counter.tell(:terminate)
-    # => #<Concurrent::Actress::Reference /first (Counter)>
-# Not terminated yet, it takes a while until the message is processed.
-counter.terminated?                                # => false
-# Waiting for the termination.
-counter.terminated.class                           # => Concurrent::Event
-counter.terminated.wait                            # => true
-counter.terminated?                                # => true
-# Any subsequent messages are rejected.
-counter.ask(5).wait.rejected?                      # => true
-
-# Failure on message processing terminates the actor.
-counter = Counter.spawn(:first, 0)
-    # => #<Concurrent::Actress::Reference /first (Counter)>
-counter.ask('boom').wait.rejected?                 # => true
-counter.terminated?                                # => true
-
-
-# Lets define an actor creating children actors.
-class Node
-  include Concurrent::Actress::Context
-
-  def on_message(message)
-    case message
-    when :new_child
-      spawn self.class, :child
-    when :how_many_children
-      children.size
-    when :terminate
-      terminate!
-    else
-      raise 'unknown'
-    end
-  end
-end                                                # => :on_message
-
-# Actors are tracking parent-child relationships
-parent = Node.spawn :parent                        # => #<Concurrent::Actress::Reference /parent (Node)>
-child  = parent.tell(:new_child).ask!(:new_child)
-    # => #<Concurrent::Actress::Reference /parent/child (Node)>
-child.parent                                       # => #<Concurrent::Actress::Reference /parent (Node)>
-parent.ask!(:how_many_children)                    # => 2
-
-# There is a special root actor which is used for all actors spawned outside any actor.
-parent.parent
-    # => #<Concurrent::Actress::Reference / (Concurrent::Actress::Root)>
-
-# Termination of an parent will also terminate all children.
-parent.ask('boom').wait 
-parent.terminated?                                 # => true
-child.terminated?                                  # => true

- -

Messaging

- -

Messages are processed in same order as they are sent by a sender. It may interleaved with -messages form other senders though. There is also a contract in actor model that -messages sent between actors should be immutable. Gems like

- -
    -
  • Algebrick - Typed struct on steroids based on -algebraic types and pattern matching
  • -
  • Hamster - Efficient, Immutable, Thread-Safe -Collection classes for Ruby
  • -
- -

are very useful.

- -

Architecture

- -

Actors are running on shared thread poll which allows user to create many actors cheaply. -Downside is that these actors cannot be directly used to do IO or other blocking operations. -Blocking operations could starve the default_task_pool. However there are two options:

- -
    -
  • Create an regular actor which will schedule blocking operations in global_operation_pool -(which is intended for blocking operations) sending results back to self in messages.
  • -
  • Create an actor using global_operation_pool instead of global_task_pool, e.g. -AnIOActor.spawn name: :blocking, executor: Concurrent.configuration.global_operation_pool.
  • -
- -

Each actor is composed from 3 objects:

- -

Reference

- -

Reference is public interface of Actor instances. It is used for sending messages and can -be freely passed around the program. It also provides some basic information about the actor, -see CoreDelegations.

-

- -

Core

- -

Core of the actor

-

- -

Context

- -

This module is used to define actors. It can be included in any class, -only requirement is to override Context#on_message method.

-

- -

Speed

- -

Simple benchmark Actress vs Celluloid, the numbers are looking good -but you know how it is with benchmarks. Source code is in -examples/actress/celluloid_benchmark.rb. It sends numbers between x actors -and adding 1 until certain limit is reached.

- -

Benchmark legend:

- -
    -
  • mes. - number of messages send between the actors
  • -
  • act. - number of actors exchanging the messages
  • -
  • impl. - which gem is used
  • -
- -

JRUBY

- -
Rehearsal --------------------------------------------------------
-50000    2 actress    24.110000   0.800000  24.910000 (  7.728000)
-50000    2 celluloid  28.510000   4.780000  33.290000 ( 14.782000)
-50000  500 actress    13.700000   0.280000  13.980000 (  4.307000)
-50000  500 celluloid  14.520000  11.740000  26.260000 ( 12.258000)
-50000 1000 actress    10.890000   0.220000  11.110000 (  3.760000)
-50000 1000 celluloid  15.600000  21.690000  37.290000 ( 18.512000)
-50000 1500 actress    10.580000   0.270000  10.850000 (  3.646000)
-50000 1500 celluloid  14.490000  29.790000  44.280000 ( 26.043000)
---------------------------------------------- total: 201.970000sec
-
- mes. act.      impl.      user     system      total        real
-50000    2 actress     9.820000   0.510000  10.330000 (  5.735000)
-50000    2 celluloid  10.390000   4.030000  14.420000 (  7.494000)
-50000  500 actress     9.880000   0.200000  10.080000 (  3.310000)
-50000  500 celluloid  12.430000  11.310000  23.740000 ( 11.727000)
-50000 1000 actress    10.590000   0.190000  10.780000 (  4.029000)
-50000 1000 celluloid  14.950000  23.260000  38.210000 ( 20.841000)
-50000 1500 actress    10.710000   0.250000  10.960000 (  3.892000)
-50000 1500 celluloid  13.280000  30.030000  43.310000 ( 24.620000) (1)
-
- -

MRI 2.1.0

- -
Rehearsal --------------------------------------------------------
-50000    2 actress     4.640000   0.080000   4.720000 (  4.852390)
-50000    2 celluloid   6.110000   2.300000   8.410000 (  7.898069)
-50000  500 actress     6.260000   2.210000   8.470000 (  7.400573)
-50000  500 celluloid  10.250000   4.930000  15.180000 ( 14.174329)
-50000 1000 actress     6.300000   1.860000   8.160000 (  7.303162)
-50000 1000 celluloid  12.300000   7.090000  19.390000 ( 17.962621)
-50000 1500 actress     7.410000   2.610000  10.020000 (  8.887396)
-50000 1500 celluloid  14.850000  10.690000  25.540000 ( 24.489796)
----------------------------------------------- total: 99.890000sec
-
- mes. act.      impl.      user     system      total        real
-50000    2 actress     4.190000   0.070000   4.260000 (  4.306386)
-50000    2 celluloid   6.490000   2.210000   8.700000 (  8.280051)
-50000  500 actress     7.060000   2.520000   9.580000 (  8.518707)
-50000  500 celluloid  10.550000   4.980000  15.530000 ( 14.699962)
-50000 1000 actress     6.440000   1.870000   8.310000 (  7.571059)
-50000 1000 celluloid  12.340000   7.510000  19.850000 ( 18.793591)
-50000 1500 actress     6.720000   2.160000   8.880000 (  7.929630)
-50000 1500 celluloid  14.140000  10.130000  24.270000 ( 22.775288) (1)
-
- -

Note (1): Celluloid is using thread per actor so this bench is creating about 1500 -native threads. Actress is using constant number of threads.

- - -
-
-
- - -

Defined Under Namespace

-

- - - Modules: Context, CoreDelegations, TypeCheck - - - - Classes: ActressTerminated, AdHoc, Core, Envelope, Reference, Root - - -

- -

Constant Summary

- -
- -
ROOT = -
-
-

A root actor, a default parent of all actors spawned outside an actor

- - -
-
-
- - -
-
-
Core.new(parent: nil, name: '/', class: Root).reference
- -
Error = - -
-
Class.new(StandardError)
- -
- - - - - - - - - -

- Class Method Summary - (collapse) -

- - - - - - -
-

Class Method Details

- - -
-

- - + (Reference?) current - - - - - -

-
-

Returns current executing actor if any

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Reference, nil) - - - - — -

    current executing actor if any

    -
    - -
  • - -
- -
- - - - -
-
-
-
-144
-145
-146
-
-
# File 'lib/concurrent/actress.rb', line 144
-
-def self.current
-  Thread.current[:__current_actor__]
-end
-
-
- -
-

- - + (Boolean) experimental_acknowledged? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-217
-218
-219
-
-
# File 'lib/concurrent/actress.rb', line 217
-
-def self.experimental_acknowledged?
-  !!@experimental_acknowledged
-end
-
-
- -
-

- - + (Object) i_know_it_is_experimental! - - - - - -

-
-

call this to disable experimental warning

- - -
-
-
- - -
- - - - -
-
-
-
-213
-214
-215
-
-
# File 'lib/concurrent/actress.rb', line 213
-
-def self.i_know_it_is_experimental!
-  @experimental_acknowledged = true
-end
-
-
- -
-

- - + (Reference) spawn(*args, &block) - - - - - -

-
-

Spawns a new actor.

- - -
-
-
- -
-

Examples:

- - -

simple

-

- -
Actress.spawn(AdHoc, :ping1) { -> message { message } }
- - -

complex

-

- -
Actress.spawn name:     :ping3,
-              class:    AdHoc,
-              args:     [1]
-              executor: Concurrent.configuration.global_task_pool do |add|
-  lambda { |number| number + add }
-end
- -
-

Parameters:

-
    - -
  • - - block - - - - - - - — -

    for actress_class instantiation

    -
    - -
  • - -
  • - - args - - - - - - - — - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Reference) - - - - — -

    never the actual actor

    -
    - -
  • - -
- -
- - - - -
-
-
-
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-
-
# File 'lib/concurrent/actress.rb', line 180
-
-def self.spawn(*args, &block)
-  experimental_acknowledged? or
-      warn '[EXPERIMENTAL] A full release of `Actress`, renamed `Actor`, is expected in the 0.7.0 release.'
-
-  if Actress.current
-    Core.new(spawn_optionify(*args).merge(parent: Actress.current), &block).reference
-  else
-    ROOT.ask([:spawn, spawn_optionify(*args), block]).value
-  end
-end
-
-
- -
-

- - + (Object) spawn!(*args, &block) - - - - - -

-
-

as spawn but it'll raise when Actor not initialized properly

- - -
-
-
- - -
- - - - -
-
-
-
-192
-193
-194
-
-
# File 'lib/concurrent/actress.rb', line 192
-
-def self.spawn!(*args, &block)
-  spawn(spawn_optionify(*args).merge(initialized: ivar = IVar.new), &block).tap { ivar.no_error! }
-end
-
-
- -
-

- - - + (Object) spawn_optionify(actress_class, name, *args) - - + (Object) spawn_optionify(opts) - - - - - - -

-
- - -
-
-
- -

Overloads:

-
    - - -
  • - + (Object) spawn_optionify(actress_class, name, *args) -
    -
    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - actress_class - - - (Context) - - - - — -

      to be spawned

      -
      - -
    • - -
    • - - name - - - (String, Symbol) - - - - — -

      of the instance, it's used to generate the Concurrent::Actress::Core#path of the actor

      -
      - -
    • - -
    • - - args - - - - - - - — -

      for actress_class instantiation

      -
      - -
    • - -
    - - -
    -
  • - - -
  • - + (Object) spawn_optionify(opts) - -
    - - -
    -
  • - -
- - -
- - - - -
-
-
-
-202
-203
-204
-205
-206
-207
-208
-209
-210
-
-
# File 'lib/concurrent/actress.rb', line 202
-
-def self.spawn_optionify(*args)
-  if args.size == 1 && args.first.is_a?(Hash)
-    args.first
-  else
-    { class: args[0],
-      name:  args[1],
-      args:  args[2..-1] }
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/AdHoc.html b/docs/1.0.5/Concurrent/Actress/AdHoc.html deleted file mode 100644 index dd46b2f69..000000000 --- a/docs/1.0.5/Concurrent/Actress/AdHoc.html +++ /dev/null @@ -1,1389 +0,0 @@ - - - - - - Class: Concurrent::Actress::AdHoc - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::AdHoc - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
Context
- - - - - -
Defined in:
-
lib/concurrent/actress/ad_hoc.rb
- -
-
- -

Overview

-
-

Allows quick creation of actors with behaviour defined by blocks.

- - -
-
-
- -
-

Examples:

- - -

ping

-

- -
AdHoc.spawn :forward, an_actor do |where|
-  # this block has to return proc defining #on_message behaviour
-  -> message { where.tell message  }
-end
- -
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - included - from Context - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Constructor Details

- -
-

- - - (AdHoc) initialize(*args, &initializer) - - - - - -

-
-

Returns a new instance of AdHoc

- - -
-
-
- - -
- - - - -
-
-
-
-11
-12
-13
-
-
# File 'lib/concurrent/actress/ad_hoc.rb', line 11
-
-def initialize(*args, &initializer)
-  @on_message = Type! initializer.call(*args), Proc
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in module - Context - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Context - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - - - Originally defined in module - Context - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
-
- -
-

- - - (Object) on_message(message) - - - - - -

- - - - -
-
-
-
-15
-16
-17
-
-
# File 'lib/concurrent/actress/ad_hoc.rb', line 15
-
-def on_message(message)
-  instance_exec message, &@on_message
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminate! - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour.html b/docs/1.0.5/Concurrent/Actress/Behaviour.html deleted file mode 100644 index 67d1f7ef5..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - Module: Concurrent::Actress::Behaviour - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actress::Behaviour - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour/abstract.rb,
- lib/concurrent/actor/behaviour/error_on_unknown_message.rb
-
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: ErrorOnUnknownMessage - - -

- - - - - - - - - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/Abstract.html b/docs/1.0.5/Concurrent/Actress/Behaviour/Abstract.html deleted file mode 100644 index 7ba1f989a..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/Abstract.html +++ /dev/null @@ -1,1723 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::Abstract - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::Abstract - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
ContextDelegations, TypeCheck
- - - - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- -
-

Direct Known Subclasses

-

Buffer, DoContext, ErrorOnUnknownMessage, RemoveChild, Termination

-
- - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) context - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute context.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Abstract) initialize(core, subsequent) - - - - - -

-
-

Returns a new instance of Abstract

- - -
-
-
- - -
- - - - -
-
-
-
-47
-48
-49
-50
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 47
-
-def initialize(core, subsequent)
-  @context    = Type! context, Core
-  @subsequent = Type! subsequent, Abstract
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) context (readonly) - - - - - -

-
-

Returns the value of attribute context

- - -
-
-
- - -
- - - - -
-
-
-
-45
-46
-47
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 45
-
-def context
-  @context
-end
-
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
- - - - -
-
-
-
-45
-46
-47
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 45
-
-def subsequent
-  @subsequent
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Envelope) envelope - - - - - -

-
-

Returns current envelope, accessible inside #on_message processing

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Envelope) - - - - — -

    current envelope, accessible inside #on_message processing

    -
    - -
  • - -
- -
- - - - -
-
-
-
-65
-66
-67
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 65
-
-def envelope
-  @envelope or raise 'envelope not set'
-end
-
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, message = nil, &block) - - - - - - - Originally defined in module - ContextDelegations - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-57
-58
-59
-60
-61
-62
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 57
-
-def on_envelope(envelope)
-  @envelope = envelope
-  on_message envelope.message
-ensure
-  @envelope = nil
-end
-
-
- -
-

- - - (Object) on_message(message) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-52
-53
-54
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 52
-
-def on_message(message)
-  raise NotImplementedError
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) pass(envelope = self.envelope) - - - - - -

- - - - -
-
-
-
-69
-70
-71
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 69
-
-def pass(envelope = self.envelope)
-  subsequent.on_envelope envelope
-end
-
-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reject_envelope(envelope) - - - - - -

- - - - -
-
-
-
-77
-78
-79
-80
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 77
-
-def reject_envelope(envelope)
-  envelope.reject! ActressTerminated.new(reference)
-  dead_letter_routing << envelope unless envelope.ivar
-end
-
-
- -
-

- - - (Object) reject_messages - - - - - -

- - - - -
-
-
-
-73
-74
-75
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 73
-
-def reject_messages
-  subsequent.reject_messages if subsequent
-end
-
-
- -
-

- - - (Object) spawn(*args, &block) - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminate! - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

-
    - -
  • Core#terminate!
  • - -
- -
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/Buffer.html b/docs/1.0.5/Concurrent/Actress/Behaviour/Buffer.html deleted file mode 100644 index 866ee0989..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/Buffer.html +++ /dev/null @@ -1,688 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::Buffer - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::Buffer - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) context - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute context.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Buffer) initialize(context, subsequent) - - - - - -

-
-

Returns a new instance of Buffer

- - -
-
-
- - -
- - - - -
-
-
-
-130
-131
-132
-133
-134
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 130
-
-def initialize(context, subsequent)
-  super context, subsequent
-  @buffer                     = []
-  @receive_envelope_scheduled = false
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) context (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute context

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-136
-137
-138
-139
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 136
-
-def on_envelope(envelope)
-  @buffer.push envelope
-  process_envelopes?
-end
-
-
- -
-

- - - (Boolean) process_envelopes? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-141
-142
-143
-144
-145
-146
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 141
-
-def process_envelopes?
-  unless @buffer.empty? || @receive_envelope_scheduled
-    @receive_envelope_scheduled = true
-    schedule_execution { receive_envelope }
-  end
-end
-
-
- -
-

- - - (Object) receive_envelope - - - - - -

- - - - -
-
-
-
-148
-149
-150
-151
-152
-153
-154
-155
-156
-157
-158
-159
-160
-161
-162
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 148
-
-def receive_envelope
-  envelope = @buffer.shift
-
-  result = pass # FIXME when to collect results, probably buffers, first is mandatory and in core
-  envelope.ivar.set result unless envelope.ivar.nil?
-  nil
-
-rescue => error
-  log ERROR, error
-  terminate!
-  envelope.ivar.fail error unless envelope.ivar.nil?
-ensure
-  @receive_envelope_scheduled = false
-  process_envelopes?
-end
-
-
- -
-

- - - (Object) reject_messages - - - - - -

- - - - -
-
-
-
-164
-165
-166
-167
-168
-169
-170
-171
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 164
-
-def reject_messages
-  @buffer.each do |envelope|
-    reject_envelope envelope
-    log DEBUG, "rejected #{envelope.message} from #{envelope.sender_path}"
-  end
-  @buffer.clear
-  super
-end
-
-
- -
-

- - - (Object) schedule_execution(&block) - - - - - -

- - - - -
-
-
-
-173
-174
-175
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 173
-
-def schedule_execution(&block)
-  core.schedule_execution &block
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/DoContext.html b/docs/1.0.5/Concurrent/Actress/Behaviour/DoContext.html deleted file mode 100644 index b96d6c515..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/DoContext.html +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::DoContext - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::DoContext - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) context - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute context.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actress::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) context (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute context

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-179
-180
-181
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 179
-
-def on_envelope(envelope)
-  context.on_envelope envelope || pass
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/ErrorOnUnknownMessage.html b/docs/1.0.5/Concurrent/Actress/Behaviour/ErrorOnUnknownMessage.html deleted file mode 100644 index c91bb3d74..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/ErrorOnUnknownMessage.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::ErrorOnUnknownMessage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::ErrorOnUnknownMessage - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actor/behaviour/error_on_unknown_message.rb
- -
-
- - - - - - - - - - - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/RemoveChild.html b/docs/1.0.5/Concurrent/Actress/Behaviour/RemoveChild.html deleted file mode 100644 index 627655107..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/RemoveChild.html +++ /dev/null @@ -1,357 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::RemoveChild - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::RemoveChild - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) context - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute context.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Actress::Behaviour::Abstract

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) context (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute context

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-120
-121
-122
-123
-124
-125
-126
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 120
-
-def on_envelope(envelope)
-  if envelope.message == :remove_child
-    core.remove_child envelope.sender
-  else
-    pass envelope
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Behaviour/Termination.html b/docs/1.0.5/Concurrent/Actress/Behaviour/Termination.html deleted file mode 100644 index 2e472ae78..000000000 --- a/docs/1.0.5/Concurrent/Actress/Behaviour/Termination.html +++ /dev/null @@ -1,591 +0,0 @@ - - - - - - Class: Concurrent::Actress::Behaviour::Termination - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Behaviour::Termination - - - -

- -
- -
Inherits:
-
- Abstract - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) context - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute context.

    -
    - -
  • - - -
  • - - - - (Object) subsequent - - - - - - - inherited - from Abstract - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute subsequent.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Termination) initialize(context, subsequent) - - - - - -

-
-

Returns a new instance of Termination

- - -
-
-
- - -
- - - - -
-
-
-
-84
-85
-86
-87
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 84
-
-def initialize(context, subsequent)
-  super context, subsequent
-  @terminated = Event.new
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) context (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute context

- - -
-
-
- - -
-
- - - -
-

- - - (Object) subsequent (readonly) - - - - - - - Originally defined in class - Abstract - - -

-
-

Returns the value of attribute subsequent

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_envelope(envelope) - - - - - -

- - - - -
-
-
-
-95
-96
-97
-98
-99
-100
-101
-102
-103
-104
-105
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 95
-
-def on_envelope(envelope)
-  if envelope.message == :terminate
-    terminate!
-  else
-    if terminated?
-      reject_envelope envelope
-    else
-      pass envelope
-    end
-  end
-end
-
-
- -
-

- - - (Object) terminate! - - - - - -

-
-

Terminates the actor. Any Envelope received after termination is rejected. -Terminates all its children, does not wait until they are terminated.

- - -
-
-
- - -
- - - - -
-
-
-
-109
-110
-111
-112
-113
-114
-115
-116
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 109
-
-def terminate!
-  return nil if terminated?
-  children.each { |ch| ch << :terminate }
-  @terminated.set
-  parent << :remove_child if parent
-  core.reject_messages
-  nil
-end
-
-
- -
-

- - - (true, false) terminated? - - - - - -

-
- -
- Note: -

Actor rejects envelopes when terminated.

-
-
- -

Returns if actor is terminated

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true, false) - - - - — -

    if actor is terminated

    -
    - -
  • - -
- -
- - - - -
-
-
-
-91
-92
-93
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 91
-
-def terminated?
-  @terminated.set?
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Context.html b/docs/1.0.5/Concurrent/Actress/Context.html deleted file mode 100644 index 2776ca491..000000000 --- a/docs/1.0.5/Concurrent/Actress/Context.html +++ /dev/null @@ -1,1445 +0,0 @@ - - - - - - Module: Concurrent::Actress::Context - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actress::Context - - - -

- -
- - - - - -
Includes:
-
CoreDelegations, TypeCheck
- - - - -
Included in:
-
AdHoc, Root
- - - -
Defined in:
-
lib/concurrent/actress/context.rb
- -
-
- -

Overview

-
-

This module is used to define actors. It can be included in any class, -only requirement is to override #on_message method.

- - -
-
-
- -
-

Examples:

- - -

ping

-

- -
class Ping
-  include Context
-  def on_message(message)
-    message
-  end
-end
-
-Ping.spawn(:ping1).ask(:m).value #=> :m
- -
- - -

Defined Under Namespace

-

- - - Modules: ClassMethods - - - - -

- - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/actress/context.rb', line 19
-
-def core
-  @core
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/actress/context.rb', line 44
-
-def children
-  core.children
-end
-
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-55
-56
-57
-
-
# File 'lib/concurrent/actress/context.rb', line 55
-
-def log(level, progname, message = nil, &block)
-  core.log(level, progname, message, &block)
-end
-
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-31
-32
-33
-34
-35
-36
-
-
# File 'lib/concurrent/actress/context.rb', line 31
-
-def on_envelope(envelope)
-  @envelope = envelope
-  on_message envelope.message
-ensure
-  @envelope = nil
-end
-
-
- -
-

- - - (Object) on_message(message) - - - - - -

-
-
- This method is abstract. -

override to define Actor's behaviour

-
-
- -
- Note: -

self should not be returned (or sent to other actors), Concurrent::Actress::CoreDelegations#reference should be used -instead

-
-
- -

Returns a result which will be used to set the IVar supplied to Reference#ask

- - -
-
-
-

Parameters:

-
    - -
  • - - message - - - (Object) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    a result which will be used to set the IVar supplied to Reference#ask

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/actress/context.rb', line 26
-
-def on_message(message)
-  raise NotImplementedError
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/actress/context.rb', line 39
-
-def spawn(*args, &block)
-  Actress.spawn(*args, &block)
-end
-
-
- -
-

- - - (Object) terminate! - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-49
-50
-51
-
-
# File 'lib/concurrent/actress/context.rb', line 49
-
-def terminate!
-  core.terminate!
-end
-
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Context/ClassMethods.html b/docs/1.0.5/Concurrent/Actress/Context/ClassMethods.html deleted file mode 100644 index 4899904f7..000000000 --- a/docs/1.0.5/Concurrent/Actress/Context/ClassMethods.html +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - Module: Concurrent::Actress::Context::ClassMethods - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actress::Context::ClassMethods - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/actress/context.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) spawn(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actress.spawn but class_name is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-77
-78
-79
-
-
# File 'lib/concurrent/actress/context.rb', line 77
-
-def spawn(name_or_opts, *args, &block)
-  Actress.spawn spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
-

- - - (Object) spawn!(name_or_opts, *args, &block) - - - - - -

-
-

behaves as Concurrent::Actress.spawn! but class_name is auto-inserted based on receiver

- - -
-
-
- - -
- - - - -
-
-
-
-82
-83
-84
-
-
# File 'lib/concurrent/actress/context.rb', line 82
-
-def spawn!(name_or_opts, *args, &block)
-  Actress.spawn! spawn_optionify(name_or_opts, *args), &block
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/ContextDelegations.html b/docs/1.0.5/Concurrent/Actress/ContextDelegations.html deleted file mode 100644 index 475e4d425..000000000 --- a/docs/1.0.5/Concurrent/Actress/ContextDelegations.html +++ /dev/null @@ -1,854 +0,0 @@ - - - - - - Module: Concurrent::Actress::ContextDelegations - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actress::ContextDelegations - - - -

- -
- - - - - -
Includes:
-
CoreDelegations
- - - - -
Included in:
-
Behaviour::Abstract, Context
- - - -
Defined in:
-
lib/concurrent/actress/behaviour.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) children - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-12
-13
-14
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 12
-
-def children
-  core.children
-end
-
-
- -
-

- - - (Object) context - - - - - -

- - - - -
-
-
-
-27
-28
-29
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 27
-
-def context
-  context.dead_letter_routing
-end
-
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, message = nil, &block) - - - - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-23
-24
-25
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 23
-
-def log(level, message = nil, &block)
-  core.log(level, message, &block)
-end
-
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - -

-
- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-7
-8
-9
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 7
-
-def spawn(*args, &block)
-  Actress.spawn(*args, &block)
-end
-
-
- -
-

- - - (Object) terminate! - - - - - -

-
- - -
-
-
- - -

See Also:

-
    - -
  • Core#terminate!
  • - -
- -
- - - - -
-
-
-
-17
-18
-19
-
-
# File 'lib/concurrent/actress/behaviour.rb', line 17
-
-def terminate!
-  core.terminate!
-end
-
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Core.html b/docs/1.0.5/Concurrent/Actress/Core.html deleted file mode 100644 index d8dfa795a..000000000 --- a/docs/1.0.5/Concurrent/Actress/Core.html +++ /dev/null @@ -1,1936 +0,0 @@ - - - - - - Class: Concurrent::Actress::Core - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Core - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
TypeCheck, Logging
- - - - - -
Defined in:
-
lib/concurrent/actress/core.rb
- -
-
- -

Overview

-
- -
- Note: -

Whole class should be considered private. An user should use Contexts and References only.

-
-
- -
- Note: -

devel: core should not block on anything, e.g. it cannot wait on children to terminate -that would eat up all threads in task pool and deadlock

-
-
- -

Core of the actor

- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) actor_class - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute actor_class.

    -
    - -
  • - - -
  • - - - - (Executor) executor - - - - - - - - - readonly - - - - - - - - - -

    Which is used to process messages.

    -
    - -
  • - - -
  • - - - - (String) name - - - - - - - - - readonly - - - - - - - - - -

    The name of this instance, it should be uniq (not enforced right now).

    -
    - -
  • - - -
  • - - - - (String) path - - - - - - - - - readonly - - - - - - - - - -

    A path of this actor.

    -
    - -
  • - - -
  • - - - - (Reference) reference - - - - - - - - - readonly - - - - - - - - - -

    Reference to this actor which can be safely passed around.

    -
    - -
  • - - -
  • - - - - (Event) terminated - - - - - - - - - readonly - - - - - - - - - -

    Event which will become set when actor is terminated.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - -
-

Constructor Details

- -
-

- - - (Core) initialize(opts = {}, &block) - - - - - -

-
-

Returns a new instance of Core

- - -
-
-
-

Parameters:

-
    - -
  • - - block - - - (Proc) - - - - — -

    for class instantiation

    -
    - -
  • - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    a customizable set of options

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - name - (String) - - - - -
  • - -
  • - parent - (Reference, nil) - - - - - —

    of an actor spawning this one

    -
    - -
  • - -
  • - actor_class - (Context) - - - - - —

    a class to be instantiated defining Actor's behaviour

    -
    - -
  • - -
  • - args - (Array<Object>) - - - - - —

    arguments for actor_class instantiation

    -
    - -
  • - -
  • - executor, - (Executor) - - - - - —

    default is Concurrent.configuration.global_task_pool

    -
    - -
  • - -
  • - initialized, - (IVar, nil) - - - - - —

    if present it'll be set or failed after Concurrent::Actress::Context initialization

    -
    - -
  • - -
  • - logger - (Proc, nil) - - - - - —

    a proc accepting (level, progname, message = nil, &block) params, -can be used to hook actor instance to any logging system

    -
    - -
  • - -
- - - - - -
- - - - -
-
-
-
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-
-
# File 'lib/concurrent/actress/core.rb', line 41
-
-def initialize(opts = {}, &block)
-  @mailbox              = Array.new
-  @serialized_execution = SerializedExecution.new
-  # noinspection RubyArgCount
-  @terminated           = Event.new
-  @executor             = Type! opts.fetch(:executor, Concurrent.configuration.global_task_pool), Executor
-  @children             = Set.new
-  @reference            = Reference.new self
-  @name                 = (Type! opts.fetch(:name), String, Symbol).to_s
-  @actor                = Concurrent::Atomic.new
-
-  parent       = opts[:parent]
-  @parent_core = (Type! parent, Reference, NilClass) && parent.send(:core)
-  if @parent_core.nil? && @name != '/'
-    raise 'only root has no parent'
-  end
-
-  @path   = @parent_core ? File.join(@parent_core.path, @name) : @name
-  @logger = opts[:logger]
-
-  @parent_core.add_child reference if @parent_core
-
-  @actor_class = actor_class = Child! opts.fetch(:class), Context
-  args         = opts.fetch(:args, [])
-  initialized  = Type! opts[:initialized], IVar, NilClass
-
-  schedule_execution do
-    begin
-      @actor.value = actor_class.new(*args, &block).
-          tap { |a| a.send :initialize_core, self }
-      initialized.set true if initialized
-    rescue => ex
-      log ERROR, ex
-      terminate!
-      initialized.fail ex if initialized
-    end
-  end
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) actor_class (readonly) - - - - - -

-
-

Returns the value of attribute actor_class

- - -
-
-
- - -
- - - - -
-
-
-
-30
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-attr_reader :reference, :name, :path, :executor, :terminated, :actor_class
-
-
- - - -
-

- - - (Executor) executor (readonly) - - - - - -

-
-

Returns which is used to process messages

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    which is used to process messages

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-attr_reader :reference, :name, :path, :executor, :terminated, :actor_class
-
-
- - - -
-

- - - (String) name (readonly) - - - - - -

-
-

Returns the name of this instance, it should be uniq (not enforced right now)

- - -
-
-
- -

Returns:

-
    - -
  • - - - (String) - - - - — -

    the name of this instance, it should be uniq (not enforced right now)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-attr_reader :reference, :name, :path, :executor, :terminated, :actor_class
-
-
- - - -
-

- - - (String) path (readonly) - - - - - -

-
-

Returns a path of this actor. It is used for easier orientation and logging. -Path is constructed recursively with: parent.path + self.name up to a ROOT, -e.g. /an_actor/its_child. -(It will also probably form a supervision path (failures will be reported up to parents) -in future versions.)

- - -
-
-
- -

Returns:

-
    - -
  • - - - (String) - - - - — -

    a path of this actor. It is used for easier orientation and logging. -Path is constructed recursively with: parent.path + self.name up to a ROOT, -e.g. /an_actor/its_child. -(It will also probably form a supervision path (failures will be reported up to parents) -in future versions.)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-attr_reader :reference, :name, :path, :executor, :terminated, :actor_class
-
-
- - - -
-

- - - (Reference) reference (readonly) - - - - - -

-
-

Returns reference to this actor which can be safely passed around

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Reference) - - - - — -

    reference to this actor which can be safely passed around

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-def reference
-  @reference
-end
-
-
- - - -
-

- - - (Event) terminated (readonly) - - - - - -

-
-

Returns event which will become set when actor is terminated.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Event) - - - - — -

    event which will become set when actor is terminated.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-
-
# File 'lib/concurrent/actress/core.rb', line 30
-
-attr_reader :reference, :name, :path, :executor, :terminated, :actor_class
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) add_child(child) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-92
-93
-94
-95
-96
-97
-
-
# File 'lib/concurrent/actress/core.rb', line 92
-
-def add_child(child)
-  guard!
-  Type! child, Reference
-  @children.add child
-  nil
-end
-
-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Array<Reference>) children - - - - - -

-
-

Returns of children actors

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Reference>) - - - - — -

    of children actors

    -
    - -
  • - -
- -
- - - - -
-
-
-
-86
-87
-88
-89
-
-
# File 'lib/concurrent/actress/core.rb', line 86
-
-def children
-  guard!
-  @children.to_a
-end
-
-
- -
-

- - - (Object) guard! - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

-

ensures that we are inside of the executor

- - -
-
-
- - -
- - - - -
-
-
-
-153
-154
-155
-156
-157
-
-
# File 'lib/concurrent/actress/core.rb', line 153
-
-def guard!
-  unless Actress.current == reference
-    raise "can be called only inside actor #{reference} but was #{Actress.current}"
-  end
-end
-
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) on_envelope(envelope) - - - - - -

-
-

is executed by Reference scheduling processing of new messages -can be called from other alternative Reference implementations

- - -
-
-
-

Parameters:

-
    - -
  • - - envelope - - - (Envelope) - - - -
  • - -
- - -
- - - - -
-
-
-
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-
-
# File 'lib/concurrent/actress/core.rb', line 111
-
-def on_envelope(envelope)
-  schedule_execution do
-    if terminated?
-      reject_envelope envelope
-    else
-      @mailbox.push envelope
-    end
-    process_envelopes?
-  end
-  nil
-end
-
-
- -
-

- - - (Reference?) parent - - - - - -

-
-

Returns of parent actor

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Reference, nil) - - - - — -

    of parent actor

    -
    - -
  • - -
- -
- - - - -
-
-
-
-81
-82
-83
-
-
# File 'lib/concurrent/actress/core.rb', line 81
-
-def parent
-  @parent_core && @parent_core.reference
-end
-
-
- -
-

- - - (Object) remove_child(child) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-100
-101
-102
-103
-104
-105
-106
-
-
# File 'lib/concurrent/actress/core.rb', line 100
-
-def remove_child(child)
-  schedule_execution do
-    Type! child, Reference
-    @children.delete child
-  end
-  nil
-end
-
-
- -
-

- - - (Object) terminate! - - - - - -

-
-

Terminates the actor. Any Envelope received after termination is rejected. -Terminates all its children, does not wait until they are terminated.

- - -
-
-
- - -
- - - - -
-
-
-
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140
-141
-142
-143
-144
-145
-146
-147
-148
-149
-
-
# File 'lib/concurrent/actress/core.rb', line 131
-
-def terminate!
-  guard!
-  return nil if terminated?
-
-  @children.each do |ch|
-    ch.send(:core).tap { |core| core.send(:schedule_execution) { core.terminate! } }
-  end
-
-  @terminated.set
-
-  @parent_core.remove_child reference if @parent_core
-  @mailbox.each do |envelope|
-    reject_envelope envelope
-    log DEBUG, "rejected #{envelope.message} from #{envelope.sender_path}"
-  end
-  @mailbox.clear
-
-  nil
-end
-
-
- -
-

- - - (true, false) terminated? - - - - - -

-
- -
- Note: -

Actor rejects envelopes when terminated.

-
-
- -

Returns if actor is terminated

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true, false) - - - - — -

    if actor is terminated

    -
    - -
  • - -
- -
- - - - -
-
-
-
-125
-126
-127
-
-
# File 'lib/concurrent/actress/core.rb', line 125
-
-def terminated?
-  @terminated.set?
-end
-
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/CoreDelegations.html b/docs/1.0.5/Concurrent/Actress/CoreDelegations.html deleted file mode 100644 index b83469e36..000000000 --- a/docs/1.0.5/Concurrent/Actress/CoreDelegations.html +++ /dev/null @@ -1,596 +0,0 @@ - - - - - - Module: Concurrent::Actress::CoreDelegations - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Actress::CoreDelegations - - - -

- -
- - - - - - - -
Included in:
-
Context, Reference
- - - -
Defined in:
-
lib/concurrent/actress/core_delegations.rb
- -
-
- -

Overview

-
-

Provides publicly expose-able methods from Core.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - -

- - - - -
-
-
-
-34
-35
-36
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 34
-
-def actor_class
-  core.actor_class
-end
-
-
- -
-

- - - (Object) executor - - - - - -

- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 30
-
-def executor
-  core.executor
-end
-
-
- -
-

- - - (Object) name - - - - - -

- - - - -
-
-
-
-6
-7
-8
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 6
-
-def name
-  core.name
-end
-
-
- -
-

- - - (Object) parent - - - - - -

- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 14
-
-def parent
-  core.parent
-end
-
-
- -
-

- - - (Object) path - - - - - -

- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 10
-
-def path
-  core.path
-end
-
-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 26
-
-def reference
-  core.reference
-end
-
-
- -
-

- - - (Object) terminated - - - - - -

- - - - -
-
-
-
-22
-23
-24
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 22
-
-def terminated
-  core.terminated
-end
-
-
- -
-

- - - (Boolean) terminated? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-18
-19
-20
-
-
# File 'lib/concurrent/actress/core_delegations.rb', line 18
-
-def terminated?
-  core.terminated?
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/DefaultDeadLetterHandler.html b/docs/1.0.5/Concurrent/Actress/DefaultDeadLetterHandler.html deleted file mode 100644 index 20d78ba16..000000000 --- a/docs/1.0.5/Concurrent/Actress/DefaultDeadLetterHandler.html +++ /dev/null @@ -1,1458 +0,0 @@ - - - - - - Class: Concurrent::Actress::DefaultDeadLetterHandler - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::DefaultDeadLetterHandler - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
Context
- - - - - -
Defined in:
-
lib/concurrent/actress/default_dead_letter_handler.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - included - from Context - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in module - Context - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) behaviour - - - - - - - Originally defined in module - Context - - -

-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) context - - - - - - - Originally defined in module - ContextDelegations - - -

-
- -
-

- - - (Reference) dead_letter_routing - - - - - - - Originally defined in module - Context - - -

-
-

Defines an actor responsible for dead letters. Any rejected message send with -Reference#tell is sent there, a message with ivar is considered already monitored for -failures. Default behaviour is to use #dead_letter_routing of the parent, -so if no #dead_letter_routing method is overridden in parent-chain the message ends up in -Actress.root.dead_letter_routing agent which will log warning.

- - -
-
-
- -

Returns:

- - -
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, message = nil, &block) - - - - - - - Originally defined in module - ContextDelegations - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - - - Originally defined in module - Context - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
-
- -
-

- - - (Object) on_message(dead_letter) - - - - - -

- - - - -
-
-
-
-6
-7
-8
-
-
# File 'lib/concurrent/actress/default_dead_letter_handler.rb', line 6
-
-def on_message(dead_letter)
-  log Logging::WARN, "got dead letter #{dead_letter.inspect}"
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminate! - - - - - - - Originally defined in module - ContextDelegations - - -

-
- - -
-
-
- - -

See Also:

-
    - -
  • Core#terminate!
  • - -
- -
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/LazyRegister.html b/docs/1.0.5/Concurrent/Actress/LazyRegister.html deleted file mode 100644 index 25b2a4dec..000000000 --- a/docs/1.0.5/Concurrent/Actress/LazyRegister.html +++ /dev/null @@ -1,497 +0,0 @@ - - - - - - Class: Concurrent::Actress::LazyRegister - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::LazyRegister - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/actress/lazy_register.rb
- -
-
- -

Overview

-
-

Implements lazy register for actors (or other objects)

- - -
-
-
- -
-

Examples:

- - -
register = Actress::LazyRegister.new
-#=> #<Concurrent::Actress::LazyRegister:0x007fd7ecd5e230 @data=#<Concurrent::Atomic:0x007fd7ecd5e1e0>>
-register[:key]
-#=> nil
-register.add(:key) { Actress.spawn(Actress::AdHoc, :ping) { -> message { message } } }
-#=> #<Concurrent::Actress::LazyRegister:0x007fd7ecd5e230 @data=#<Concurrent::Atomic:0x007fd7ecd5e1e0>>
-register[:key]
-#=> #<Concurrent::Actress::Reference /ping (Concurrent::Actress::AdHoc)>
- -
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (LazyRegister) initialize - - - - - -

-
-

Returns a new instance of LazyRegister

- - -
-
-
- - -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/actress/lazy_register.rb', line 19
-
-def initialize
-  @data = Atomic.new Hash.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) [](key) - - - - - -

- - - - -
-
-
-
-23
-24
-25
-26
-
-
# File 'lib/concurrent/actress/lazy_register.rb', line 23
-
-def [](key)
-  delay = @data.get[key]
-  delay.value! if delay
-end
-
-
- -
-

- - - (Object) register(key, &block) - - - - Also known as: - add - - - - -

- - - - -
-
-
-
-34
-35
-36
-37
-38
-
-
# File 'lib/concurrent/actress/lazy_register.rb', line 34
-
-def register(key, &block)
-  delay = Delay.new(&block)
-  @data.update { |h| h.merge key => delay }
-  self
-end
-
-
- -
-

- - - (Boolean) registered?(key) - - - - Also known as: - key? - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-28
-29
-30
-
-
# File 'lib/concurrent/actress/lazy_register.rb', line 28
-
-def registered?(key)
-  @data.get.key? key
-end
-
-
- -
-

- - - (Object) unregister(key) - - - - Also known as: - remove - - - - -

- - - - -
-
-
-
-42
-43
-44
-45
-
-
# File 'lib/concurrent/actress/lazy_register.rb', line 42
-
-def unregister(key)
-  @data.update { |h| h.dup.tap { |h| h.delete(key) } }
-  self
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Reference.html b/docs/1.0.5/Concurrent/Actress/Reference.html deleted file mode 100644 index eedf14dcf..000000000 --- a/docs/1.0.5/Concurrent/Actress/Reference.html +++ /dev/null @@ -1,1409 +0,0 @@ - - - - - - Class: Concurrent::Actress::Reference - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Reference - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
CoreDelegations, TypeCheck
- - - - - -
Defined in:
-
lib/concurrent/actress/reference.rb
- -
-
- -

Overview

-
-

Reference is public interface of Actor instances. It is used for sending messages and can -be freely passed around the program. It also provides some basic information about the actor, -see CoreDelegations.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) ==(other) - - - - - -

- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/actress/reference.rb', line 59
-
-def ==(other)
-  Type? other, self.class and other.send(:core) == core
-end
-
-
- -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (IVar) ask(message, ivar = IVar.new) - - - - - -

-
-

tells message to the actor

- - -
-
-
-

Parameters:

-
    - -
  • - - message - - - (Object) - - - -
  • - -
  • - - ivar - - - (Ivar) - - - (defaults to: IVar.new) - - - — -

    to be fulfilled be message's processing result

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (IVar) - - - - — -

    supplied ivar

    -
    - -
  • - -
- -
- - - - -
-
-
-
-32
-33
-34
-
-
# File 'lib/concurrent/actress/reference.rb', line 32
-
-def ask(message, ivar = IVar.new)
-  message message, ivar
-end
-
-
- -
-

- - - (Object) ask!(message, ivar = IVar.new) - - - - - -

-
- -
- Note: -

can lead to deadlocks, use only in tests or when you are sure it won't deadlock

-
-
- -

tells message to the actor

- - -
-
-
-

Parameters:

-
    - -
  • - - message - - - (Object) - - - -
  • - -
  • - - ivar - - - (Ivar) - - - (defaults to: IVar.new) - - - — -

    to be fulfilled be message's processing result

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    message's processing result

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (Exception) - - - - — -

    ivar.reason if ivar is #rejected?

    -
    - -
  • - -
- -
- - - - -
-
-
-
-42
-43
-44
-
-
# File 'lib/concurrent/actress/reference.rb', line 42
-
-def ask!(message, ivar = IVar.new)
-  ask(message, ivar).value!
-end
-
-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) message(message, ivar = nil) - - - - - -

-
-

behaves as #tell when no ivar and as #ask when ivar

- - -
-
-
- - -
- - - - -
-
-
-
-47
-48
-49
-50
-51
-
-
# File 'lib/concurrent/actress/reference.rb', line 47
-
-def message(message, ivar = nil)
-  # TODO if ivar nil create IVar placing the message in dead letter route
-  core.on_envelope Envelope.new(message, ivar, Actress.current || Thread.current, self)
-  return ivar || self
-end
-
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Reference) tell(message) - - - - Also known as: - << - - - - -

-
-

tells message to the actor

- - -
-
-
-

Parameters:

-
    - -
  • - - message - - - (Object) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Reference) - - - - — -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-22
-23
-24
-
-
# File 'lib/concurrent/actress/reference.rb', line 22
-
-def tell(message)
-  message message, nil
-end
-
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) to_s - - - - Also known as: - inspect - - - - -

- - - - -
-
-
-
-53
-54
-55
-
-
# File 'lib/concurrent/actress/reference.rb', line 53
-
-def to_s
-  "#<#{self.class} #{path} (#{actor_class})>"
-end
-
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Root.html b/docs/1.0.5/Concurrent/Actress/Root.html deleted file mode 100644 index d7ea59452..000000000 --- a/docs/1.0.5/Concurrent/Actress/Root.html +++ /dev/null @@ -1,1325 +0,0 @@ - - - - - - Class: Concurrent::Actress::Root - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Actress::Root - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
Context
- - - - - -
Defined in:
-
lib/concurrent/actress.rb
- -
-
- -

Overview

-
-

implements ROOT

- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) core - - - - - - - included - from Context - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute core.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) core (readonly) - - - - - - - Originally defined in module - Context - - -

-
-

Returns the value of attribute core

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) actor_class - - - - Also known as: - actress_class - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) Child!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Child?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) children - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) executor - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Context - - -

-
-

delegates to core.log

- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) Match!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Match?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) name - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) on_envelope(envelope) - - - - - - - Originally defined in module - Context - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
-
- -
-

- - - (Object) on_message(message) - - - - - -

-
-

to allow spawning of new actors, spawn needs to be called inside the parent Actor

- - -
-
-
- - -
- - - - -
-
-
-
-152
-153
-154
-155
-156
-157
-158
-
-
# File 'lib/concurrent/actress.rb', line 152
-
-def on_message(message)
-  if message.is_a?(Array) && message.first == :spawn
-    spawn message[1], &message[2]
-  else
-    # ignore
-  end
-end
-
-
- -
-

- - - (Object) parent - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) path - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) reference - - - - Also known as: - ref - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Object) spawn(*args, &block) - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminate! - - - - - - - Originally defined in module - Context - - -

-
- - -
-
-
- - -

See Also:

- - -
-
- -
-

- - - (Object) terminated - - - - - - - Originally defined in module - CoreDelegations - - -

-
- -
-

- - - (Boolean) terminated? - - - - - - - Originally defined in module - CoreDelegations - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Object) Type!(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- -
-

- - - (Boolean) Type?(value, *types) - - - - - - - Originally defined in module - TypeCheck - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Agent.html b/docs/1.0.5/Concurrent/Agent.html index ce3bad326..e52e3e8b8 100644 --- a/docs/1.0.5/Concurrent/Agent.html +++ b/docs/1.0.5/Concurrent/Agent.html @@ -3751,9 +3751,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Agent::Rescuer - - - -

- -
- -
Inherits:
-
- Struct - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/agent.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) block - - - - - - - - - - - private - - - - - -

    Returns the value of attribute block.

    -
    - -
  • - - -
  • - - - - (Object) clazz - - - - - - - - - - - private - - - - - -

    Returns the value of attribute clazz.

    -
    - -
  • - - -
- - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) block (private) - - - - - -

-
-

Returns the value of attribute block

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of block

    -
    - -
  • - -
- -
- - - - -
-
-
-
-188
-189
-190
-
-
# File 'lib/concurrent/agent.rb', line 188
-
-def block
-  @block
-end
-
-
- - - -
-

- - - (Object) clazz (private) - - - - - -

-
-

Returns the value of attribute clazz

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of clazz

    -
    - -
  • - -
- -
- - - - -
-
-
-
-188
-189
-190
-
-
# File 'lib/concurrent/agent.rb', line 188
-
-def clazz
-  @clazz
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Agent/ValidationError.html b/docs/1.0.5/Concurrent/Agent/ValidationError.html index 0b972fa0d..350e2ac26 100644 --- a/docs/1.0.5/Concurrent/Agent/ValidationError.html +++ b/docs/1.0.5/Concurrent/Agent/ValidationError.html @@ -211,9 +211,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Async::AsyncDelegator - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/async.rb
- -
-
- -

Overview

-
-

Delegates asynchronous, thread-safe method calls to the wrapped object.

- - -
-
-
- -

Since:

-
    - -
  • - - - - - -

    0.6.0

    -
    - -
  • - -
- -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (AsyncDelegator) initialize(delegate, executor, serializer, blocking = false) - - - - - -

-
-

Create a new delegator object wrapping the given delegate, -protecting it with the given serializer, and executing it on the -given executor. Block if necessary.

- - -
-
-
-

Parameters:

-
    - -
  • - - delegate - - - (Object) - - - - — -

    the object to wrap and delegate method calls to

    -
    - -
  • - -
  • - - executor - - - (Concurrent::Delay) - - - - — -

    a Delay wrapping the executor on which to execute delegated method calls

    -
    - -
  • - -
  • - - serializer - - - (Concurrent::SerializedExecution) - - - - — -

    the serializer to use when delegating method calls

    -
    - -
  • - -
  • - - blocking - - - (Boolean) - - - (defaults to: false) - - - — -

    will block awaiting result when true

    -
    - -
  • - -
- -

Since:

-
    - -
  • - - - - - -

    0.6.0

    -
    - -
  • - -
- -
- - - - -
-
-
-
-140
-141
-142
-143
-144
-145
-
-
# File 'lib/concurrent/async.rb', line 140
-
-def initialize(delegate, executor, serializer, blocking = false)
-  @delegate = delegate
-  @executor = executor
-  @serializer = serializer
-  @blocking = blocking
-end
-
-
- -
-
-

Dynamic Method Handling

-

- This class handles dynamic methods through the method_missing method - -

- -
-

- - - (IVar) method_missing(method, *args, &block) - - - - - -

-
-

Delegates method calls to the wrapped object. For performance, -dynamically defines the given method on the delegator so that -all future calls to method will not be directed here.

- - -
-
-
-

Parameters:

-
    - -
  • - - method - - - (Symbol) - - - - — -

    the method being called

    -
    - -
  • - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to the method

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (IVar) - - - - — -

    the result of the method call

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (NameError) - - - - — -

    the object does not respond to method method

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    the given args do not match the arity of method

    -
    - -
  • - -
-

Since:

-
    - -
  • - - - - - -

    0.6.0

    -
    - -
  • - -
- -
- - - - -
-
-
-
-158
-159
-160
-161
-162
-163
-164
-165
-166
-167
-168
-169
-170
-171
-172
-173
-174
-175
-176
-177
-178
-179
-180
-
-
# File 'lib/concurrent/async.rb', line 158
-
-def method_missing(method, *args, &block)
-  super unless @delegate.respond_to?(method)
-  Async::validate_argc(@delegate, method, *args)
-
-  self.define_singleton_method(method) do |*args|
-    Async::validate_argc(@delegate, method, *args)
-    ivar = Concurrent::IVar.new
-    value, reason = nil, nil
-    @serializer.post(@executor.value) do
-      begin
-        value = @delegate.send(method, *args, &block)
-      rescue => reason
-        # caught
-      ensure
-        ivar.complete(reason.nil?, value, reason)
-      end
-    end
-    ivar.value if @blocking
-    ivar
-  end
-
-  self.send(method, *args)
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Atom.html b/docs/1.0.5/Concurrent/Atom.html index 7601c2a79..31a22160a 100644 --- a/docs/1.0.5/Concurrent/Atom.html +++ b/docs/1.0.5/Concurrent/Atom.html @@ -1453,9 +1453,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Atomic - - - -

- -
- -
Inherits:
-
- MutexAtomic - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic.rb,
- lib/concurrent/atomic.rb,
lib/concurrent/atomic.rb,
lib/concurrent/atomic.rb
-
- -
-
- -

Overview

-
-

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
- - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::MutexAtomic

- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AtomicBoolean.html b/docs/1.0.5/Concurrent/AtomicBoolean.html index 5824219de..d93b9dd03 100644 --- a/docs/1.0.5/Concurrent/AtomicBoolean.html +++ b/docs/1.0.5/Concurrent/AtomicBoolean.html @@ -904,9 +904,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::AtomicDirectUpdate - - - -

- -
- - - - - - - -
Included in:
-
CAtomic, JavaAtomic, MutexAtomic, RbxAtomic
- - - -
Defined in:
-
lib/concurrent/atomic_reference/direct_update.rb
- -
-
- -

Overview

-
-

Define update methods that use direct paths

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) try_update {|Object| ... } - - - - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. Raise an exception if the update -fails.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
-

Raises:

- - -
- - - - -
-
-
-
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-
-
# File 'lib/concurrent/atomic_reference/direct_update.rb', line 37
-
-def try_update
-  old_value = get
-  new_value = yield old_value
-  unless compare_and_set(old_value, new_value)
-    if $VERBOSE
-      raise ConcurrentUpdateError, "Update failed"
-    else
-      raise ConcurrentUpdateError, "Update failed", ConcurrentUpdateError::CONC_UP_ERR_BACKTRACE
-    end
-  end
-  new_value
-end
-
-
- -
-

- - - (Object) update {|Object| ... } - - - - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. May retry if the value changes -during the block's execution.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-22
-
-
# File 'lib/concurrent/atomic_reference/direct_update.rb', line 19
-
-def update
-  true until compare_and_set(old_value = get, new_value = yield(old_value))
-  new_value
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AtomicFixnum.html b/docs/1.0.5/Concurrent/AtomicFixnum.html index b93f5706d..34c0fb58d 100644 --- a/docs/1.0.5/Concurrent/AtomicFixnum.html +++ b/docs/1.0.5/Concurrent/AtomicFixnum.html @@ -1050,9 +1050,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::AtomicNumericCompareAndSetWrapper - - - -

- -
- - - - - - - -
Included in:
-
CAtomic, MutexAtomic, RbxAtomic
- - - -
Defined in:
-
lib/concurrent/atomic_reference/numeric_cas_wrapper.rb
- -
-
- -

Overview

-
-

Special "compare and set" handling of numeric values.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Boolean) compare_and_set(old_value, new_value) - - - - Also known as: - compare_and_swap - - - - -

-
-

Atomically sets the value to the given updated value if -the current value == the expected value.

- -

that the actual value was not equal to the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if successful. A false return indicates

    -
    - -
  • - -
- -
- - - - -
-
-
-
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-
-
# File 'lib/concurrent/atomic_reference/numeric_cas_wrapper.rb', line 7
-
-def compare_and_set(old_value, new_value)
-  if old_value.kind_of? Numeric
-    while true
-      old = get
-
-      return false unless old.kind_of? Numeric
-
-      return false unless old == old_value
-
-      result = _compare_and_set(old, new_value)
-      return result if result
-    end
-  else
-    _compare_and_set(old_value, new_value)
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/AtomicReference.html b/docs/1.0.5/Concurrent/AtomicReference.html index 78056265f..0a14d3591 100644 --- a/docs/1.0.5/Concurrent/AtomicReference.html +++ b/docs/1.0.5/Concurrent/AtomicReference.html @@ -725,9 +725,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::BlockingRingBuffer - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/collection/blocking_ring_buffer.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Integer) capacity - - - - - - - - - - - - - -

    The capacity of the buffer.

    -
    - -
  • - - -
  • - - - - (Integer) count - - - - - - - - - - - - - -

    The number of elements currently in the buffer.

    -
    - -
  • - - -
  • - - - - (Boolean) empty? - - - - - - - - - - - - - -

    True if buffer is empty, false otherwise.

    -
    - -
  • - - -
  • - - - - (Boolean) full? - - - - - - - - - - - - - -

    True if buffer is full, false otherwise.

    -
    - -
  • - - -
  • - - - - (BlockingRingBuffer) initialize(capacity) - - - - - - - constructor - - - - - - - - -

    A new instance of BlockingRingBuffer.

    -
    - -
  • - - -
  • - - - - (Object) peek - - - - - - - - - - - - - -

    The first available value and without removing it from the buffer.

    -
    - -
  • - - -
  • - - - - (Boolean) put(value) - - - - - - - - - - - - - -

    True if value has been inserted, false otherwise.

    -
    - -
  • - - -
  • - - - - (Object) take - - - - - - - - - - - - - -

    The first available value and removes it from the buffer.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (BlockingRingBuffer) initialize(capacity) - - - - - -

-
-

Returns a new instance of BlockingRingBuffer

- - -
-
-
- - -
- - - - -
-
-
-
-6
-7
-8
-9
-10
-11
-12
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 6
-
-def initialize(capacity)
-  @buffer = RingBuffer.new(capacity)
-  @first = @last = 0
-  @count = 0
-  @mutex = Mutex.new
-  @condition = Condition.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Integer) capacity - - - - - -

-
-

Returns the capacity of the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the capacity of the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-15
-16
-17
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 15
-
-def capacity
-  @mutex.synchronize { @buffer.capacity }
-end
-
-
- -
-

- - - (Integer) count - - - - - -

-
-

Returns the number of elements currently in the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the number of elements currently in the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-20
-21
-22
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 20
-
-def count
-  @mutex.synchronize { @buffer.count }
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if buffer is empty, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is empty, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-25
-26
-27
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 25
-
-def empty?
-  @mutex.synchronize { @buffer.empty? }
-end
-
-
- -
-

- - - (Boolean) full? - - - - - -

-
-

Returns true if buffer is full, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is full, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 30
-
-def full?
-  @mutex.synchronize { @buffer.full? }
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Returns the first available value and without removing it from -the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and without removing it from -the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-58
-59
-60
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 58
-
-def peek
-  @mutex.synchronize { @buffer.peek }
-end
-
-
- -
-

- - - (Boolean) put(value) - - - - - -

-
-

Returns true if value has been inserted, false otherwise

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Object) - - - - — -

    the value to be inserted

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if value has been inserted, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-36
-37
-38
-39
-40
-41
-42
-43
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 36
-
-def put(value)
-  @mutex.synchronize do
-    wait_while_full
-    @buffer.offer(value)
-    @condition.signal
-    true
-  end
-end
-
-
- -
-

- - - (Object) take - - - - - -

-
-

Returns the first available value and removes it from the buffer. -If buffer is empty it blocks until an element is available

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and removes it from the buffer. -If buffer is empty it blocks until an element is available

    -
    - -
  • - -
- -
- - - - -
-
-
-
-47
-48
-49
-50
-51
-52
-53
-54
-
-
# File 'lib/concurrent/collection/blocking_ring_buffer.rb', line 47
-
-def take
-  @mutex.synchronize do
-    wait_while_empty
-    result = @buffer.poll
-    @condition.signal
-    result
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/BufferedChannel.html b/docs/1.0.5/Concurrent/BufferedChannel.html deleted file mode 100644 index e08c67f24..000000000 --- a/docs/1.0.5/Concurrent/BufferedChannel.html +++ /dev/null @@ -1,563 +0,0 @@ - - - - - - Class: Concurrent::BufferedChannel - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::BufferedChannel - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/buffered_channel.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (BufferedChannel) initialize(size) - - - - - -

-
-

Returns a new instance of BufferedChannel

- - -
-
-
- - -
- - - - -
-
-
-
-8
-9
-10
-11
-12
-13
-14
-15
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 8
-
-def initialize(size)
-  @mutex = Mutex.new
-  @condition = Condition.new
-  @buffer_condition = Condition.new
-
-  @probe_set = WaitableList.new
-  @buffer = RingBuffer.new(size)
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) buffer_queue_size - - - - - -

- - - - -
-
-
-
-21
-22
-23
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 21
-
-def buffer_queue_size
-  @mutex.synchronize { @buffer.count }
-end
-
-
- -
-

- - - (Object) pop - - - - - -

- - - - -
-
-
-
-30
-31
-32
-33
-34
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 30
-
-def pop
-  probe = Channel::Probe.new
-  select(probe)
-  probe.value
-end
-
-
- -
-

- - - (Object) probe_set_size - - - - - -

- - - - -
-
-
-
-17
-18
-19
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 17
-
-def probe_set_size
-  @probe_set.size
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

- - - - -
-
-
-
-25
-26
-27
-28
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 25
-
-def push(value)
-  until set_probe_or_push_into_buffer(value)
-  end
-end
-
-
- -
-

- - - (Object) remove_probe(probe) - - - - - -

- - - - -
-
-
-
-49
-50
-51
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 49
-
-def remove_probe(probe)
-  @probe_set.delete(probe)
-end
-
-
- -
-

- - - (Object) select(probe) - - - - - -

- - - - -
-
-
-
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 36
-
-def select(probe)
-  @mutex.synchronize do
-
-    if @buffer.empty?
-      @probe_set.put(probe)
-      true
-    else
-      shift_buffer if probe.set_unless_assigned(peek_buffer, self)
-    end
-
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/CAtomic.html b/docs/1.0.5/Concurrent/CAtomic.html deleted file mode 100644 index 07006800a..000000000 --- a/docs/1.0.5/Concurrent/CAtomic.html +++ /dev/null @@ -1,808 +0,0 @@ - - - - - - Class: Concurrent::CAtomic - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::CAtomic - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
AtomicDirectUpdate, AtomicNumericCompareAndSetWrapper
- - - - - -
Defined in:
-
lib/concurrent/atomic_reference/ruby.rb
- -
-
- -

Overview

-
-

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Constructor Details

- -
-

- - - (Object) initialize - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic_reference/ruby.rb', line 13
-
-
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) _compare_and_set - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic_reference/ruby.rb', line 25
-
-
-
-
- -
-

- - - (Boolean) compare_and_set(old_value, new_value) - - - - Also known as: - compare_and_swap - - - - - - Originally defined in module - AtomicNumericCompareAndSetWrapper - - -

-
-

Atomically sets the value to the given updated value if -the current value == the expected value.

- -

that the actual value was not equal to the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if successful. A false return indicates

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) get - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic_reference/ruby.rb', line 16
-
-
-
-
- -
-

- - - (Object) get_and_set - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic_reference/ruby.rb', line 22
-
-
-
-
- -
-

- - - (Object) set - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic_reference/ruby.rb', line 19
-
-
-
-
- -
-

- - - (Object) try_update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. Raise an exception if the update -fails.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
-

Raises:

- - -
-
- -
-

- - - (Object) update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. May retry if the value changes -during the block's execution.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/CAtomicBoolean.html b/docs/1.0.5/Concurrent/CAtomicBoolean.html deleted file mode 100644 index b1ec92da3..000000000 --- a/docs/1.0.5/Concurrent/CAtomicBoolean.html +++ /dev/null @@ -1,739 +0,0 @@ - - - - - - Class: Concurrent::CAtomicBoolean - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::CAtomicBoolean - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_boolean.rb
- -
-
- -

Overview

-
-

A boolean value that can be updated atomically. Reads and writes to an atomic -boolean and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicBoolean...
-  2.790000   0.000000   2.790000 (  2.791454)
-Testing with Concurrent::CAtomicBoolean...
-  0.740000   0.000000   0.740000 (  0.740206)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicBoolean...
-  5.240000   2.520000   7.760000 (  3.683000)
-Testing with Concurrent::JavaAtomicBoolean...
-  3.340000   0.010000   3.350000 (  0.855000)
-
- - -
-
-
- - -

See Also:

- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Boolean) false? - - - - - - - - - - - - - -

    Is the current value false.

    -
    - -
  • - - -
  • - - - - (Object) initialize - - - - - - - constructor - - - - - - - - -

    Creates a new AtomicBoolean with the given initial value.

    -
    - -
  • - - -
  • - - - - (Boolean) make_false - - - - - - - - - - - - - -

    Explicitly sets the value to false.

    -
    - -
  • - - -
  • - - - - (Boolean) make_true - - - - - - - - - - - - - -

    Explicitly sets the value to true.

    -
    - -
  • - - -
  • - - - - (Boolean) true? - - - - - - - - - - - - - -

    Is the current value true.

    -
    - -
  • - - -
  • - - - - (Boolean) value - - - - - - - - - - - - - -

    Retrieves the current Boolean value.

    -
    - -
  • - - -
  • - - - - (Boolean) value= - - - - - - - - - - - - - -

    Explicitly sets the value.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (Object) initialize - - - - - -

-
-

Creates a new AtomicBoolean with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - initial - - - (Boolean) - - - - — -

    the initial value

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 126
-
-
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) false? - - - - - -

-
-

Is the current value false

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is false, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 138
-
-
-
-
- -
-

- - - (Boolean) make_false - - - - - -

-
-

Explicitly sets the value to false.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 146
-
-
-
-
- -
-

- - - (Boolean) make_true - - - - - -

-
-

Explicitly sets the value to true.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 141
-
-
-
-
- -
-

- - - (Boolean) true? - - - - - -

-
-

Is the current value true

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is true, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 135
-
-
-
-
- -
-

- - - (Boolean) value - - - - - -

-
-

Retrieves the current Boolean value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 129
-
-
-
-
- -
-

- - - (Boolean) value= - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Boolean) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 132
-
-
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/CAtomicFixnum.html b/docs/1.0.5/Concurrent/CAtomicFixnum.html deleted file mode 100644 index 550999899..000000000 --- a/docs/1.0.5/Concurrent/CAtomicFixnum.html +++ /dev/null @@ -1,732 +0,0 @@ - - - - - - Class: Concurrent::CAtomicFixnum - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::CAtomicFixnum - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_fixnum.rb
- -
-
- -

Overview

-
-

A numeric value that can be updated atomically. Reads and writes to an atomic -fixnum and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicFixnum...
-  3.130000   0.000000   3.130000 (  3.136505)
-Testing with Concurrent::CAtomicFixnum...
-  0.790000   0.000000   0.790000 (  0.785550)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicFixnum...
-  5.460000   2.460000   7.920000 (  3.715000)
-Testing with Concurrent::JavaAtomicFixnum...
-  4.520000   0.030000   4.550000 (  1.187000)
-
- - -
-
-
- - -

See Also:

- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Boolean) compare_and_set - - - - - - - - - - - - - -

    Atomically sets the value to the given updated value if the current value == the expected value.

    -
    - -
  • - - -
  • - - - - (Fixnum) decrement - - - - - - - - - - - - - -

    Decreases the current value by 1.

    -
    - -
  • - - -
  • - - - - (Fixnum) increment - - - - - - - - - - - - - -

    Increases the current value by 1.

    -
    - -
  • - - -
  • - - - - (Object) initialize - - - - - - - constructor - - - - - - - - -

    Creates a new AtomicFixnum with the given initial value.

    -
    - -
  • - - -
  • - - - - (Fixnum) value - - - - - - - - - - - - - -

    Retrieves the current Fixnum value.

    -
    - -
  • - - -
  • - - - - (Fixnum) value= - - - - - - - - - - - - - -

    Explicitly sets the value.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (Object) initialize - - - - - -

-
-

Creates a new AtomicFixnum with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - init - - - (Fixnum) - - - - — -

    the initial value

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the initial value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 132
-
-
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) compare_and_set - - - - - -

-
-

Atomically sets the value to the given updated value if the current -value == the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - expect - - - (Fixnum) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - update - - - (Fixnum) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the value was updated else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 149
-
-
-
-
- -
-

- - - (Fixnum) decrement - - - - - -

-
-

Decreases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after decrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 144
-
-
-
-
- -
-

- - - (Fixnum) increment - - - - - -

-
-

Increases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after incrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 141
-
-
-
-
- -
-

- - - (Fixnum) value - - - - - -

-
-

Retrieves the current Fixnum value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 135
-
-
-
-
- -
-

- - - (Fixnum) value= - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Fixnum) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the new value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 138
-
-
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/CachedThreadPool.html b/docs/1.0.5/Concurrent/CachedThreadPool.html index 498a3d2d6..9d5ff3616 100644 --- a/docs/1.0.5/Concurrent/CachedThreadPool.html +++ b/docs/1.0.5/Concurrent/CachedThreadPool.html @@ -1258,9 +1258,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Channel::BlockingRingBuffer - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/blocking_ring_buffer.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- - - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Integer) capacity - - - - - - - - - - - - - -

    The capacity of the buffer.

    -
    - -
  • - - -
  • - - - - (Integer) count - - - - - - - - - - - - - -

    The number of elements currently in the buffer.

    -
    - -
  • - - -
  • - - - - (Boolean) empty? - - - - - - - - - - - - - -

    True if buffer is empty, false otherwise.

    -
    - -
  • - - -
  • - - - - (Boolean) full? - - - - - - - - - - - - - -

    True if buffer is full, false otherwise.

    -
    - -
  • - - -
  • - - - - (BlockingRingBuffer) initialize(capacity) - - - - - - - constructor - - - - - - - - -

    A new instance of BlockingRingBuffer.

    -
    - -
  • - - -
  • - - - - (Object) peek - - - - - - - - - - - - - -

    The first available value and without removing it from the buffer.

    -
    - -
  • - - -
  • - - - - (Boolean) put(value) - - - - - - - - - - - - - -

    True if value has been inserted, false otherwise.

    -
    - -
  • - - -
  • - - - - (Object) take - - - - - - - - - - - - - -

    The first available value and removes it from the buffer.

    -
    - -
  • - - -
- - - - -
-

Constructor Details

- -
-

- - - (BlockingRingBuffer) initialize(capacity) - - - - - -

-
-

Returns a new instance of BlockingRingBuffer

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-13
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 10
-
-def initialize(capacity)
-  super()
-  synchronize { ns_initialize capacity}
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Integer) capacity - - - - - -

-
-

Returns the capacity of the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the capacity of the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-16
-17
-18
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 16
-
-def capacity
-  synchronize { @buffer.capacity }
-end
-
-
- -
-

- - - (Integer) count - - - - - -

-
-

Returns the number of elements currently in the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the number of elements currently in the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-21
-22
-23
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 21
-
-def count
-  synchronize { @buffer.count }
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if buffer is empty, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is empty, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 26
-
-def empty?
-  synchronize { @buffer.empty? }
-end
-
-
- -
-

- - - (Boolean) full? - - - - - -

-
-

Returns true if buffer is full, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is full, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-31
-32
-33
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 31
-
-def full?
-  synchronize { @buffer.full? }
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Returns the first available value and without removing it from -the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and without removing it from -the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 59
-
-def peek
-  synchronize { @buffer.peek }
-end
-
-
- -
-

- - - (Boolean) put(value) - - - - - -

-
-

Returns true if value has been inserted, false otherwise

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Object) - - - - — -

    the value to be inserted

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if value has been inserted, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-37
-38
-39
-40
-41
-42
-43
-44
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 37
-
-def put(value)
-  synchronize do
-    wait_while_full
-    @buffer.offer(value)
-    ns_signal
-    true
-  end
-end
-
-
- -
-

- - - (Object) take - - - - - -

-
-

Returns the first available value and removes it from the buffer. -If buffer is empty it blocks until an element is available

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and removes it from the buffer. -If buffer is empty it blocks until an element is available

    -
    - -
  • - -
- -
- - - - -
-
-
-
-48
-49
-50
-51
-52
-53
-54
-55
-
-
# File 'lib/concurrent/channel/blocking_ring_buffer.rb', line 48
-
-def take
-  synchronize do
-    wait_while_empty
-    result = @buffer.poll
-    ns_signal
-    result
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Channel/Buffer.html b/docs/1.0.5/Concurrent/Channel/Buffer.html index 211faad51..d64a0211b 100644 --- a/docs/1.0.5/Concurrent/Channel/Buffer.html +++ b/docs/1.0.5/Concurrent/Channel/Buffer.html @@ -108,9 +108,9 @@

Defined Under Namespace

- - - - - - - - - - - - - -

Class: Concurrent::Channel::BufferedChannel - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/buffered_channel.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- - - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Constructor Details

- -
-

- - - (BufferedChannel) initialize(size) - - - - - -

-
-

Returns a new instance of BufferedChannel

- - -
-
-
- - -
- - - - -
-
-
-
-11
-12
-13
-14
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 11
-
-def initialize(size)
-  super()
-  synchronize { ns_initialize(size) }
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) buffer_queue_size - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-20
-21
-22
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 20
-
-def buffer_queue_size
-  synchronize { @buffer.count }
-end
-
-
- -
-

- - - (Object) pop - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-29
-30
-31
-32
-33
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 29
-
-def pop
-  probe = Channel::Probe.new
-  select(probe)
-  probe.value
-end
-
-
- -
-

- - - (Object) probe_set_size - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-16
-17
-18
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 16
-
-def probe_set_size
-  @probe_set.size
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-24
-25
-26
-27
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 24
-
-def push(value)
-  until set_probe_or_ns_push_into_buffer(value)
-  end
-end
-
-
- -
-

- - - (Object) remove_probe(probe) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 46
-
-def remove_probe(probe)
-  @probe_set.delete(probe)
-end
-
-
- -
-

- - - (Object) select(probe) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-
-
# File 'lib/concurrent/channel/buffered_channel.rb', line 35
-
-def select(probe)
-  synchronize do
-    if @buffer.empty?
-      @probe_set.put(probe)
-      true
-    else
-      ns_shift_buffer if probe.try_set([ns_peek_buffer, self])
-    end
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Channel/Probe.html b/docs/1.0.5/Concurrent/Channel/Probe.html deleted file mode 100644 index 94b065cf7..000000000 --- a/docs/1.0.5/Concurrent/Channel/Probe.html +++ /dev/null @@ -1,516 +0,0 @@ - - - - - - Class: Concurrent::Channel::Probe - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Channel::Probe - - - -

- -
- -
Inherits:
-
- IVar - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/channel.rb
- -
-
- - -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

- - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Probe) initialize(value = NO_VALUE, opts = {}) - - - - - -

-
-

Returns a new instance of Probe

- - -
-
-
- - -
- - - - -
-
-
-
-8
-9
-10
-
-
# File 'lib/concurrent/channel/channel.rb', line 8
-
-def initialize(value = NO_VALUE, opts = {})
-  super(value, opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) observers (protected) - - - - - - - Originally defined in module - Observable - - -

-
-

Returns the value of attribute observers

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) channel - - - - - -

- - - - -
-
-
-
-28
-29
-30
-
-
# File 'lib/concurrent/channel/channel.rb', line 28
-
-def channel
-  composite_value.nil? ? nil : composite_value[1]
-end
-
-
- -
-

- - - (Object) composite_value - - - - - -

- - - - -
-
-
-
-22
-
-
# File 'lib/concurrent/channel/channel.rb', line 22
-
-alias_method :composite_value, :value
-
-
- -
-

- - - (Object) set_unless_assigned(value, channel) - - - - - -

- - - - -
-
-
-
-12
-13
-14
-15
-16
-17
-18
-19
-20
-
-
# File 'lib/concurrent/channel/channel.rb', line 12
-
-def set_unless_assigned(value, channel)
-  mutex.synchronize do
-    return false if [:fulfilled, :rejected].include? @state
-
-    set_state(true, [value, channel], nil)
-    event.set
-    true
-  end
-end
-
-
- -
-

- - - (Object) value - - - - - -

- - - - -
-
-
-
-24
-25
-26
-
-
# File 'lib/concurrent/channel/channel.rb', line 24
-
-def value
-  composite_value.nil? ? nil : composite_value[0]
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Channel/RingBuffer.html b/docs/1.0.5/Concurrent/Channel/RingBuffer.html deleted file mode 100644 index 5f13d47c2..000000000 --- a/docs/1.0.5/Concurrent/Channel/RingBuffer.html +++ /dev/null @@ -1,836 +0,0 @@ - - - - - - Class: Concurrent::Channel::RingBuffer - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Channel::RingBuffer - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/ring_buffer.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- -

non-thread safe buffer

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (RingBuffer) initialize(capacity) - - - - - -

-
-

Returns a new instance of RingBuffer

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-13
-14
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 10
-
-def initialize(capacity)
-  @buffer = ::Array.new(capacity)
-  @first = @last = 0
-  @count = 0
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Integer) capacity - - - - - -

-
-

Returns the capacity of the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the capacity of the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-18
-19
-20
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 18
-
-def capacity
-  @buffer.size
-end
-
-
- -
-

- - - (Integer) count - - - - - -

-
-

Returns the number of elements currently in the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the number of elements currently in the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-23
-24
-25
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 23
-
-def count
-  @count
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if buffer is empty, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is empty, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-28
-29
-30
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 28
-
-def empty?
-  @count == 0
-end
-
-
- -
-

- - - (Boolean) full? - - - - - -

-
-

Returns true if buffer is full, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is full, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-33
-34
-35
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 33
-
-def full?
-  @count == capacity
-end
-
-
- -
-

- - - (Boolean) offer(value) - - - - - -

-
-

Returns true if value has been inserted, false otherwise

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Object) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if value has been inserted, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-39
-40
-41
-42
-43
-44
-45
-46
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 39
-
-def offer(value)
-  return false if full?
-
-  @buffer[@last] = value
-  @last = (@last + 1) % @buffer.size
-  @count += 1
-  true
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Returns the first available value and without removing it from -the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and without removing it from -the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 59
-
-def peek
-  @buffer[@first]
-end
-
-
- -
-

- - - (Object) poll - - - - - -

-
-

Returns the first available value and removes it from the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and removes it from the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-49
-50
-51
-52
-53
-54
-55
-
-
# File 'lib/concurrent/channel/ring_buffer.rb', line 49
-
-def poll
-  result = @buffer[@first]
-  @buffer[@first] = nil
-  @first = (@first + 1) % @buffer.size
-  @count -= 1
-  result
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Channel/Selector/AfterClause.html b/docs/1.0.5/Concurrent/Channel/Selector/AfterClause.html index bc9afa037..7d9573c85 100644 --- a/docs/1.0.5/Concurrent/Channel/Selector/AfterClause.html +++ b/docs/1.0.5/Concurrent/Channel/Selector/AfterClause.html @@ -276,9 +276,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Channel::UnbufferedChannel - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/unbuffered_channel.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- - - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (UnbufferedChannel) initialize - - - - - -

-
-

Returns a new instance of UnbufferedChannel

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 10
-
-def initialize
-  @probe_set = WaitableList.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) pop - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-23
-24
-25
-26
-27
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 23
-
-def pop
-  probe = Channel::Probe.new
-  select(probe)
-  probe.value
-end
-
-
- -
-

- - - (Object) probe_set_size - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 14
-
-def probe_set_size
-  @probe_set.size
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-18
-19
-20
-21
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 18
-
-def push(value)
-  until @probe_set.take.try_set([value, self])
-  end
-end
-
-
- -
-

- - - (Object) remove_probe(probe) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-33
-34
-35
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 33
-
-def remove_probe(probe)
-  @probe_set.delete(probe)
-end
-
-
- -
-

- - - (Object) select(probe) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 29
-
-def select(probe)
-  @probe_set.put(probe)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Channel/ValidationError.html b/docs/1.0.5/Concurrent/Channel/ValidationError.html index cdd273ee4..c99db9dab 100644 --- a/docs/1.0.5/Concurrent/Channel/ValidationError.html +++ b/docs/1.0.5/Concurrent/Channel/ValidationError.html @@ -191,9 +191,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Channel::WaitableList - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/waitable_list.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- - - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Constructor Details

- -
-

- - - (WaitableList) initialize - - - - - -

-
-

Returns a new instance of WaitableList

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-13
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 10
-
-def initialize
-  super()
-  synchronize { ns_initialize }
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) delete(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 30
-
-def delete(value)
-  synchronize { @list.delete(value) }
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 19
-
-def empty?
-  synchronize { @list.empty? }
-end
-
-
- -
-

- - - (Object) put(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-23
-24
-25
-26
-27
-28
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 23
-
-def put(value)
-  synchronize do
-    @list << value
-    ns_signal
-  end
-end
-
-
- -
-

- - - (Object) size - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-15
-16
-17
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 15
-
-def size
-  synchronize { @list.size }
-end
-
-
- -
-

- - - (Object) take - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-34
-35
-36
-37
-38
-39
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 34
-
-def take
-  synchronize do
-    ns_wait_until { !@list.empty? }
-    @list.shift
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Collection.html b/docs/1.0.5/Concurrent/Collection.html deleted file mode 100644 index d8899078d..000000000 --- a/docs/1.0.5/Concurrent/Collection.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Module: Concurrent::Collection - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Collection - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/collection/priority_queue.rb,
- lib/concurrent/collection/copy_on_write_observer_set.rb,
lib/concurrent/collection/copy_on_notify_observer_set.rb
-
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: CopyOnNotifyObserverSet, CopyOnWriteObserverSet - - -

- -

Constant Summary

- - - - - - - - - - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Collection/CopyOnNotifyObserverSet.html b/docs/1.0.5/Concurrent/Collection/CopyOnNotifyObserverSet.html index 6021f5315..7a3d18ce9 100644 --- a/docs/1.0.5/Concurrent/Collection/CopyOnNotifyObserverSet.html +++ b/docs/1.0.5/Concurrent/Collection/CopyOnNotifyObserverSet.html @@ -874,9 +874,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Condition - - Deprecated - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/condition.rb
- -
-
- -

Overview

-
-
Deprecated.
-

Condition is a better implementation of standard Ruby ConditionVariable. The -biggest difference is the wait return value: Condition#wait returns -Condition::Result which make possible to know if waiting thread has been -woken up by an another thread (using #signal or #broadcast) or due to -timeout.

- -

Every #wait must be guarded by a locked Mutex or a ThreadError will be -risen. Although it's not mandatory, it's recommended to call also #signal -and #broadcast within the same mutex

- - -
-
-
- - -

Defined Under Namespace

-

- - - - - Classes: Result - - -

- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - -
-

Constructor Details

- -
-

- - - (Condition) initialize - - - - - -

-
-

Returns a new instance of Condition

- - -
-
-
- - -
- - - - -
-
-
-
-43
-44
-45
-46
-
-
# File 'lib/concurrent/atomic/condition.rb', line 43
-
-def initialize
-  deprecated 'Will be replaced with Synchronization::Object in v1.0.'
-  @condition = ConditionVariable.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (true) broadcast - - - - - -

-
-

Wakes up all waiting threads

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true) - - - -
  • - -
- -
- - - - -
-
-
-
-73
-74
-75
-76
-
-
# File 'lib/concurrent/atomic/condition.rb', line 73
-
-def broadcast
-  @condition.broadcast
-  true
-end
-
-
- -
-

- - - (Object) deprecated(message, strip = 2) - - - - - - - Originally defined in module - Concurrent::Concern::Deprecation - - -

-
- -
-

- - - (Object) deprecated_method(old_name, new_name) - - - - - - - Originally defined in module - Concurrent::Concern::Deprecation - - -

-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Concurrent::Concern::Logging - - -

-
-

Logs through Concurrent::Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (true) signal - - - - - -

-
-

Wakes up a waiting thread

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true) - - - -
  • - -
- -
- - - - -
-
-
-
-66
-67
-68
-69
-
-
# File 'lib/concurrent/atomic/condition.rb', line 66
-
-def signal
-  @condition.signal
-  true
-end
-
-
- -
-

- - - (Result) wait(mutex, timeout = nil) - - - - - -

-
- -
- Note: -

Time calculations one all platforms and languages are sensitive to -changes to the system clock. To alleviate the potential problems -associated with changing the system clock while an application is running, -most modern operating systems provide a monotonic clock that operates -independently of the system clock. A monotonic clock cannot be used to -determine human-friendly clock times. A monotonic clock is used exclusively -for calculating time intervals. Not all Ruby platforms provide access to an -operating system monotonic clock. On these platforms a pure-Ruby monotonic -clock will be used as a fallback. An operating system monotonic clock is both -faster and more reliable than the pure-Ruby implementation. The pure-Ruby -implementation should be fast and reliable enough for most non-realtime -operations. At this time the common Ruby platforms that provide access to an -operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

-
-
- - - -
-
-
-

Parameters:

-
    - -
  • - - mutex - - - (Mutex) - - - - — -

    the locked mutex guarding the wait

    -
    - -
  • - -
  • - - timeout - - - (Object) - - - (defaults to: nil) - - - — -

    nil means no timeout

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Result) - - - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-
-
# File 'lib/concurrent/atomic/condition.rb', line 53
-
-def wait(mutex, timeout = nil)
-  start_time = Concurrent.monotonic_time
-  @condition.wait(mutex, timeout)
-
-  if timeout.nil?
-    Result.new(nil)
-  else
-    Result.new(start_time + timeout - Concurrent.monotonic_time)
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Condition/Result.html b/docs/1.0.5/Concurrent/Condition/Result.html deleted file mode 100644 index 2714d6715..000000000 --- a/docs/1.0.5/Concurrent/Condition/Result.html +++ /dev/null @@ -1,467 +0,0 @@ - - - - - - Class: Concurrent::Condition::Result - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Condition::Result - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/condition.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) remaining_time - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute remaining_time.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Result) initialize(remaining_time) - - - - - - - constructor - - - - - - - - -

    A new instance of Result.

    -
    - -
  • - - -
  • - - - - (Boolean) timed_out? - - - - - - - - - - - - - -

    True if current thread has been waken up due to a timeout, otherwise false.

    -
    - -
  • - - -
  • - - - - (Boolean) woken_up? - - - - (also: #can_wait?) - - - - - - - - - - - -

    True if current thread has been waken up by a #signal or a #broadcast call , otherwise false.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (Result) initialize(remaining_time) - - - - - -

-
-

Returns a new instance of Result

- - -
-
-
- - -
- - - - -
-
-
-
-21
-22
-23
-
-
# File 'lib/concurrent/atomic/condition.rb', line 21
-
-def initialize(remaining_time)
-  @remaining_time = remaining_time
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) remaining_time (readonly) - - - - - -

-
-

Returns the value of attribute remaining_time

- - -
-
-
- - -
- - - - -
-
-
-
-25
-26
-27
-
-
# File 'lib/concurrent/atomic/condition.rb', line 25
-
-def remaining_time
-  @remaining_time
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) timed_out? - - - - - -

-
-

Returns true if current thread has been waken up due to a -timeout, otherwise false

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if current thread has been waken up due to a -timeout, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/concurrent/atomic/condition.rb', line 35
-
-def timed_out?
-  @remaining_time != nil && @remaining_time <= 0
-end
-
-
- -
-

- - - (Boolean) woken_up? - - - - Also known as: - can_wait? - - - - -

-
-

Returns true if current thread has been waken up by a #signal -or a #broadcast call , otherwise false

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if current thread has been waken up by a #signal -or a #broadcast call , otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/atomic/condition.rb', line 29
-
-def woken_up?
-  @remaining_time.nil? || @remaining_time > 0
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Configuration.html b/docs/1.0.5/Concurrent/Configuration.html deleted file mode 100644 index 2dc67ad05..000000000 --- a/docs/1.0.5/Concurrent/Configuration.html +++ /dev/null @@ -1,1246 +0,0 @@ - - - - - - Class: Concurrent::Configuration - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Configuration - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/configuration.rb
- -
-
- -

Overview

-
-

A gem-level configuration object.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - -
-

Constructor Details

- -
-

- - - (Configuration) initialize - - - - - -

-
-

Create a new configuration object.

- - -
-
-
- - -
- - - - -
-
-
-
-179
-180
-
-
# File 'lib/concurrent/configuration.rb', line 179
-
-def initialize
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) auto_terminate - - - - - -

-
-
Deprecated.

Use Concurrent.auto_terminate_global_executors? instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-260
-261
-262
-263
-
-
# File 'lib/concurrent/configuration.rb', line 260
-
-def auto_terminate
-  deprecated_method 'Concurrent.configuration.auto_terminate', 'Concurrent.auto_terminate_global_executors?'
-  Concurrent.auto_terminate_global_executors?
-end
-
-
- -
-

- - - (Object) auto_terminate=(value) - - - - - -

-
-
Deprecated.

Use Concurrent.disable_executor_auto_termination! instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-254
-255
-256
-257
-
-
# File 'lib/concurrent/configuration.rb', line 254
-
-def auto_terminate=(value)
-  deprecated_method 'Concurrent.configuration.auto_terminate=', 'Concurrent.disable_executor_auto_termination!'
-  Concurrent.disable_executor_auto_termination! if !value
-end
-
-
- -
-

- - - (Object) deprecated(message, strip = 2) - - - - - - - Originally defined in module - Concurrent::Concern::Deprecation - - -

-
- -
-

- - - (Object) deprecated_method(old_name, new_name) - - - - - - - Originally defined in module - Concurrent::Concern::Deprecation - - -

-
- -
-

- - - (Object) global_operation_pool - - - - - -

-
-
Deprecated.

Use Concurrent.global_fast_executor instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-214
-215
-216
-217
-
-
# File 'lib/concurrent/configuration.rb', line 214
-
-def global_operation_pool
-  deprecated_method 'Concurrent.configuration.global_operation_pool', 'Concurrent.global_fast_executor'
-  Concurrent.global_fast_executor
-end
-
-
- -
-

- - - (Object) global_operation_pool=(executor) - - - - - -

-
-
Deprecated.

Replacing global thread pools is deprecated. -Use the :executor constructor option instead.

-
- - -
-
-
- - -
- - - - -
-
-
-
-235
-236
-237
-238
-239
-
-
# File 'lib/concurrent/configuration.rb', line 235
-
-def global_operation_pool=(executor)
-  deprecated 'Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
-  GLOBAL_FAST_EXECUTOR.reconfigure { executor } or
-      raise ConfigurationError.new('global operation pool was already set')
-end
-
-
- -
-

- - - (Object) global_task_pool - - - - - -

-
-
Deprecated.

Use Concurrent.global_io_executor instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-208
-209
-210
-211
-
-
# File 'lib/concurrent/configuration.rb', line 208
-
-def global_task_pool
-  deprecated_method 'Concurrent.configuration.global_task_pool', 'Concurrent.global_io_executor'
-  Concurrent.global_io_executor
-end
-
-
- -
-

- - - (Object) global_task_pool=(executor) - - - - - -

-
-
Deprecated.

Replacing global thread pools is deprecated. -Use the :executor constructor option instead.

-
- - -
-
-
- - -
- - - - -
-
-
-
-227
-228
-229
-230
-231
-
-
# File 'lib/concurrent/configuration.rb', line 227
-
-def global_task_pool=(executor)
-  deprecated 'Replacing global thread pools is deprecated. Use the :executor constructor option instead.'
-  GLOBAL_IO_EXECUTOR.reconfigure { executor } or
-      raise ConfigurationError.new('global task pool was already set')
-end
-
-
- -
-

- - - (Object) global_timer_set - - - - - -

-
-
Deprecated.

Use Concurrent.global_timer_set instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-220
-221
-222
-223
-
-
# File 'lib/concurrent/configuration.rb', line 220
-
-def global_timer_set
-  deprecated_method 'Concurrent.configuration.global_timer_set', 'Concurrent.global_timer_set'
-  Concurrent.global_timer_set
-end
-
-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Concurrent::Concern::Logging - - -

-
-

Logs through Concurrent::Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) logger - - - - - -

-
-
Deprecated.

Use Concurrent.global_logger instead

-
-

a proc defining how to log messages, its interface has to be: - lambda { |level, progname, message = nil, &block| _ }

- - -
-
-
- - -
- - - - -
-
-
-
-193
-194
-195
-196
-
-
# File 'lib/concurrent/configuration.rb', line 193
-
-def logger
-  deprecated_method 'Concurrent.configuration.logger', 'Concurrent.global_logger'
-  Concurrent.global_logger.value
-end
-
-
- -
-

- - - (Object) logger=(value) - - - - - -

-
-
Deprecated.

Use Concurrent.global_logger instead

-
-

a proc defining how to log messages, its interface has to be: - lambda { |level, progname, message = nil, &block| _ }

- - -
-
-
- - -
- - - - -
-
-
-
-202
-203
-204
-205
-
-
# File 'lib/concurrent/configuration.rb', line 202
-
-def logger=(value)
-  deprecated_method 'Concurrent.configuration.logger=', 'Concurrent.global_logger='
-  Concurrent.global_logger = value
-end
-
-
- -
-

- - - (Object) new_operation_pool - - - - - -

-
-
Deprecated.

Use Concurrent.new_fast_executor instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-248
-249
-250
-251
-
-
# File 'lib/concurrent/configuration.rb', line 248
-
-def new_operation_pool
-  deprecated_method 'Concurrent.configuration.new_operation_pool', 'Concurrent.new_fast_executor'
-  Concurrent.new_fast_executor
-end
-
-
- -
-

- - - (Object) new_task_pool - - - - - -

-
-
Deprecated.

Use Concurrent.new_io_executor instead

-
- - -
-
-
- - -
- - - - -
-
-
-
-242
-243
-244
-245
-
-
# File 'lib/concurrent/configuration.rb', line 242
-
-def new_task_pool
-  deprecated_method 'Concurrent.configuration.new_task_pool', 'Concurrent.new_io_executor'
-  Concurrent.new_io_executor
-end
-
-
- -
-

- - - (Object) no_logger - - - - - -

-
-
Deprecated.

Use Concurrent::NULL_LOGGER instead

-
-

if assigned to #logger, it will log nothing.

- - -
-
-
- - -
- - - - -
-
-
-
-184
-185
-186
-187
-
-
# File 'lib/concurrent/configuration.rb', line 184
-
-def no_logger
-  deprecated_method 'Concurrent.configuration.no_logger', 'Concurrent::NULL_LOGGER'
-  NULL_LOGGER
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/CountDownLatch.html b/docs/1.0.5/Concurrent/CountDownLatch.html index aa098cc93..802905af8 100644 --- a/docs/1.0.5/Concurrent/CountDownLatch.html +++ b/docs/1.0.5/Concurrent/CountDownLatch.html @@ -521,9 +521,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::CyclicBarrier::Generation - - - -

- -
- -
Inherits:
-
- Struct - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/cyclic_barrier.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) status - - - - - - - - - - - - - - - - -

    Returns the value of attribute status.

    -
    - -
  • - - -
- - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) status - - - - - -

-
-

Returns the value of attribute status

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of status

    -
    - -
  • - -
- -
- - - - -
-
-
-
-5
-6
-7
-
-
# File 'lib/concurrent/atomic/cyclic_barrier.rb', line 5
-
-def status
-  @status
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Delay.html b/docs/1.0.5/Concurrent/Delay.html index 63f54bd02..d990e6adb 100644 --- a/docs/1.0.5/Concurrent/Delay.html +++ b/docs/1.0.5/Concurrent/Delay.html @@ -1714,9 +1714,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::DependencyCounter - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/dataflow.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (DependencyCounter) initialize(count, &block) - - - - - -

-
-

:nodoc:

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-13
-
-
# File 'lib/concurrent/dataflow.rb', line 10
-
-def initialize(count, &block)
-  @counter = AtomicFixnum.new(count)
-  @block = block
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) update(time, value, reason) - - - - - -

- - - - -
-
-
-
-15
-16
-17
-18
-19
-
-
# File 'lib/concurrent/dataflow.rb', line 15
-
-def update(time, value, reason)
-  if @counter.decrement == 0
-    @block.call
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Dereferenceable.html b/docs/1.0.5/Concurrent/Dereferenceable.html deleted file mode 100644 index e3b65bc14..000000000 --- a/docs/1.0.5/Concurrent/Dereferenceable.html +++ /dev/null @@ -1,688 +0,0 @@ - - - - - - Module: Concurrent::Dereferenceable - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Dereferenceable - - - -

- -
- - - - - - - -
Included in:
-
Agent, MVar, Obligation, TimerTask
- - - -
Defined in:
-
lib/concurrent/dereferenceable.rb
- -
-
- -

Overview

-
-

Object references in Ruby are mutable. This can lead to serious problems when -the #value of a concurrent object is a mutable reference. Which is always the -case unless the value is a Fixnum, Symbol, or similar "primitive" data type. -Most classes in this library that expose a #value getter method do so using the -Dereferenceable mixin module.

- -

Objects with this mixin can be configured with a few options that can help protect -the program from potentially dangerous operations.

- -
    -
  • :dup_on_deref when true will call the #dup method on the value -object every time the #value method is called (default: false)
  • -
  • :freeze_on_deref when true will call the #freeze method on the value object -every time the #value method is called (default: false)
  • -
  • :copy_on_deref when given a Proc object the Proc will be run every -time the #value method is called. The Proc will be given the current -value as its only parameter and the result returned by the block will -be the return value of the #value call. When nil this option will be -ignored (default: nil)
  • -
- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Object) init_mutex - - - - - - - - protected - - - - - -

    Initializes the internal Mutex.

    -
    - -
  • - - -
  • - - - - (Mutex) mutex - - - - - - - - protected - - - - - -

    A mutex lock used for synchronizing thread-safe operations.

    -
    - -
  • - - -
  • - - - - (Object) set_deref_options(opts = {}) - - - - - - - - protected - - - - - -

    Set the options which define the operations #value performs before returning data to the caller (dereferencing).

    -
    - -
  • - - -
  • - - - - (Object) value - - - - (also: #deref) - - - - - - - - - - - -

    Return the value this object represents after applying the options specified by the #set_deref_options method.

    -
    - -
  • - - -
  • - - - - (Object) value=(val) - - - - - - - - protected - - - - - -

    Set the internal value of this object.

    -
    - -
  • - - -
- - - - -
-

Instance Method Details

- - -
-

- - - (Object) init_mutex (protected) - - - - - -

-
- -
- Note: -

This method must be called from within the constructor of the including class.

-
-
- -

Initializes the internal Mutex.

- - -
-
-
- - -

See Also:

- - -
- - - - -
-
-
-
-77
-78
-79
-
-
# File 'lib/concurrent/dereferenceable.rb', line 77
-
-def init_mutex
-  @mutex = Mutex.new
-end
-
-
- -
-

- - - (Mutex) mutex (protected) - - - - - -

-
-

A mutex lock used for synchronizing thread-safe operations. Methods defined -by Dereferenceable are synchronized using the Mutex returned from this -method. Operations performed by the including class that operate on the -@value instance variable should be locked with this Mutex.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Mutex) - - - - — -

    the synchronization object

    -
    - -
  • - -
- -
- - - - -
-
-
-
-68
-69
-70
-
-
# File 'lib/concurrent/dereferenceable.rb', line 68
-
-def mutex
-  @mutex
-end
-
-
- -
-

- - - (Object) set_deref_options(opts = {}) (protected) - - - - - -

-
- -
- Note: -

Most classes that include this module will call #set_deref_options

-
-
- -

Set the options which define the operations #value performs before -returning data to the caller (dereferencing).

- -

from within the constructor, thus allowing these options to be set at -object creation.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining dereference behavior.

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :dup_on_deref - (String) - - - — default: - false - - - - —

    call #dup before returning the data

    -
    - -
  • - -
  • - :freeze_on_deref - (String) - - - — default: - false - - - - —

    call #freeze before returning the data

    -
    - -
  • - -
  • - :copy_on_deref - (String) - - - — default: - nil - - - - —

    call the given Proc passing -the internal value and returning the value returned from the proc

    -
    - -
  • - -
- - - -
- - - - -
-
-
-
-93
-94
-95
-96
-97
-98
-99
-100
-101
-102
-
-
# File 'lib/concurrent/dereferenceable.rb', line 93
-
-def set_deref_options(opts = {})
-  mutex.lock
-  @dup_on_deref = opts[:dup_on_deref] || opts[:dup]
-  @freeze_on_deref = opts[:freeze_on_deref] || opts[:freeze]
-  @copy_on_deref = opts[:copy_on_deref] || opts[:copy]
-  @do_nothing_on_deref = !(@dup_on_deref || @freeze_on_deref || @copy_on_deref)
-  nil
-ensure
-  mutex.unlock
-end
-
-
- -
-

- - - (Object) value - - - - Also known as: - deref - - - - -

-
-

Return the value this object represents after applying the options specified -by the #set_deref_options method.

- -

When multiple deref options are set the order of operations is strictly defined. -The order of deref operations is:

- -
    -
  • :copy_on_deref
  • -
  • :dup_on_deref
  • -
  • :freeze_on_deref
  • -
- -

Because of this ordering there is no need to #freeze an object created by a -provided :copy_on_deref block. Simply set :freeze_on_deref to true. -Setting both :dup_on_deref to true and :freeze_on_deref to true is -as close to the behavior of a "pure" functional language (like Erlang, Clojure, -or Haskell) as we are likely to get in Ruby.

- -

This method is thread-safe and synchronized with the internal #mutex.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of the object

    -
    - -
  • - -
- -
- - - - -
-
-
-
-41
-42
-43
-44
-45
-46
-
-
# File 'lib/concurrent/dereferenceable.rb', line 41
-
-def value
-  mutex.lock
-  apply_deref_options(@value)
-ensure
-  mutex.unlock
-end
-
-
- -
-

- - - (Object) value=(val) (protected) - - - - - -

-
-

Set the internal value of this object

- - -
-
-
-

Parameters:

-
    - -
  • - - val - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-55
-56
-57
-58
-59
-60
-
-
# File 'lib/concurrent/dereferenceable.rb', line 55
-
-def value=(val)
-  mutex.lock
-  @value = val
-ensure
-  mutex.unlock
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge.html b/docs/1.0.5/Concurrent/Edge.html index cd13ff855..308dd124e 100644 --- a/docs/1.0.5/Concurrent/Edge.html +++ b/docs/1.0.5/Concurrent/Edge.html @@ -141,9 +141,9 @@

Overview

- - - - - - - - - - - - - -

Class: Concurrent::Edge::Channel - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
- -
- Note: -

proof of concept

-
-
- - - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Constructor Details

- -
-

- - - (Channel) initialize - - - - - -

-
-

TODO make lock free

- - -
-
-
- - -
- - - - -
-
-
-
-1378
-1379
-1380
-1381
-1382
-
-
# File 'lib/concurrent/edge/future.rb', line 1378
-
-def initialize
-  super
-  @ProbeSet = Concurrent::Channel::WaitableList.new
-  ensure_ivar_visibility!
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) inspect - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-1402
-1403
-1404
-
-
# File 'lib/concurrent/edge/future.rb', line 1402
-
-def inspect
-  to_s
-end
-
-
- -
-

- - - (Object) pop - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-1393
-1394
-1395
-
-
# File 'lib/concurrent/edge/future.rb', line 1393
-
-def pop
-  select(Concurrent.future)
-end
-
-
- -
-

- - - (Object) probe_set_size - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-1384
-1385
-1386
-
-
# File 'lib/concurrent/edge/future.rb', line 1384
-
-def probe_set_size
-  @ProbeSet.size
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-1388
-1389
-1390
-1391
-
-
# File 'lib/concurrent/edge/future.rb', line 1388
-
-def push(value)
-  until @ProbeSet.take.try_success([value, self])
-  end
-end
-
-
- -
-

- - - (Object) select(probe) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-1397
-1398
-1399
-1400
-
-
# File 'lib/concurrent/edge/future.rb', line 1397
-
-def select(probe)
-  @ProbeSet.put(probe)
-  probe
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/CompletableEvent.html b/docs/1.0.5/Concurrent/Edge/CompletableEvent.html deleted file mode 100644 index 2794b8f96..000000000 --- a/docs/1.0.5/Concurrent/Edge/CompletableEvent.html +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - Class: Concurrent::Edge::CompletableEvent - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Edge::CompletableEvent - - - -

- -
- -
Inherits:
-
- Event - -
    -
  • Object
  • - - - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
-

A Event which can be completed by user.

- - -
-
-
- - -
-

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Edge::Event

- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) complete(raise_on_reassign = true) - - - - - -

-
-

Complete the Event, raise if already completed

- - -
-
-
- - -
- - - - -
-
-
-
-834
-835
-836
-
-
# File 'lib/concurrent/edge/future.rb', line 834
-
-def complete(raise_on_reassign = true)
-  complete_with COMPLETED, raise_on_reassign
-end
-
-
- -
-

- - - (Object) hide_completable - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-838
-839
-840
-
-
# File 'lib/concurrent/edge/future.rb', line 838
-
-def hide_completable
-  EventWrapperPromise.new(self, @DefaultExecutor).event
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/CompletableFuture.html b/docs/1.0.5/Concurrent/Edge/CompletableFuture.html deleted file mode 100644 index 32df9c9b1..000000000 --- a/docs/1.0.5/Concurrent/Edge/CompletableFuture.html +++ /dev/null @@ -1,711 +0,0 @@ - - - - - - Class: Concurrent::Edge::CompletableFuture - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Edge::CompletableFuture - - - -

- -
- -
Inherits:
-
- Future - -
    -
  • Object
  • - - - - - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
-

A Future which can be completed by user.

- - -
-
-
- - -
-

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Edge::Event

- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) complete(success, value, reason, raise_on_reassign = true) - - - - - -

-
-

Complete the future with triplet od success, value, reason -raise if already completed -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-848
-849
-850
-
-
# File 'lib/concurrent/edge/future.rb', line 848
-
-def complete(success, value, reason, raise_on_reassign = true)
-  complete_with(success ? Success.new(value) : Failed.new(reason), raise_on_reassign)
-end
-
-
- -
-

- - - (Object) evaluate_to(*args, &block) - - - - - -

-
-

Evaluate the future to value if there is an exception the future fails with it -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-878
-879
-880
-
-
# File 'lib/concurrent/edge/future.rb', line 878
-
-def evaluate_to(*args, &block)
-  promise.evaluate_to(*args, block)
-end
-
-
- -
-

- - - (Object) evaluate_to!(*args, &block) - - - - - -

-
-

Evaluate the future to value if there is an exception the future fails with it -return [self]

- - -
-
-
- -

Raises:

-
    - -
  • - - - - - - - -

    the exception

    -
    - -
  • - -
- -
- - - - -
-
-
-
-885
-886
-887
-
-
# File 'lib/concurrent/edge/future.rb', line 885
-
-def evaluate_to!(*args, &block)
-  promise.evaluate_to!(*args, block)
-end
-
-
- -
-

- - - (Object) fail(reason = StandardError.new) - - - - - -

-
-

Fail the future with reason -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-866
-867
-868
-
-
# File 'lib/concurrent/edge/future.rb', line 866
-
-def fail(reason = StandardError.new)
-  promise.fail(reason)
-end
-
-
- -
-

- - - (Object) hide_completable - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-889
-890
-891
-
-
# File 'lib/concurrent/edge/future.rb', line 889
-
-def hide_completable
-  FutureWrapperPromise.new(self, @DefaultExecutor).future
-end
-
-
- -
-

- - - (Object) success(value) - - - - - -

-
-

Complete the future with value -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-854
-855
-856
-
-
# File 'lib/concurrent/edge/future.rb', line 854
-
-def success(value)
-  promise.success(value)
-end
-
-
- -
-

- - - (Object) try_fail(reason = StandardError.new) - - - - - -

-
-

Try to fail the future with reason -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-872
-873
-874
-
-
# File 'lib/concurrent/edge/future.rb', line 872
-
-def try_fail(reason = StandardError.new)
-  promise.try_fail(reason)
-end
-
-
- -
-

- - - (Object) try_success(value) - - - - - -

-
-

Try to complete the future with value -return [self]

- - -
-
-
- - -
- - - - -
-
-
-
-860
-861
-862
-
-
# File 'lib/concurrent/edge/future.rb', line 860
-
-def try_success(value)
-  promise.try_success(value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/Event.html b/docs/1.0.5/Concurrent/Edge/Event.html deleted file mode 100644 index 9264e62c4..000000000 --- a/docs/1.0.5/Concurrent/Edge/Event.html +++ /dev/null @@ -1,1864 +0,0 @@ - - - - - - Class: Concurrent::Edge::Event - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Edge::Event - - - -

- -
- -
Inherits:
-
- Synchronization::LockableObject - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
-

Represents an event which will happen in future (will be completed). It has to always happen.

- - -
-
-
- - -
-

Direct Known Subclasses

-

CompletableEvent, Future

-
- -

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (Event) initialize(promise, default_executor) - - - - - -

-
-

Returns a new instance of Event

- - -
-
-
- - -
- - - - -
-
-
-
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-
-
# File 'lib/concurrent/edge/future.rb', line 189
-
-def initialize(promise, default_executor)
-  super()
-  @Promise            = promise
-  @DefaultExecutor    = default_executor
-  @Touched            = AtomicBoolean.new(false)
-  @Callbacks          = LockFreeStack.new
-  # TODO (pitr 12-Sep-2015): replace with AtomicFixnum, avoid aba problem
-  # TODO (pitr 12-Sep-2015): look at java.util.concurrent solution
-  @Waiters            = LockFreeStack.new
-  self.internal_state = PENDING
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) chain(executor = nil) {|success, value, reason| ... } - - - - Also known as: - then - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    of the parent

    -
    - -
  • - -
- -
- - - - -
-
-
-
-252
-253
-254
-
-
# File 'lib/concurrent/edge/future.rb', line 252
-
-def chain(executor = nil, &callback)
-  ChainPromise.new(self, @DefaultExecutor, executor || @DefaultExecutor, &callback).future
-end
-
-
- -
-

- - - (Object) chain_completable(completable_event) - - - - Also known as: - tangle - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-258
-259
-260
-
-
# File 'lib/concurrent/edge/future.rb', line 258
-
-def chain_completable(completable_event)
-  on_completion! { completable_event.complete_with COMPLETED }
-end
-
-
- -
-

- - - (Boolean) completed?(state = internal_state) - - - - Also known as: - complete? - - - - -

-
-

Has the Event been completed?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-220
-221
-222
-
-
# File 'lib/concurrent/edge/future.rb', line 220
-
-def completed?(state = internal_state)
-  state.completed?
-end
-
-
- -
-

- - - (Executor) default_executor - - - - - -

-
-

Returns current default executor

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    current default executor

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-247
-248
-249
-
-
# File 'lib/concurrent/edge/future.rb', line 247
-
-def default_executor
-  @DefaultExecutor
-end
-
-
- -
-

- - - (Event) delay - - - - - -

-
-

Inserts delay into the chain of Futures making rest of it lazy evaluated.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Event) - - - -
  • - -
- -
- - - - -
-
-
-
-278
-279
-280
-
-
# File 'lib/concurrent/edge/future.rb', line 278
-
-def delay
-  ZipEventEventPromise.new(self, Delay.new(@DefaultExecutor).event, @DefaultExecutor).event
-end
-
-
- -
-

- - - (Object) deprecated(message, strip = 2) - - - - - - - Originally defined in module - Concern::Deprecation - - -

-
- -
-

- - - (Object) deprecated_method(old_name, new_name) - - - - - - - Originally defined in module - Concern::Deprecation - - -

-
- -
-

- - - (Object) inspect - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-320
-321
-322
-
-
# File 'lib/concurrent/edge/future.rb', line 320
-
-def inspect
-  "#{to_s[0..-2]} blocks:[#{blocks.map(&:to_s).join(', ')}]>"
-end
-
-
- -
-

- - - (Object) internal_state - - - - - -

-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Concern::Logging - - -

-
-

Logs through Concurrent.global_logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) on_completion(executor = nil) {|success, value, reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    executed async on executor when completed

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-300
-301
-302
-
-
# File 'lib/concurrent/edge/future.rb', line 300
-
-def on_completion(executor = nil, &callback)
-  add_callback :pr_async_callback_on_completion, executor || @DefaultExecutor, callback
-end
-
-
- -
-

- - - (Object) on_completion! {|success, value, reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    executed sync when completed

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-306
-307
-308
-
-
# File 'lib/concurrent/edge/future.rb', line 306
-
-def on_completion!(&callback)
-  add_callback :pr_callback_on_completion, callback
-end
-
-
- -
-

- - - (Boolean) pending?(state = internal_state) - - - - Also known as: - incomplete? - - - - -

-
-

Is Event/Future pending?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-208
-209
-210
-
-
# File 'lib/concurrent/edge/future.rb', line 208
-
-def pending?(state = internal_state)
-  !state.completed?
-end
-
-
- -
-

- - - (Object) set(*args, &block) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-324
-325
-326
-327
-
-
# File 'lib/concurrent/edge/future.rb', line 324
-
-def set(*args, &block)
-  raise 'Use CompletableEvent#complete or CompletableFuture#complete instead, ' +
-            'constructed by Concurrent.event or Concurrent.future respectively.'
-end
-
-
- -
-

- - - (:pending, :completed) state - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (:pending, :completed) - - - -
  • - -
- -
- - - - -
-
-
-
-202
-203
-204
-
-
# File 'lib/concurrent/edge/future.rb', line 202
-
-def state
-  internal_state.to_sym
-end
-
-
- -
-

- - - (Future) then_select(*channels) - - - - - -

-
-

Zips with selected value form the suplied channels

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-294
-295
-296
-
-
# File 'lib/concurrent/edge/future.rb', line 294
-
-def then_select(*channels)
-  ZipFutureEventPromise(Concurrent.select(*channels), self, @DefaultExecutor).future
-end
-
-
- -
-

- - - (Object) to_s - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-316
-317
-318
-
-
# File 'lib/concurrent/edge/future.rb', line 316
-
-def to_s
-  "<##{self.class}:0x#{'%x' % (object_id << 1)} #{state.to_sym}>"
-end
-
-
- -
-

- - - (Boolean) unscheduled? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-212
-213
-214
-
-
# File 'lib/concurrent/edge/future.rb', line 212
-
-def unscheduled?
-  raise 'unsupported'
-end
-
-
- -
-

- - - (Event, ...) wait(timeout = nil) - - - - - -

-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Wait until Event is #complete?

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Numeric) - - - (defaults to: nil) - - - — -

    the maximum time in second to wait.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Event, true, false) - - - - — -

    self or true/false if timeout is used

    -
    - -
  • - -
- -
- - - - -
-
-
-
-232
-233
-234
-235
-236
-
-
# File 'lib/concurrent/edge/future.rb', line 232
-
-def wait(timeout = nil)
-  touch
-  result = wait_until_complete(timeout)
-  timeout ? result : self
-end
-
-
- -
-

- - - (Event) with_default_executor(executor) - - - - - -

-
-

Changes default executor for rest of the chain

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Event) - - - -
  • - -
- -
- - - - -
-
-
-
-312
-313
-314
-
-
# File 'lib/concurrent/edge/future.rb', line 312
-
-def with_default_executor(executor)
-  EventWrapperPromise.new(self, executor).future
-end
-
-
- -
-

- - - (Event) zip(other) - - - - Also known as: - & - - - - -

-
-

Zip with future producing new Future

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Event) - - - -
  • - -
- -
- - - - -
-
-
-
-266
-267
-268
-269
-270
-271
-272
-
-
# File 'lib/concurrent/edge/future.rb', line 266
-
-def zip(other)
-  if other.is?(Future)
-    ZipFutureEventPromise.new(other, self, @DefaultExecutor).future
-  else
-    ZipEventEventPromise.new(self, other, @DefaultExecutor).future
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/Future.html b/docs/1.0.5/Concurrent/Edge/Future.html deleted file mode 100644 index 55d759b11..000000000 --- a/docs/1.0.5/Concurrent/Edge/Future.html +++ /dev/null @@ -1,2546 +0,0 @@ - - - - - - Class: Concurrent::Edge::Future - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Edge::Future - - - -

- -
- -
Inherits:
-
- Event - -
    -
  • Object
  • - - - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
-

Represents a value which will become available in future. May fail with a reason instead.

- - -
-
-
- - -
-

Direct Known Subclasses

-

CompletableFuture

-
- -

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Edge::Event

- -
- - -
-

Instance Method Details

- - -
-

- - - (Future) any(*futures) - - - - Also known as: - | - - - - -

-
-

Returns which has first completed value from futures

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - - — -

    which has first completed value from futures

    -
    - -
  • - -
- -
- - - - -
-
-
-
-662
-663
-664
-
-
# File 'lib/concurrent/edge/future.rb', line 662
-
-def any(*futures)
-  AnyPromise.new([self, *futures], @DefaultExecutor).future
-end
-
-
- -
-

- - - (Object) chain_completable(completable_future) - - - - Also known as: - tangle - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-642
-643
-644
-
-
# File 'lib/concurrent/edge/future.rb', line 642
-
-def chain_completable(completable_future)
-  on_completion! { completable_future.complete_with internal_state }
-end
-
-
- -
-

- - - (Future) delay - - - - - -

-
-

Inserts delay into the chain of Futures making rest of it lazy evaluated.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-668
-669
-670
-
-
# File 'lib/concurrent/edge/future.rb', line 668
-
-def delay
-  ZipFutureEventPromise.new(self, Delay.new(@DefaultExecutor).future, @DefaultExecutor).future
-end
-
-
- -
-

- - - (Object) exception(*args) - - - - - -

-
- - -
-
-
- -
-

Examples:

- - -

allows failed Future to be risen

-

- -
raise Concurrent.future.fail
- -
- - -
- - - - -
-
-
-
-619
-620
-621
-622
-623
-624
-625
-626
-627
-628
-
-
# File 'lib/concurrent/edge/future.rb', line 619
-
-def exception(*args)
-  raise 'obligation is not failed' unless failed?
-  reason = internal_state.reason
-  if reason.is_a?(::Array)
-    reason.each { |e| log ERROR, 'Edge::Future', e }
-    Concurrent::Error.new 'multiple exceptions, inspect log'
-  else
-    reason.exception(*args)
-  end
-end
-
-
- -
-

- - - (Boolean) failed?(state = internal_state) - - - - - -

-
-

Has Future been failed?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-560
-561
-562
-
-
# File 'lib/concurrent/edge/future.rb', line 560
-
-def failed?(state = internal_state)
-  state.completed? && !state.success?
-end
-
-
- -
-

- - - (Object) flat(level = 1) - - - - - -

-
-

zips with the Future in the value

- - -
-
-
- -
-

Examples:

- - -
Concurrent.future { Concurrent.future { 1 } }.flat.vale # => 1
- -
- - -
- - - - -
-
-
-
-657
-658
-659
-
-
# File 'lib/concurrent/edge/future.rb', line 657
-
-def flat(level = 1)
-  FlatPromise.new(self, level, @DefaultExecutor).future
-end
-
-
- -
-

- - - (Boolean) fulfilled? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-553
-554
-555
-556
-
-
# File 'lib/concurrent/edge/future.rb', line 553
-
-def fulfilled?
-  deprecated_method 'fulfilled?', 'success?'
-  success?
-end
-
-
- -
-

- - - (Object) on_failure(executor = nil) {|reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed async on executor when failed?

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-722
-723
-724
-
-
# File 'lib/concurrent/edge/future.rb', line 722
-
-def on_failure(executor = nil, &callback)
-  add_callback :pr_async_callback_on_failure, executor || @DefaultExecutor, callback
-end
-
-
- -
-

- - - (Object) on_failure! {|reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed sync when failed?

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-734
-735
-736
-
-
# File 'lib/concurrent/edge/future.rb', line 734
-
-def on_failure!(&callback)
-  add_callback :pr_callback_on_failure, callback
-end
-
-
- -
-

- - - (Object) on_success(executor = nil) {|value| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed async on executor when success

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-716
-717
-718
-
-
# File 'lib/concurrent/edge/future.rb', line 716
-
-def on_success(executor = nil, &callback)
-  add_callback :pr_async_callback_on_success, executor || @DefaultExecutor, callback
-end
-
-
- -
-

- - - (Object) on_success! {|value| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed sync when success

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-728
-729
-730
-
-
# File 'lib/concurrent/edge/future.rb', line 728
-
-def on_success!(&callback)
-  add_callback :pr_callback_on_success, callback
-end
-
-
- -
-

- - - (Exception?) reason(timeout = nil) - - - - - -

-
- -
- Note: -

If the Future can have value nil then it cannot be distinquished from nil returned on timeout. -In this case is better to use first wait then value (or similar).

-
-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Returns the reason of the Future's failure

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Exception, nil) - - - - — -

    the reason of the Future's failure

    -
    - -
  • - -
- -
- - - - -
-
-
-
-582
-583
-584
-585
-
-
# File 'lib/concurrent/edge/future.rb', line 582
-
-def reason(timeout = nil)
-  touch
-  internal_state.reason if wait_until_complete timeout
-end
-
-
- -
-

- - - (Boolean) rejected? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-564
-565
-566
-567
-
-
# File 'lib/concurrent/edge/future.rb', line 564
-
-def rejected?
-  deprecated_method 'rejected?', 'failed?'
-  failed?
-end
-
-
- -
-

- - - (Future) rescue(executor = nil) {|reason| ... } - - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed only on parent failure

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-650
-651
-652
-
-
# File 'lib/concurrent/edge/future.rb', line 650
-
-def rescue(executor = nil, &callback)
-  RescuePromise.new(self, @DefaultExecutor, executor || @DefaultExecutor, &callback).future
-end
-
-
- -
-

- - - (Array(Boolean, Object, Exception)?) result(timeout = nil) - - - - - -

-
- -
- Note: -

If the Future can have value nil then it cannot be distinquished from nil returned on timeout. -In this case is better to use first wait then value (or similar).

-
-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Returns triplet of success, value, reason

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array(Boolean, Object, Exception), nil) - - - - — -

    triplet of success, value, reason

    -
    - -
  • - -
- -
- - - - -
-
-
-
-590
-591
-592
-593
-
-
# File 'lib/concurrent/edge/future.rb', line 590
-
-def result(timeout = nil)
-  touch
-  internal_state.result if wait_until_complete timeout
-end
-
-
- -
-

- - - (Future) schedule(intended_time) - - - - - -

-
-

Schedules rest of the chain for execution with specified time or on specified time

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-674
-675
-676
-677
-678
-679
-680
-
-
# File 'lib/concurrent/edge/future.rb', line 674
-
-def schedule(intended_time)
-  chain do
-    ZipFutureEventPromise.new(self,
-                              ScheduledPromise.new(@DefaultExecutor, intended_time).event,
-                              @DefaultExecutor).future
-  end.flat
-end
-
-
- -
-

- - - (:pending, ...) state - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (:pending, :success, :failed) - - - -
  • - -
- -
- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/edge/future.rb', line 544
-
-
-
-
- -
-

- - - (Boolean) success?(state = internal_state) - - - - - -

-
-

Has Future been success?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-549
-550
-551
-
-
# File 'lib/concurrent/edge/future.rb', line 549
-
-def success?(state = internal_state)
-  state.completed? && state.success?
-end
-
-
- -
-

- - - (Future) then(executor = nil) {|value| ... } - - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed only on parent success

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-632
-633
-634
-
-
# File 'lib/concurrent/edge/future.rb', line 632
-
-def then(executor = nil, &callback)
-  ThenPromise.new(self, @DefaultExecutor, executor || @DefaultExecutor, &callback).future
-end
-
-
- -
-

- - - (Future) then_ask(actor) - - - - - -

-
-

Asks the actor with its value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - - — -

    new future with the response form the actor

    -
    - -
  • - -
- -
- - - - -
-
-
-
-638
-639
-640
-
-
# File 'lib/concurrent/edge/future.rb', line 638
-
-def then_ask(actor)
-  self.then { |v| actor.ask(v) }.flat
-end
-
-
- -
-

- - - (Object) then_put(channel) - - - - - -

-
- -
- Note: -

may block

-
-
- -
- Note: -

only proof of concept

-
-
- - - -
-
-
- - -
- - - - -
-
-
-
-710
-711
-712
-
-
# File 'lib/concurrent/edge/future.rb', line 710
-
-def then_put(channel)
-  on_success(:io) { |value| channel.put value }
-end
-
-
- -
-

- - - (Future) then_select(*channels) - - - - - -

-
-

Zips with selected value form the suplied channels

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-684
-685
-686
-
-
# File 'lib/concurrent/edge/future.rb', line 684
-
-def then_select(*channels)
-  ZipFuturesPromise.new([self, Concurrent.select(*channels)], @DefaultExecutor).future
-end
-
-
- -
-

- - - (Object?) value(timeout = nil) - - - - - -

-
- -
- Note: -

If the Future can have value nil then it cannot be distinquished from nil returned on timeout. -In this case is better to use first wait then value (or similar).

-
-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Returns the value of the Future when success, nil on timeout

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object, nil) - - - - — -

    the value of the Future when success, nil on timeout

    -
    - -
  • - -
- -
- - - - -
-
-
-
-574
-575
-576
-577
-
-
# File 'lib/concurrent/edge/future.rb', line 574
-
-def value(timeout = nil)
-  touch
-  internal_state.value if wait_until_complete timeout
-end
-
-
- -
-

- - - (Object?) value!(timeout = nil) - - - - - -

-
- -
- Note: -

If the Future can have value nil then it cannot be distinquished from nil returned on timeout. -In this case is better to use first wait then value (or similar).

-
-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Wait until Future is #complete?

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Numeric) - - - (defaults to: nil) - - - — -

    the maximum time in second to wait.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object, nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - - - - - -

    reason on failure

    -
    - -
  • - -
- -
- - - - -
-
-
-
-612
-613
-614
-615
-
-
# File 'lib/concurrent/edge/future.rb', line 612
-
-def value!(timeout = nil)
-  touch
-  internal_state.value if wait_until_complete! timeout
-end
-
-
- -
-

- - - (Event, ...) wait!(timeout = nil) - - - - - -

-
- -
- Note: -

a thread should wait only once! For repeated checking use faster completed? check. -If thread waits periodically it will dangerously grow the waiters stack.

-
-
- -

Wait until Future is #complete?

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Numeric) - - - (defaults to: nil) - - - — -

    the maximum time in second to wait.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Event, true, false) - - - - — -

    self or true/false if timeout is used

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - - - - - -

    reason on failure

    -
    - -
  • - -
- -
- - - - -
-
-
-
-600
-601
-602
-603
-604
-
-
# File 'lib/concurrent/edge/future.rb', line 600
-
-def wait!(timeout = nil)
-  touch
-  result = wait_until_complete!(timeout)
-  timeout ? result : self
-end
-
-
- -
-

- - - (Future) with_default_executor(executor) - - - - - -

-
-

Changes default executor for rest of the chain

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-690
-691
-692
-
-
# File 'lib/concurrent/edge/future.rb', line 690
-
-def with_default_executor(executor)
-  FutureWrapperPromise.new(self, executor).future
-end
-
-
- -
-

- - - (Future) zip(other) - - - - Also known as: - & - - - - -

-
-

Zip with future producing new Future

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-696
-697
-698
-699
-700
-701
-702
-
-
# File 'lib/concurrent/edge/future.rb', line 696
-
-def zip(other)
-  if other.is_a?(Future)
-    ZipFutureFuturePromise.new(self, other, @DefaultExecutor).future
-  else
-    ZipFutureEventPromise.new(self, other, @DefaultExecutor).future
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/FutureShortcuts.html b/docs/1.0.5/Concurrent/Edge/FutureShortcuts.html deleted file mode 100644 index 8ac7265f8..000000000 --- a/docs/1.0.5/Concurrent/Edge/FutureShortcuts.html +++ /dev/null @@ -1,1749 +0,0 @@ - - - - - - Module: Concurrent::Edge::FutureShortcuts - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Edge::FutureShortcuts - - - -

- -
- - - - - - - -
Included in:
-
Concurrent, Concurrent, Concurrent::Edge, Concurrent::Edge
- - - -
Defined in:
-
lib/concurrent/edge/future.rb
- -
-
- -

Overview

-
- -
- Note: -

Edge Feature: Edge features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will -be obeyed though. Features developed in concurrent-ruby-edge are expected to move -to concurrent-ruby when final.

-
-
- -

Provides edge features, which will be added to or replace features in main gem.

- -

Contains new unified implementation of Futures and Promises which combines Features of previous Future, -Promise, IVar, Event, Probe, dataflow, Delay, TimerTask into single framework. It uses extensively -new synchronization layer to make all the paths lock-free with exception of blocking threads on #wait. -It offers better performance and does not block threads (exception being #wait and similar methods where it's -intended).

- -

Examples

- -

### Simple asynchronous task
-
-future = Concurrent.future { sleep 0.1; 1 + 1 } # evaluation starts immediately
-    # => <#Concurrent::Edge::Future:0x7fcc73208180 pending blocks:[]>
-future.completed?                                  # => false
-# block until evaluated
-future.value                                       # => 2
-future.completed?                                  # => true
-
-
-### Failing asynchronous task
-
-future = Concurrent.future { raise 'Boom' }
-    # => <#Concurrent::Edge::Future:0x7fcc731fa0a8 pending blocks:[]>
-future.value                                       # => nil
-future.value! rescue $!                            # => #<RuntimeError: Boom>
-future.reason                                      # => #<RuntimeError: Boom>
-# re-raising
-raise future rescue $!                             # => #<RuntimeError: Boom>
-
-
-### Chaining
-
-head    = Concurrent.succeeded_future 1 
-branch1 = head.then(&:succ) 
-branch2 = head.then(&:succ).then(&:succ) 
-branch1.zip(branch2).value!                        # => [2, 3]
-(branch1 & branch2).then { |a, b| a + b }.value!   # => 5
-(branch1 & branch2).then(&:+).value!               # => 5
-Concurrent.zip(branch1, branch2, branch1).then { |*values| values.reduce &:+ }.value!
-    # => 7
-# pick only first completed
-(branch1 | branch2).value!                         # => 2
-
-### Error handling
-
-Concurrent.future { Object.new }.then(&:succ).then(&:succ).rescue { |e| e.class }.value # error propagates
-    # => NoMethodError
-Concurrent.future { Object.new }.then(&:succ).rescue { 1 }.then(&:succ).value # rescued and replaced with 1
-    # => 2
-Concurrent.future { 1 }.then(&:succ).rescue { |e| e.message }.then(&:succ).value # no error, rescue not applied
-    # => 3
-
-failing_zip = Concurrent.succeeded_future(1) & Concurrent.failed_future(StandardError.new('boom'))
-    # => <#Concurrent::Edge::Future:0x7ffcc19ac2a0 failed blocks:[]>
-failing_zip.result                                 # => [false, [1, nil], [nil, #<StandardError: boom>]]
-failing_zip.then { |v| 'never happens' }.result    # => [false, [1, nil], [nil, #<StandardError: boom>]]
-failing_zip.rescue { |a, b| (a || b).message }.value
-    # => "boom"
-failing_zip.chain { |success, values, reasons| [success, values.compact, reasons.compactß] }.value
-    # => nil
-
-### Delay
-
-# will not evaluate until asked by #value or other method requiring completion
-future = Concurrent.delay { 'lazy' }
-    # => <#Concurrent::Edge::Future:0x7fcc731a1840 pending blocks:[]>
-sleep 0.1 
-future.completed?                                  # => false
-future.value                                       # => "lazy"
-
-# propagates trough chain allowing whole or partial lazy chains
-
-head    = Concurrent.delay { 1 }
-    # => <#Concurrent::Edge::Future:0x7fcc73193b28 pending blocks:[]>
-branch1 = head.then(&:succ)
-    # => <#Concurrent::Edge::Future:0x7fcc73190900 pending blocks:[]>
-branch2 = head.delay.then(&:succ)
-    # => <#Concurrent::Edge::Future:0x7fcc7318b400 pending blocks:[]>
-join    = branch1 & branch2
-    # => <#Concurrent::Edge::Future:0x7fcc73180af0 pending blocks:[]>
-
-sleep 0.1 # nothing will complete                  # => 0
-[head, branch1, branch2, join].map(&:completed?)   # => [false, false, false, false]
-
-branch1.value                                      # => 2
-sleep 0.1 # forces only head to complete, branch 2 stays incomplete
-    # => 0
-[head, branch1, branch2, join].map(&:completed?)   # => [true, true, false, false]
-
-join.value                                         # => [2, 2]
-
-
-### Flatting
-
-Concurrent.future { Concurrent.future { 1+1 } }.flat.value # waits for inner future
-    # => 2
-
-# more complicated example
-Concurrent.future { Concurrent.future { Concurrent.future { 1 + 1 } } }.
-    flat(1).
-    then { |f| f.then(&:succ) }.
-    flat(1).value                                  # => 3
-
-
-### Schedule
-
-scheduled = Concurrent.schedule(0.1) { 1 }
-    # => <#Concurrent::Edge::Future:0x7fcc73143e48 pending blocks:[]>
-
-scheduled.completed?                               # => false
-scheduled.value # available after 0.1sec           # => 1
-
-# and in chain
-scheduled = Concurrent.delay { 1 }.schedule(0.1).then(&:succ)
-    # => <#Concurrent::Edge::Future:0x7fcc7313a758 pending blocks:[]>
-# will not be scheduled until value is requested
-sleep 0.1 
-scheduled.value # returns after another 0.1sec     # => 2
-
-
-### Completable Future and Event
-
-future = Concurrent.future
-    # => <#Concurrent::Edge::CompletableFuture:0x7fcc731286e8 pending blocks:[]>
-event  = Concurrent.event
-    # => <#Concurrent::Edge::CompletableEvent:0x7fcc73123058 pending blocks:[]>
-# Don't forget to keep the reference, `Concurrent.future.then { |v| v }` is incompletable
-
-# will be blocked until completed
-t1     = Thread.new { future.value } 
-t2     = Thread.new { event.wait } 
-
-future.success 1
-    # => <#Concurrent::Edge::CompletableFuture:0x7fcc731286e8 success blocks:[]>
-future.success 1 rescue $!
-    # => #<Concurrent::MultipleAssignmentError: Future can be completed only once. Current result is [true, 1, nil], trying to set [true, 1, nil]>
-future.try_success 2                               # => false
-event.complete
-    # => <#Concurrent::Edge::CompletableEvent:0x7fcc73123058 completed blocks:[]>
-
-[t1, t2].each &:join 
-
-
-### Callbacks
-
-queue  = Queue.new                                 # => #<Thread::Queue:0x007fcc73110638>
-future = Concurrent.delay { 1 + 1 }
-    # => <#Concurrent::Edge::Future:0x7fcc7310ab98 pending blocks:[]>
-
-future.on_success { queue << 1 } # evaluated asynchronously
-    # => <#Concurrent::Edge::Future:0x7fcc7310ab98 pending blocks:[]>
-future.on_success! { queue << 2 } # evaluated on completing thread
-    # => <#Concurrent::Edge::Future:0x7fcc7310ab98 pending blocks:[]>
-
-queue.empty?                                       # => true
-future.value                                       # => 2
-queue.pop                                          # => 2
-queue.pop                                          # => 1
-
-
-### Thread-pools
-
-Concurrent.future(:fast) { 2 }.then(:io) { File.read __FILE__ }.wait
-    # => <#Concurrent::Edge::Future:0x7fcc730f98e8 success blocks:[]>
-
-
-### Interoperability with actors
-
-actor = Concurrent::Actor::Utils::AdHoc.spawn :square do
-  -> v { v ** 2 }
-end
-    # => #<Concurrent::Actor::Reference:0x7fcc730c36f8 /square (Concurrent::Actor::Utils::AdHoc)>
-
-Concurrent.
-    future { 2 }.
-    then_ask(actor).
-    then { |v| v + 2 }.
-    value                                          # => 6
-
-actor.ask(2).then(&:succ).value                    # => 5
-
-
-### Interoperability with channels
-
-ch1 = Concurrent::Channel.new                # => #<Concurrent::Channel:0x007fcc73043188>
-ch2 = Concurrent::Channel.new                # => #<Concurrent::Channel:0x007fcc730425f8>
-
-result = Concurrent.select(ch1, ch2)
-    # => <#Concurrent::Edge::CompletableFuture:0x7fcc730411a8 pending blocks:[]>
-ch1.push 1                                         # => nil
-result.value!
-    # => [1, #<Concurrent::Channel:0x007fcc73043188>]
-
-Concurrent.
-    future { 1+1 }.
-    then_push(ch1)
-    # => <#Concurrent::Edge::Future:0x7fcc73032c98 pending blocks:[]>
-result = Concurrent.
-    future { '%02d' }.
-    then_select(ch1, ch2).
-    then { |format, (value, channel)| format format, value }
-    # => <#Concurrent::Edge::Future:0x7fcc7302a4f8 pending blocks:[]>
-result.value!                                      # => "02"
-
-
-### Common use-cases Examples
-
-# simple background processing
-Concurrent.future { do_stuff }
-    # => <#Concurrent::Edge::Future:0x7fcc72123c48 pending blocks:[]>
-
-# parallel background processing
-jobs = 10.times.map { |i| Concurrent.future { i } } 
-Concurrent.zip(*jobs).value                        # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-
-# periodic task
-@end = false                                       # => false
-
-def schedule_job
-  Concurrent.schedule(1) { do_stuff }.
-      rescue { |e| StandardError === e ? report_error(e) : raise(e) }.
-      then { schedule_job unless @end }
-end                                                # => :schedule_job
-
-schedule_job
-    # => <#Concurrent::Edge::Future:0x7fcc75011370 pending blocks:[]>
-@end = true                                        # => true
-
-
-# How to limit processing where there are limited resources?
-# By creating an actor managing the resource
-DB   = Concurrent::Actor::Utils::AdHoc.spawn :db do
-  data = Array.new(10) { |i| '*' * i }
-  lambda do |message|
-    # pretending that this queries a DB
-    data[message]
-  end
-end
-    # => #<Concurrent::Actor::Reference:0x7fcc71832a08 /db (Concurrent::Actor::Utils::AdHoc)>
-
-concurrent_jobs = 11.times.map do |v|
-  Concurrent.
-      future { v }.
-      # ask the DB with the `v`, only one at the time, rest is parallel
-      then_ask(DB).
-      # get size of the string, fails for 11
-      then(&:size).
-      rescue { |reason| reason.message } # translate error to value (exception, message)
-end 
-
-Concurrent.zip(*concurrent_jobs).value!
-    # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "undefined method `size' for nil:NilClass"]
-
-
-# In reality there is often a pool though:
-data      = Array.new(10) { |i| '*' * i }
-    # => ["", "*", "**", "***", "****", "*****", "******", "*******", "********", "*********"]
-pool_size = 5                                      # => 5
-
-DB_POOL = Concurrent::Actor::Utils::Pool.spawn!('DB-pool', pool_size) do |index|
-  # DB connection constructor
-  Concurrent::Actor::Utils::AdHoc.spawn(name: "worker-#{index}", args: [data]) do |data|
-    lambda do |message|
-      # pretending that this queries a DB
-      data[message]
-    end
-  end
-end
-    # => #<Concurrent::Actor::Reference:0x7fcc72320118 /DB-pool (Concurrent::Actor::Utils::Pool)>
-
-concurrent_jobs = 11.times.map do |v|
-  Concurrent.
-      future { v }.
-      # ask the DB_POOL with the `v`, only 5 at the time, rest is parallel
-      then_ask(DB_POOL).
-      then(&:size).
-      rescue { |reason| reason.message }
-end 
-
-Concurrent.zip(*concurrent_jobs).value!
-    # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "undefined method `size' for nil:NilClass"]

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Future) any(*futures) - - - - - -

-
-

Constructs new Concurrent::Edge::Future which is completed after first of the futures is complete.

- - -
-
-
-

Parameters:

-
    - -
  • - - futures - - - (Event) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-101
-102
-103
-
-
# File 'lib/concurrent/edge/future.rb', line 101
-
-def any(*futures)
-  AnyPromise.new(futures, :io).future
-end
-
-
- -
-

- - - (Event) completed_event(default_executor = :io) - - - - - -

-
-

Returns which is already completed

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Event) - - - - — -

    which is already completed

    -
    - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/edge/future.rb', line 59
-
-def completed_event(default_executor = :io)
-  ImmediateEventPromise.new(default_executor).event
-end
-
-
- -
-

- - - (Future) completed_future(success, value, reason, default_executor = :io) - - - - - -

-
-

Returns which is already completed

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - - — -

    which is already completed

    -
    - -
  • - -
- -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/edge/future.rb', line 44
-
-def completed_future(success, value, reason, default_executor = :io)
-  ImmediateFuturePromise.new(default_executor, success, value, reason).future
-end
-
-
- -
-

- - - (Future) delay(default_executor = :io, &task) - - - - - -

-
-

Constructs new Future which will evaluate to the block after -requested by calling #wait, #value, #value!, etc. on it or on any of the chained futures.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-68
-69
-70
-
-
# File 'lib/concurrent/edge/future.rb', line 68
-
-def delay(default_executor = :io, &task)
-  Delay.new(default_executor).future.then(&task)
-end
-
-
- -
-

- - - (CompletableEvent) event(default_executor = :io) - - - - - -

-
-

User is responsible for completing the event once by CompletableEvent#complete

- - -
-
-
- -

Returns:

- - -
- - - - -
-
-
-
-25
-26
-27
-
-
# File 'lib/concurrent/edge/future.rb', line 25
-
-def event(default_executor = :io)
-  CompletableEventPromise.new(default_executor).future
-end
-
-
- -
-

- - - (Future) failed_future(reason, default_executor = :io) - - - - - -

-
-

Returns which is already completed in failed state with reason

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - - — -

    which is already completed in failed state with reason

    -
    - -
  • - -
- -
- - - - -
-
-
-
-54
-55
-56
-
-
# File 'lib/concurrent/edge/future.rb', line 54
-
-def failed_future(reason, default_executor = :io)
-  completed_future false, nil, reason, default_executor
-end
-
-
- -
-

- - - - (Future) future(default_executor = :io, &task) - - - (CompletableFuture) future(default_executor = :io) - - - - - Also known as: - async - - - - -

-
- - -
-
-
- -

Overloads:

-
    - - -
  • - - (Future) future(default_executor = :io, &task) -
    -
    -

    Constructs new Future which will be completed after block is evaluated on executor. Evaluation begins immediately.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Future) - - - -
    • - -
    - -
    -
  • - - -
  • - - (CompletableFuture) future(default_executor = :io) -
    -
    -

    User is responsible for completing the future once by CompletableFuture#success or CompletableFuture#fail

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
  • - -
- - -
- - - - -
-
-
-
-35
-36
-37
-38
-39
-40
-41
-
-
# File 'lib/concurrent/edge/future.rb', line 35
-
-def future(default_executor = :io, &task)
-  if task
-    ImmediateEventPromise.new(default_executor).future.then(&task)
-  else
-    CompletableFuturePromise.new(default_executor).future
-  end
-end
-
-
- -
-

- - - (true, false) post(*args, &job) - - - - - -

-
-

post job on :io executor

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true, false) - - - -
  • - -
- -
- - - - -
-
-
-
-126
-127
-128
-
-
# File 'lib/concurrent/edge/future.rb', line 126
-
-def post(*args, &job)
-  post_on(:io, *args, &job)
-end
-
-
- -
-

- - - (true, false) post!(*args, &job) - - - - - -

-
-

post job on :fast executor

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true, false) - - - -
  • - -
- -
- - - - -
-
-
-
-120
-121
-122
-
-
# File 'lib/concurrent/edge/future.rb', line 120
-
-def post!(*args, &job)
-  post_on(:fast, *args, &job)
-end
-
-
- -
-

- - - (true, false) post_on(executor, *args, &job) - - - - - -

-
-

post job on executor

- - -
-
-
- -

Returns:

-
    - -
  • - - - (true, false) - - - -
  • - -
- -
- - - - -
-
-
-
-132
-133
-134
-
-
# File 'lib/concurrent/edge/future.rb', line 132
-
-def post_on(executor, *args, &job)
-  Concurrent.executor(executor).post(*args, &job)
-end
-
-
- -
-

- - - (Future) schedule(intended_time, default_executor = :io, &task) - - - - - -

-
-

Schedules the block to be executed on executor in given intended_time.

- - -
-
-
-

Parameters:

-
    - -
  • - - intended_time - - - (Numeric, Time) - - - - — -

    Numeric => run in intended_time seconds. Time => eun on time.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-75
-76
-77
-
-
# File 'lib/concurrent/edge/future.rb', line 75
-
-def schedule(intended_time, default_executor = :io, &task)
-  ScheduledPromise.new(default_executor, intended_time).future.then(&task)
-end
-
-
- -
-

- - - (Future) select(*channels) - - - - - -

-
-

only proof of concept

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-
-
# File 'lib/concurrent/edge/future.rb', line 107
-
-def select(*channels)
-  future do
-    # noinspection RubyArgCount
-    Channel.select do |s|
-      channels.each do |ch|
-        s.take(ch) { |value| [value, ch] }
-      end
-    end
-  end
-end
-
-
- -
-

- - - (Future) succeeded_future(value, default_executor = :io) - - - - - -

-
-

Returns which is already completed in success state with value

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Future) - - - - — -

    which is already completed in success state with value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-49
-50
-51
-
-
# File 'lib/concurrent/edge/future.rb', line 49
-
-def succeeded_future(value, default_executor = :io)
-  completed_future true, value, nil, default_executor
-end
-
-
- -
-

- - - (Event) zip_events(*futures_and_or_events) - - - - - -

-
-

Constructs new Event which is completed after all futures_and_or_events are complete -(Future is completed when Success or Failed).

- - -
-
-
-

Parameters:

-
    - -
  • - - futures_and_or_events - - - (Event) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Event) - - - -
  • - -
- -
- - - - -
-
-
-
-94
-95
-96
-
-
# File 'lib/concurrent/edge/future.rb', line 94
-
-def zip_events(*futures_and_or_events)
-  ZipEventsPromise.new(futures_and_or_events, :io).future
-end
-
-
- -
-

- - - (Future) zip_futures(*futures_and_or_events) - - - - Also known as: - zip - - - - -

-
-

Constructs new Concurrent::Edge::Future which is completed after all futures_and_or_events are complete. Its value is array -of dependent future values. If there is an error it fails with the first one. Event does not -have a value so it's represented by nil in the array of values.

- - -
-
-
-

Parameters:

-
    - -
  • - - futures_and_or_events - - - (Event) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Future) - - - -
  • - -
- -
- - - - -
-
-
-
-84
-85
-86
-
-
# File 'lib/concurrent/edge/future.rb', line 84
-
-def zip_futures(*futures_and_or_events)
-  ZipFuturesPromise.new(futures_and_or_events, :io).future
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/LockFreeLinkedSet.html b/docs/1.0.5/Concurrent/Edge/LockFreeLinkedSet.html index a774d8c6b..19422c234 100644 --- a/docs/1.0.5/Concurrent/Edge/LockFreeLinkedSet.html +++ b/docs/1.0.5/Concurrent/Edge/LockFreeLinkedSet.html @@ -883,9 +883,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::Edge::LockFreeStack - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - -
Includes:
-
Enumerable
- - - - - -
Defined in:
-
lib/concurrent/edge/lock_free_stack.rb
- -
-
- -
-
- - -
-
-
- - -

Defined Under Namespace

-

- - - - - Classes: Empty, Node - - -

- -

Constant Summary

- -
- -
EMPTY = -
-
- - -
-
-
- - -
-
-
Empty[nil, nil]
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Constructor Details

- -
-

- - - (LockFreeStack) initialize - - - - - -

-
-

Returns a new instance of LockFreeStack

- - -
-
-
- - -
- - - - -
-
-
-
-28
-29
-30
-31
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 28
-
-def initialize
-  super()
-  self.head = EMPTY
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) clear - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-79
-80
-81
-82
-83
-84
-85
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 79
-
-def clear
-  while true
-    current_head = head
-    return false if current_head == EMPTY
-    return true if compare_and_set_head current_head, EMPTY
-  end
-end
-
-
- -
-

- - - (Object) clear_each(&block) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 87
-
-def clear_each(&block)
-  while true
-    current_head = head
-    return self if current_head == EMPTY
-    if compare_and_set_head current_head, EMPTY
-      each current_head, &block
-      return self
-    end
-  end
-end
-
-
- -
-

- - - (Object) compare_and_clear(head) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-63
-64
-65
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 63
-
-def compare_and_clear(head)
-  compare_and_set_head head, EMPTY
-end
-
-
- -
-

- - - (Object) compare_and_pop(head) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-52
-53
-54
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 52
-
-def compare_and_pop(head)
-  compare_and_set_head head, head.next_node
-end
-
-
- -
-

- - - (Object) compare_and_push(head, value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-37
-38
-39
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 37
-
-def compare_and_push(head, value)
-  compare_and_set_head head, Node[value, head]
-end
-
-
- -
-

- - - (Object) each(head = nil) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-69
-70
-71
-72
-73
-74
-75
-76
-77
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 69
-
-def each(head = nil)
-  return to_enum(:each, head) unless block_given?
-  it = head || peek
-  until it.equal?(EMPTY)
-    yield it.value
-    it = it.next_node
-  end
-  self
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-33
-34
-35
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 33
-
-def empty?
-  head.equal? EMPTY
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-48
-49
-50
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 48
-
-def peek
-  head
-end
-
-
- -
-

- - - (Object) pop - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-56
-57
-58
-59
-60
-61
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 56
-
-def pop
-  while true
-    current_head = head
-    return current_head.value if compare_and_set_head current_head, current_head.next_node
-  end
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-41
-42
-43
-44
-45
-46
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 41
-
-def push(value)
-  while true
-    current_head = head
-    return self if compare_and_set_head current_head, Node[value, current_head]
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Edge/LockFreeStack/Empty.html b/docs/1.0.5/Concurrent/Edge/LockFreeStack/Empty.html deleted file mode 100644 index 56bea61f6..000000000 --- a/docs/1.0.5/Concurrent/Edge/LockFreeStack/Empty.html +++ /dev/null @@ -1,358 +0,0 @@ - - - - - - Class: Concurrent::Edge::LockFreeStack::Empty - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Edge::LockFreeStack::Empty - - - -

- -
- -
Inherits:
-
- Node - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/lock_free_stack.rb
- -
-
- -
-
- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

- - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::Edge::LockFreeStack::Node

- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) next_node (readonly) - - - - - - - Originally defined in class - Node - - -

-
- - -
-
-
- - -
-
- - - -
-

- - - (Object) value (readonly) - - - - - - - Originally defined in class - Node - - -

-
- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) next_node - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 19
-
-def next_node
-  self
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/EnsureNewVisibility.html b/docs/1.0.5/Concurrent/EnsureNewVisibility.html deleted file mode 100644 index 7151b13c6..000000000 --- a/docs/1.0.5/Concurrent/EnsureNewVisibility.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - Module: Concurrent::EnsureNewVisibility - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::EnsureNewVisibility - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/atomic/ensure_new_visibility.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) new - - - - - -

- - - - -
-
-
-
-5
-6
-7
-8
-9
-
-
# File 'lib/concurrent/atomic/ensure_new_visibility.rb', line 5
-
-def new(*)
-  super
-ensure
-  Synchronization.store_fence
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Event.html b/docs/1.0.5/Concurrent/Event.html index 08ac8b5e2..05df0c04a 100644 --- a/docs/1.0.5/Concurrent/Event.html +++ b/docs/1.0.5/Concurrent/Event.html @@ -678,9 +678,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Executor - - - -

- -
- - - - - - - -
Included in:
-
JavaExecutor, PerThreadExecutor, RubyExecutor, SerialExecutor
- - - -
Defined in:
-
lib/concurrent/executor/executor.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
- - - - -
-
-
-
-12
-13
-14
-
-
# File 'lib/concurrent/executor/executor.rb', line 12
-
-def fallback_policy
-  @fallback_policy
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) auto_terminate? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-63
-64
-65
-
-
# File 'lib/concurrent/executor/executor.rb', line 63
-
-def auto_terminate?
-  !! @auto_terminate
-end
-
-
- -
-

- - - (Boolean) can_overflow? - - - - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-21
-22
-23
-
-
# File 'lib/concurrent/executor/executor.rb', line 21
-
-def can_overflow?
-  false
-end
-
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - -

- - - - -
-
-
-
-89
-90
-91
-92
-93
-
-
# File 'lib/concurrent/executor/executor.rb', line 89
-
-def create_at_exit_handler!(this)
-  at_exit do
-    this.kill if Concurrent.auto_terminate_all_executors?
-  end
-end
-
-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - -

- - - - -
-
-
-
-80
-81
-82
-83
-84
-85
-86
-87
-
-
# File 'lib/concurrent/executor/executor.rb', line 80
-
-def create_mri_at_exit_handler!(id)
-  at_exit do
-    if Concurrent.auto_terminate_all_executors?
-      this = ObjectSpace._id2ref(id)
-      this.kill if this
-    end
-  end
-end
-
-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - -

- - - - -
-
-
-
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-
-
# File 'lib/concurrent/executor/executor.rb', line 69
-
-def enable_at_exit_handler!(opts = {})
-  if opts.fetch(:stop_on_exit, true)
-    @auto_terminate = true
-    if RUBY_PLATFORM == 'ruby'
-      create_mri_at_exit_handler!(self.object_id)
-    else
-      create_at_exit_handler!(self)
-    end
-  end
-end
-
-
- -
-

- - - (Boolean) serialized? - - - - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/executor/executor.rb', line 59
-
-def serialized?
-  false
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/FixedThreadPool.html b/docs/1.0.5/Concurrent/FixedThreadPool.html index ced2c8000..eabfe5f7b 100644 --- a/docs/1.0.5/Concurrent/FixedThreadPool.html +++ b/docs/1.0.5/Concurrent/FixedThreadPool.html @@ -1278,9 +1278,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::JavaAtomic - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
AtomicDirectUpdate
- - - - - -
Defined in:
-
lib/concurrent/atomic_reference/jruby.rb
- -
-
- -

Overview

-
-

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) try_update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. Raise an exception if the update -fails.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
-

Raises:

- - -
-
- -
-

- - - (Object) update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. May retry if the value changes -during the block's execution.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaAtomicBoolean.html b/docs/1.0.5/Concurrent/JavaAtomicBoolean.html deleted file mode 100644 index b795498ee..000000000 --- a/docs/1.0.5/Concurrent/JavaAtomicBoolean.html +++ /dev/null @@ -1,769 +0,0 @@ - - - - - - Class: Concurrent::JavaAtomicBoolean - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaAtomicBoolean - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_boolean.rb
- -
-
- -

Overview

-
-

A boolean value that can be updated atomically. Reads and writes to an atomic -boolean and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicBoolean...
-  2.790000   0.000000   2.790000 (  2.791454)
-Testing with Concurrent::CAtomicBoolean...
-  0.740000   0.000000   0.740000 (  0.740206)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicBoolean...
-  5.240000   2.520000   7.760000 (  3.683000)
-Testing with Concurrent::JavaAtomicBoolean...
-  3.340000   0.010000   3.350000 (  0.855000)
-
- - -
-
-
- - -

See Also:

- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (JavaAtomicBoolean) initialize(initial = false) - - - - - -

-
-

Creates a new AtomicBoolean with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - initial - - - (Boolean) - - - (defaults to: false) - - - — -

    the initial value

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-123
-124
-125
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 123
-
-def initialize(initial = false)
-  @atomic = java.util.concurrent.atomic.AtomicBoolean.new(!!initial)
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) false? - - - - - -

-
-

Is the current value false

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is false, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-145
-146
-147
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 145
-
-def false?
-  !@atomic.get
-end
-
-
- -
-

- - - (Boolean) make_false - - - - - -

-
-

Explicitly sets the value to false.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-155
-156
-157
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 155
-
-def make_false
-  @atomic.compareAndSet(true, false)
-end
-
-
- -
-

- - - (Boolean) make_true - - - - - -

-
-

Explicitly sets the value to true.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-150
-151
-152
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 150
-
-def make_true
-  @atomic.compareAndSet(false, true)
-end
-
-
- -
-

- - - (Boolean) true? - - - - - -

-
-

Is the current value true

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is true, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-140
-141
-142
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 140
-
-def true?
-  @atomic.get
-end
-
-
- -
-

- - - (Boolean) value - - - - - -

-
-

Retrieves the current Boolean value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-129
-130
-131
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 129
-
-def value
-  @atomic.get
-end
-
-
- -
-

- - - (Boolean) value=(value) - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Boolean) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-135
-136
-137
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 135
-
-def value=(value)
-  @atomic.set(!!value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaAtomicFixnum.html b/docs/1.0.5/Concurrent/JavaAtomicFixnum.html deleted file mode 100644 index f0cb25457..000000000 --- a/docs/1.0.5/Concurrent/JavaAtomicFixnum.html +++ /dev/null @@ -1,791 +0,0 @@ - - - - - - Class: Concurrent::JavaAtomicFixnum - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaAtomicFixnum - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_fixnum.rb
- -
-
- -

Overview

-
-

A numeric value that can be updated atomically. Reads and writes to an atomic -fixnum and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicFixnum...
-  3.130000   0.000000   3.130000 (  3.136505)
-Testing with Concurrent::CAtomicFixnum...
-  0.790000   0.000000   0.790000 (  0.785550)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicFixnum...
-  5.460000   2.460000   7.920000 (  3.715000)
-Testing with Concurrent::JavaAtomicFixnum...
-  4.520000   0.030000   4.550000 (  1.187000)
-
- - -
-
-
- - -

See Also:

- - -
-

Constant Summary

- -
- -
MIN_VALUE = - -
-
Java::JavaLang::Long::MIN_VALUE
- -
MAX_VALUE = - -
-
Java::JavaLang::Long::MAX_VALUE
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (JavaAtomicFixnum) initialize(init = 0) - - - - - -

-
-

Creates a new AtomicFixnum with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - init - - - (Fixnum) - - - (defaults to: 0) - - - — -

    the initial value

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the initial value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-130
-131
-132
-133
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 130
-
-def initialize(init = 0)
-  raise ArgumentError.new('initial value must be a Fixnum') unless init.is_a?(Fixnum)
-  @atomic = java.util.concurrent.atomic.AtomicLong.new(init)
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) compare_and_set(expect, update) - - - - - -

-
-

Atomically sets the value to the given updated value if the current -value == the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - expect - - - (Fixnum) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - update - - - (Fixnum) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the value was updated else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-159
-160
-161
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 159
-
-def compare_and_set(expect, update)
-  @atomic.compare_and_set(expect, update)
-end
-
-
- -
-

- - - (Fixnum) decrement - - - - Also known as: - down - - - - -

-
-

Decreases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after decrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-153
-154
-155
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 153
-
-def decrement
-  @atomic.decrement_and_get
-end
-
-
- -
-

- - - (Fixnum) increment - - - - Also known as: - up - - - - -

-
-

Increases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after incrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-147
-148
-149
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 147
-
-def increment
-  @atomic.increment_and_get
-end
-
-
- -
-

- - - (Fixnum) value - - - - - -

-
-

Retrieves the current Fixnum value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-136
-137
-138
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 136
-
-def value
-  @atomic.get
-end
-
-
- -
-

- - - (Fixnum) value=(value) - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Fixnum) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the new value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-141
-142
-143
-144
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 141
-
-def value=(value)
-  raise ArgumentError.new('value must be a Fixnum') unless value.is_a?(Fixnum)
-  @atomic.set(value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaCachedThreadPool.html b/docs/1.0.5/Concurrent/JavaCachedThreadPool.html deleted file mode 100644 index a13b7f92d..000000000 --- a/docs/1.0.5/Concurrent/JavaCachedThreadPool.html +++ /dev/null @@ -1,469 +0,0 @@ - - - - - - Class: Concurrent::JavaCachedThreadPool - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaCachedThreadPool - - - -

- -
- -
Inherits:
-
- JavaThreadPoolExecutor - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/java_cached_thread_pool.rb
- -
-
- - -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
  • - - - - (Integer) max_length - - - - - - - inherited - from JavaThreadPoolExecutor - - - - - - readonly - - - - - - - - - -

    The maximum number of threads that may be created in the pool.

    -
    - -
  • - - -
  • - - - - (Object) max_queue - - - - - - - inherited - from JavaThreadPoolExecutor - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute max_queue.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Constructor Details

- -
-

- - - (JavaCachedThreadPool) initialize(opts = {}) - - - - - -

-
-

Returns a new instance of JavaCachedThreadPool

- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-
-
# File 'lib/concurrent/executor/java_cached_thread_pool.rb', line 19
-
-def initialize(opts = {})
-  @fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
-  warn '[DEPRECATED] :overflow_policy is deprecated terminology, please use :fallback_policy instead' if opts.has_key?(:overflow_policy)
-  @max_queue = 0
-
-  raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.keys.include?(@fallback_policy)
-
-  @executor = java.util.concurrent.Executors.newCachedThreadPool
-  @executor.setRejectedExecutionHandler(FALLBACK_POLICIES[@fallback_policy].new)
-
-  enable_at_exit_handler!(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Integer) max_length (readonly) - - - - - - - Originally defined in class - JavaThreadPoolExecutor - - -

-
-

The maximum number of threads that may be created in the pool.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the max_length

    -
    - -
  • - -
- -
-
- - - -
-

- - - (Object) max_queue (readonly) - - - - - - - Originally defined in class - JavaThreadPoolExecutor - - -

-
-

Returns the value of attribute max_queue

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaExecutor.html b/docs/1.0.5/Concurrent/JavaExecutor.html deleted file mode 100644 index a8117cebb..000000000 --- a/docs/1.0.5/Concurrent/JavaExecutor.html +++ /dev/null @@ -1,1352 +0,0 @@ - - - - - - Module: Concurrent::JavaExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::JavaExecutor - - - -

- -
- - - - - -
Includes:
-
Executor
- - - - -
Included in:
-
JavaSingleThreadExecutor, JavaThreadPoolExecutor
- - - -
Defined in:
-
lib/concurrent/executor/executor.rb
- -
-
- - -

Constant Summary

- -
- -
FALLBACK_POLICIES = -
-
-

The set of possible fallback policies that may be set at thread pool creation.

- - -
-
-
- - -
-
-
{
-  abort: java.util.concurrent.ThreadPoolExecutor::AbortPolicy,
-  discard: java.util.concurrent.ThreadPoolExecutor::DiscardPolicy,
-  caller_runs: java.util.concurrent.ThreadPoolExecutor::CallerRunsPolicy
-}.freeze
- -
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (self) <<(task) - - - - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - task - - - (Proc) - - - - — -

    the asynchronous task to perform

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (self) - - - - — -

    returns itself

    -
    - -
  • - -
- -
- - - - -
-
-
-
-298
-299
-300
-301
-
-
# File 'lib/concurrent/executor/executor.rb', line 298
-
-def <<(task)
-  post(&task)
-  self
-end
-
-
- -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) kill - - - - - -

-
-

Begin an immediate shutdown. In-progress tasks will be allowed to -complete but enqueued tasks will be dismissed and no new tasks -will be accepted. Has no additional effect if the thread pool is -not running.

- - -
-
-
- - -
- - - - -
-
-
-
-339
-340
-341
-342
-
-
# File 'lib/concurrent/executor/executor.rb', line 339
-
-def kill
-  @executor.shutdownNow
-  nil
-end
-
-
- -
-

- - - (Boolean) post(*args) { ... } - - - - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to be passed to the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the asynchronous task to perform

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the task is queued, false if the executor -is not running

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no task is given

    -
    - -
  • - -
- -
- - - - -
-
-
-
-287
-288
-289
-290
-291
-292
-293
-294
-295
-
-
# File 'lib/concurrent/executor/executor.rb', line 287
-
-def post(*args, &task)
-  raise ArgumentError.new('no block given') unless block_given?
-  return handle_fallback(*args, &task) unless running?
-  executor_submit = @executor.java_method(:submit, [Runnable.java_class])
-  executor_submit.call { yield(*args) }
-  true
-rescue Java::JavaUtilConcurrent::RejectedExecutionException
-  raise RejectedExecutionError
-end
-
-
- -
-

- - - (Boolean) running? - - - - - -

-
-

Is the executor running?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when running, false when shutting down or shutdown

    -
    - -
  • - -
- -
- - - - -
-
-
-
-304
-305
-306
-
-
# File 'lib/concurrent/executor/executor.rb', line 304
-
-def running?
-  ! (shuttingdown? || shutdown?)
-end
-
-
- -
-

- - - (Boolean) serialized? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) shutdown - - - - - -

-
-

Begin an orderly shutdown. Tasks already in the queue will be executed, -but no new tasks will be accepted. Has no additional effect if the -thread pool is not running.

- - -
-
-
- - -
- - - - -
-
-
-
-333
-334
-335
-336
-
-
# File 'lib/concurrent/executor/executor.rb', line 333
-
-def shutdown
-  @executor.shutdown
-  nil
-end
-
-
- -
-

- - - (Boolean) shutdown? - - - - - -

-
-

Is the executor shutdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when shutdown, false when shutting down or running

    -
    - -
  • - -
- -
- - - - -
-
-
-
-318
-319
-320
-
-
# File 'lib/concurrent/executor/executor.rb', line 318
-
-def shutdown?
-  @executor.isShutdown || @executor.isTerminated
-end
-
-
- -
-

- - - (Boolean) shuttingdown? - - - - - -

-
-

Is the executor shuttingdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when not running and not shutdown, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-309
-310
-311
-312
-313
-314
-315
-
-
# File 'lib/concurrent/executor/executor.rb', line 309
-
-def shuttingdown?
-  if @executor.respond_to? :isTerminating
-    @executor.isTerminating
-  else
-    false
-  end
-end
-
-
- -
-

- - - (Boolean) wait_for_termination(timeout = nil) - - - - - -

-
- -
- Note: -

Does not initiate shutdown or termination. Either shutdown or kill -must be called before this method (or on another thread).

-
-
- -

Block until executor shutdown is complete or until timeout seconds have -passed.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Integer) - - - (defaults to: nil) - - - — -

    the maximum number of seconds to wait for shutdown to complete

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if shutdown complete or false on timeout

    -
    - -
  • - -
- -
- - - - -
-
-
-
-323
-324
-325
-326
-327
-328
-329
-330
-
-
# File 'lib/concurrent/executor/executor.rb', line 323
-
-def wait_for_termination(timeout = nil)
-  if timeout.nil?
-    ok = @executor.awaitTermination(60, java.util.concurrent.TimeUnit::SECONDS) until ok
-    true
-  else
-    @executor.awaitTermination(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaFixedThreadPool.html b/docs/1.0.5/Concurrent/JavaFixedThreadPool.html deleted file mode 100644 index 4db818459..000000000 --- a/docs/1.0.5/Concurrent/JavaFixedThreadPool.html +++ /dev/null @@ -1,638 +0,0 @@ - - - - - - Class: Concurrent::JavaFixedThreadPool - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaFixedThreadPool - - - -

- -
- -
Inherits:
-
- JavaThreadPoolExecutor - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/java_fixed_thread_pool.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

A thread pool with a set number of threads. The number of threads in the pool -is set on construction and remains constant. When all threads are busy new -tasks #post to the thread pool are enqueued until a thread becomes available. -Should a thread crash for any reason the thread will immediately be removed -from the pool and replaced.

- -

The API and behavior of this class are based on Java's FixedThreadPool

- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
- -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
  • - - - - (Integer) max_length - - - - - - - inherited - from JavaThreadPoolExecutor - - - - - - readonly - - - - - - - - - -

    The maximum number of threads that may be created in the pool.

    -
    - -
  • - - -
  • - - - - (Object) max_queue - - - - - - - inherited - from JavaThreadPoolExecutor - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute max_queue.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Constructor Details

- -
-

- - - (JavaFixedThreadPool) initialize(num_threads, opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining pool behavior.

    -
    - -
  • - -
- - - - - - -

Options Hash (opts):

-
    - -
  • - :fallback_policy - (Symbol) - - - — default: - `:abort` - - - - —

    the fallback policy

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if num_threads is less than or equal to zero

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if fallback_policy is not a known policy

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-
-
# File 'lib/concurrent/executor/java_fixed_thread_pool.rb', line 20
-
-def initialize(num_threads, opts = {})
-
-  opts = {
-      min_threads: num_threads,
-      max_threads: num_threads
-  }.merge(opts)
-  super(opts)
-
-  enable_at_exit_handler!(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Integer) max_length (readonly) - - - - - - - Originally defined in class - JavaThreadPoolExecutor - - -

-
-

The maximum number of threads that may be created in the pool.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the max_length

    -
    - -
  • - -
- -
-
- - - -
-

- - - (Object) max_queue (readonly) - - - - - - - Originally defined in class - JavaThreadPoolExecutor - - -

-
-

Returns the value of attribute max_queue

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaPriorityQueue.html b/docs/1.0.5/Concurrent/JavaPriorityQueue.html deleted file mode 100644 index 9cc457535..000000000 --- a/docs/1.0.5/Concurrent/JavaPriorityQueue.html +++ /dev/null @@ -1,1158 +0,0 @@ - - - - - - Class: Concurrent::JavaPriorityQueue - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaPriorityQueue - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/collection/priority_queue.rb
- -
-
- -

Overview

-
- -
- Note: -

This implementation is not thread safe and performs no blocking.

-
-
- -

A queue collection in which the elements are sorted based on their -comparison (spaceship) operator <=>. Items are added to the queue -at a position relative to their priority. On removal the element -with the "highest" priority is removed. By default the sort order is -from highest to lowest, but a lowest-to-highest sort order can be -set on construction.

- -

The API is based on the Queue class from the Ruby standard library.

- -

The pure Ruby implementation, MutexPriorityQueue uses a heap algorithm -stored in an array. The algorithm is based on the work of Robert Sedgewick -and Kevin Wayne.

- -

The JRuby native implementation is a thin wrapper around the standard -library java.util.PriorityQueue.

- -

When running under JRuby the class PriorityQueue extends JavaPriorityQueue. -When running under all other interpreters it extends MutexPriorityQueue.

- - -
-
- - - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Object) clear - - - - - - - - - - - - - -

    Removes all of the elements from this priority queue.

    -
    - -
  • - - -
  • - - - - (Object) delete(item) - - - - - - - - - - - - - -

    Deletes all items from self that are equal to item.

    -
    - -
  • - - -
  • - - - - (Boolean) empty? - - - - - - - - - - - - - -

    Returns true if self contains no elements.

    -
    - -
  • - - -
  • - - - - (Boolean) include?(item) - - - - (also: #has_priority?) - - - - - - - - - - - -

    Returns true if the given item is present in self (that is, if any element == item), otherwise returns false.

    -
    - -
  • - - -
  • - - - - (JavaPriorityQueue) initialize(opts = {}) - - - - - - - constructor - - - - - - - - -

    Create a new priority queue with no items.

    -
    - -
  • - - -
  • - - - - (Fixnum) length - - - - (also: #size) - - - - - - - - - - - -

    The current length of the queue.

    -
    - -
  • - - -
  • - - - - (Object) peek - - - - - - - - - - - - - -

    Retrieves, but does not remove, the head of this queue, or returns nil if this queue is empty.

    -
    - -
  • - - -
  • - - - - (Object) pop - - - - (also: #deq, #shift) - - - - - - - - - - - -

    Retrieves and removes the head of this queue, or returns nil if this queue is empty.

    -
    - -
  • - - -
  • - - - - (Object) push(item) - - - - (also: #<<, #enq) - - - - - - - - - - - -

    Inserts the specified element into this priority queue.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (JavaPriorityQueue) initialize(opts = {}) - - - - - -

-
-

Create a new priority queue with no items.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options for creating the queue

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :order - (Symbol) - - - — default: - :max - - - - —

    dictates the order in which items are -stored: from highest to lowest when :max or :high; from lowest to -highest when :min or :low

    -
    - -
  • - -
- - - -
- - - - -
-
-
-
-228
-229
-230
-231
-232
-233
-234
-235
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 228
-
-def initialize(opts = {})
-  order = opts.fetch(:order, :max)
-  if [:min, :low].include?(order)
-    @queue = java.util.PriorityQueue.new(11) # 11 is the default initial capacity
-  else
-    @queue = java.util.PriorityQueue.new(11, java.util.Collections.reverseOrder())
-  end
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - + (PriorityQueue) from_list(list, opts = {}) - - - - - -

-
-

Create a new priority queue from the given list.

- - -
-
-
-

Parameters:

-
    - -
  • - - list - - - (Enumerable) - - - - — -

    the list to build the queue from

    -
    - -
  • - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options for creating the queue

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (PriorityQueue) - - - - — -

    the newly created and populated queue

    -
    - -
  • - -
- -
- - - - -
-
-
-
-289
-290
-291
-292
-293
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 289
-
-def self.from_list(list, opts = {})
-  queue = new(opts)
-  list.each{|item| queue << item }
-  queue
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (Object) clear - - - - - -

-
-

Removes all of the elements from this priority queue.

- - -
-
-
- - -
- - - - -
-
-
-
-238
-239
-240
-241
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 238
-
-def clear
-  @queue.clear
-  true
-end
-
-
- -
-

- - - (Object) delete(item) - - - - - -

-
-

Deletes all items from self that are equal to item.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to be removed from the queue

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    true if the item is found else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-244
-245
-246
-247
-248
-249
-250
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 244
-
-def delete(item)
-  found = false
-  while @queue.remove(item) do
-    found = true
-  end
-  found
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if self contains no elements.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if there are no items in the queue else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-253
-254
-255
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 253
-
-def empty?
-  @queue.size == 0
-end
-
-
- -
-

- - - (Boolean) include?(item) - - - - Also known as: - has_priority? - - - - -

-
-

Returns true if the given item is present in self (that is, if any -element == item), otherwise returns false.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to search for

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the item is found else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-258
-259
-260
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 258
-
-def include?(item)
-  @queue.contains(item)
-end
-
-
- -
-

- - - (Fixnum) length - - - - Also known as: - size - - - - -

-
-

The current length of the queue.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the number of items in the queue

    -
    - -
  • - -
- -
- - - - -
-
-
-
-264
-265
-266
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 264
-
-def length
-  @queue.size
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Retrieves, but does not remove, the head of this queue, or returns nil -if this queue is empty.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the head of the queue or nil when empty

    -
    - -
  • - -
- -
- - - - -
-
-
-
-270
-271
-272
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 270
-
-def peek
-  @queue.peek
-end
-
-
- -
-

- - - (Object) pop - - - - Also known as: - deq, shift - - - - -

-
-

Retrieves and removes the head of this queue, or returns nil if this -queue is empty.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the head of the queue or nil when empty

    -
    - -
  • - -
- -
- - - - -
-
-
-
-275
-276
-277
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 275
-
-def pop
-  @queue.poll
-end
-
-
- -
-

- - - (Object) push(item) - - - - Also known as: - <<, enq - - - - -

-
-

Inserts the specified element into this priority queue.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to insert onto the queue

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-282
-283
-284
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 282
-
-def push(item)
-  @queue.add(item)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaSemaphore.html b/docs/1.0.5/Concurrent/JavaSemaphore.html deleted file mode 100644 index f604dfd15..000000000 --- a/docs/1.0.5/Concurrent/JavaSemaphore.html +++ /dev/null @@ -1,964 +0,0 @@ - - - - - - Class: Concurrent::JavaSemaphore - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaSemaphore - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/semaphore.rb
- -
-
- -

Overview

-
-

A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if necessary -until a permit is available, and then takes it. Each #release adds a permit, -potentially releasing a blocking acquirer. -However, no actual permit objects are used; the Semaphore just keeps a count of the number available and -acts accordingly.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (JavaSemaphore) initialize(count) - - - - - -

-
-

Create a new Semaphore with the initial count.

- - -
-
-
-

Parameters:

-
    - -
  • - - count - - - (Fixnum) - - - - — -

    the initial count

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if count is not an integer or is less than zero

    -
    - -
  • - -
- -
- - - - -
-
-
-
-164
-165
-166
-167
-168
-169
-170
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 164
-
-def initialize(count)
-  unless count.is_a?(Fixnum) && count >= 0
-    fail(ArgumentError,
-         'count must be in integer greater than or equal zero')
-  end
-  @semaphore = java.util.concurrent.Semaphore.new(count)
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Nil) acquire(permits = 1) - - - - - -

-
-

Acquires the given number of permits from this semaphore, - blocking until all are available.

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    Number of permits to acquire

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not an integer or is less than -one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-173
-174
-175
-176
-177
-178
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 173
-
-def acquire(permits = 1)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  @semaphore.acquire(permits)
-end
-
-
- -
-

- - - (Integer) available_permits - - - - - -

-
-

Returns the current number of permits available in this semaphore.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-181
-182
-183
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 181
-
-def available_permits
-  @semaphore.availablePermits
-end
-
-
- -
-

- - - (Integer) drain_permits - - - - - -

-
-

Acquires and returns all permits that are immediately available.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-186
-187
-188
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 186
-
-def drain_permits
-  @semaphore.drainPermits
-end
-
-
- -
-

- - - (Nil) reduce_permits(reduction) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

-

Shrinks the number of available permits by the indicated reduction.

- - -
-
-
-

Parameters:

-
    - -
  • - - reduction - - - (Fixnum) - - - - — -

    Number of permits to remove.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if reduction is not an integer or is negative

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if @free - @reduction is less than zero

    -
    - -
  • - -
- -
- - - - -
-
-
-
-214
-215
-216
-217
-218
-219
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 214
-
-def reduce_permits(reduction)
-  unless reduction.is_a?(Fixnum) && reduction >= 0
-    fail ArgumentError, 'reduction must be an non-negative integer'
-  end
-  @semaphore.reducePermits(reduction)
-end
-
-
- -
-

- - - (Nil) release(permits = 1) - - - - - -

-
-

Releases the given number of permits, returning them to the semaphore.

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    Number of permits to return to the semaphore.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not a number or is less than one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-205
-206
-207
-208
-209
-210
-211
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 205
-
-def release(permits = 1)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  @semaphore.release(permits)
-  true
-end
-
-
- -
-

- - - (Boolean) try_acquire(permits = 1, timeout = nil) - - - - - -

-
-

Acquires the given number of permits from this semaphore, - only if all are available at the time of invocation or within - timeout interval

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    the number of permits to acquire

    -
    - -
  • - -
  • - - timeout - - - (Fixnum) - - - (defaults to: nil) - - - — -

    the number of seconds to wait for the counter -or nil to return immediately

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    false if no permits are available, true when -acquired a permit

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not an integer or is less than -one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 191
-
-def try_acquire(permits = 1, timeout = nil)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  if timeout.nil?
-    @semaphore.tryAcquire(permits)
-  else
-    @semaphore.tryAcquire(permits,
-                           timeout,
-                           java.util.concurrent.TimeUnit::SECONDS)
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaSingleThreadExecutor.html b/docs/1.0.5/Concurrent/JavaSingleThreadExecutor.html deleted file mode 100644 index 6dd3b46d1..000000000 --- a/docs/1.0.5/Concurrent/JavaSingleThreadExecutor.html +++ /dev/null @@ -1,1492 +0,0 @@ - - - - - - Class: Concurrent::JavaSingleThreadExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::JavaSingleThreadExecutor - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
JavaExecutor, SerialExecutor
- - - - - -
Defined in:
-
lib/concurrent/executor/java_single_thread_executor.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

A thread pool with a set number of threads. The number of threads in the pool -is set on construction and remains constant. When all threads are busy new -tasks #post to the thread pool are enqueued until a thread becomes available. -Should a thread crash for any reason the thread will immediately be removed -from the pool and replaced.

- -

The API and behavior of this class are based on Java's SingleThreadExecutor

- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
- -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Constructor Details

- -
-

- - - (JavaSingleThreadExecutor) initialize(opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    a customizable set of options

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :fallback_policy - (Symbol) - - - — default: - :discard - - - - —

    the policy -for handling new tasks that are received when the queue size -has reached max_queue or after the executor has shut down

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-21
-22
-23
-24
-25
-26
-
-
# File 'lib/concurrent/executor/java_single_thread_executor.rb', line 21
-
-def initialize(opts = {})
-  @executor = java.util.concurrent.Executors.newSingleThreadExecutor
-  @fallback_policy = opts.fetch(:fallback_policy, :discard)
-  raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.keys.include?(@fallback_policy)
-  enable_at_exit_handler!(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (self) <<(task) - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - task - - - (Proc) - - - - — -

    the asynchronous task to perform

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (self) - - - - — -

    returns itself

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) kill - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Begin an immediate shutdown. In-progress tasks will be allowed to -complete but enqueued tasks will be dismissed and no new tasks -will be accepted. Has no additional effect if the thread pool is -not running.

- - -
-
-
- - -
-
- -
-

- - - (Boolean) post(*args) { ... } - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to be passed to the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the asynchronous task to perform

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the task is queued, false if the executor -is not running

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no task is given

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) running? - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Is the executor running?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when running, false when shutting down or shutdown

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) serialized? - - - - - - - Originally defined in module - SerialExecutor - - -

-
- -
- Note: -

Always returns true

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) shutdown - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Begin an orderly shutdown. Tasks already in the queue will be executed, -but no new tasks will be accepted. Has no additional effect if the -thread pool is not running.

- - -
-
-
- - -
-
- -
-

- - - (Boolean) shutdown? - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Is the executor shutdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when shutdown, false when shutting down or running

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) shuttingdown? - - - - - - - Originally defined in module - JavaExecutor - - -

-
-

Is the executor shuttingdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when not running and not shutdown, else false

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) wait_for_termination(timeout = nil) - - - - - - - Originally defined in module - JavaExecutor - - -

-
- -
- Note: -

Does not initiate shutdown or termination. Either shutdown or kill -must be called before this method (or on another thread).

-
-
- -

Block until executor shutdown is complete or until timeout seconds have -passed.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Integer) - - - (defaults to: nil) - - - — -

    the maximum number of seconds to wait for shutdown to complete

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if shutdown complete or false on timeout

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/JavaThreadPoolExecutor.html b/docs/1.0.5/Concurrent/JavaThreadPoolExecutor.html index 4b5cab0ad..23f866095 100644 --- a/docs/1.0.5/Concurrent/JavaThreadPoolExecutor.html +++ b/docs/1.0.5/Concurrent/JavaThreadPoolExecutor.html @@ -1113,9 +1113,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::LazyReference - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/lazy_reference.rb
- -
-
- -

Overview

-
-

Lazy evaluation of a block yielding an immutable result. Useful for -expensive operations that may never be needed. LazyReference is a simpler, -blocking version of Delay and has an API similar to AtomicReference. -The first time #value is called the caller will block until the -block given at construction is executed. Once the result has been -computed the value will be immutably set. Any exceptions thrown during -computation will be suppressed.

- -

Because of its simplicity LazyReference is much faster than Delay:

- -
       user     system      total        real
-Benchmarking Delay...
-   0.730000   0.000000   0.730000 (  0.738434)
-Benchmarking LazyReference...
-   0.040000   0.000000   0.040000 (  0.042322)
-
- - -
-
-
- - -

See Also:

- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (LazyReference) initialize(default = nil) { ... } - - - - - -

-
-

Creates anew unfulfilled object.

- - -
-
-
-

Parameters:

-
    - -
  • - - default - - - (Object) - - - (defaults to: nil) - - - — -

    (nil) the default value for the object when -the block raises an exception

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the delayed operation to perform

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no block is given

    -
    - -
  • - -
- -
- - - - -
-
-
-
-29
-30
-31
-32
-33
-34
-35
-36
-
-
# File 'lib/concurrent/lazy_reference.rb', line 29
-
-def initialize(default = nil, &block)
-  raise ArgumentError.new('no block given') unless block_given?
-  @default = default
-  @task = block
-  @mutex = Mutex.new
-  @value = nil
-  @fulfilled = false
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) value - - - - - -

-
-

The calculated value of the object or the default value if one -was given at construction. This first time this method is called -it will block indefinitely while the block is processed. -Subsequent calls will not block.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the calculated value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-
-
# File 'lib/concurrent/lazy_reference.rb', line 44
-
-def value
-  # double-checked locking is safe because we only update once
-  return @value if @fulfilled
-
-  @mutex.synchronize do
-    unless @fulfilled
-      begin
-        @value = @task.call
-      rescue
-        @value = @default
-      ensure
-        @fulfilled = true
-      end
-    end
-    return @value
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/LazyRegister.html b/docs/1.0.5/Concurrent/LazyRegister.html index bc1a0771c..739a3117b 100644 --- a/docs/1.0.5/Concurrent/LazyRegister.html +++ b/docs/1.0.5/Concurrent/LazyRegister.html @@ -681,9 +681,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::LockFreeQueue - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/lock_free_queue.rb
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: Node - - -

- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Constructor Details

- -
-

- - - (LockFreeQueue) initialize - - - - - -

-
-

Returns a new instance of LockFreeQueue

- - -
-
-
- - -
- - - - -
-
-
-
-24
-25
-26
-27
-28
-29
-30
-
-
# File 'lib/concurrent/edge/lock_free_queue.rb', line 24
-
-def initialize
-  super()
-  dummy_node = Node.new(:dummy, nil)
-
-  self.head = dummy_node
-  self.tail = dummy_node
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (undocumented) pop - - - - - -

- - - - -
-
-
-
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-
-
# File 'lib/concurrent/edge/lock_free_queue.rb', line 62
-
-def pop
-  # retry until some value can be returned
-  while true
-    # the value in @head is just a dummy node that always sits in that position,
-    # the real 'head' is in its successor
-    current_dummy_node = head
-    current_tail_node  = tail
-
-    current_head_node = current_dummy_node.successor
-
-    # if our local head is still consistent with the head node, continue
-    # otherwise, start over
-    if current_dummy_node == head
-      # if either the queue is empty, or falling behind
-      if current_dummy_node == current_tail_node
-        # if there's nothing after the 'dummy' head node
-        if current_head_node.nil?
-          # just return nil
-          return nil
-        else
-          # here the head element succeeding head is not nil, but the head and tail are equal
-          # so tail is falling behind, update it, then start over
-          compare_and_set_tail(current_tail_node, current_head_node)
-        end
-
-        # the queue isn't empty
-        # if we can set the dummy head to the 'real' head, we're free to return the value in that real head, success
-      elsif compare_and_set_head(current_dummy_node, current_head_node)
-        # grab the item from the popped node
-        item = current_head_node.item
-
-        # return it, success!
-        return item
-      end
-    end
-  end
-end
-
-
- -
-

- - - (undocumented) push(item) - - - - - -

- - - - -
-
-
-
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-
-
# File 'lib/concurrent/edge/lock_free_queue.rb', line 32
-
-def push(item)
-  # allocate a new node with the item embedded
-  new_node = Node.new(item, nil)
-
-  # keep trying until the operation succeeds
-  while true
-    current_tail_node      = tail
-    current_tail_successor = current_tail_node.successor
-
-    # if our stored tail is still the current tail
-    if current_tail_node == tail
-      # if that tail was really the last node
-      if current_tail_successor.nil?
-        # if we can update the previous successor of tail to point to this new node
-        if current_tail_node.compare_and_set_successor(nil, new_node)
-          # then update tail to point to this node as well
-          compare_and_set_tail(current_tail_node, new_node)
-          # and return
-          return true
-          # else, start the loop over
-        end
-      else
-        # in this case, the tail ref we had wasn't the real tail
-        # so we try to set its successor as the real tail, then start the loop again
-        compare_and_set_tail(current_tail_node, current_tail_successor)
-      end
-    end
-  end
-end
-
-
- -
-

- - - (undocumented) size - - - - - -

-
-

approximate

- - -
-
-
- - -
- - - - -
-
-
-
-101
-102
-103
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-
-
# File 'lib/concurrent/edge/lock_free_queue.rb', line 101
-
-def size
-  successor = head.successor
-  count     = 0
-
-  while true
-    break if successor.nil?
-
-    current_node = successor
-    successor    = current_node.successor
-    count        += 1
-  end
-
-  count
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/LockFreeQueue/Node.html b/docs/1.0.5/Concurrent/LockFreeQueue/Node.html index 7a7c9ff37..773cc7230 100644 --- a/docs/1.0.5/Concurrent/LockFreeQueue/Node.html +++ b/docs/1.0.5/Concurrent/LockFreeQueue/Node.html @@ -259,9 +259,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::LockFreeStack - - - -

- -
- -
Inherits:
-
- Synchronization::Object - - - show all - -
- - - - - - -
Includes:
-
Enumerable
- - - - - -
Defined in:
-
lib/concurrent/edge/lock_free_stack.rb
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: Empty, Node - - -

- -

Constant Summary

- -
- -
EMPTY = - -
-
Empty[nil, nil]
- -
- - - - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Constructor Details

- -
-

- - - (LockFreeStack) initialize(head = EMPTY) - - - - - -

-
-

Returns a new instance of LockFreeStack

- - -
-
-
- - -
- - - - -
-
-
-
-39
-40
-41
-42
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 39
-
-def initialize(head = EMPTY)
-  super()
-  self.head = head
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - + (undocumented) of1(value) - - - - - -

- - - - -
-
-
-
-31
-32
-33
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 31
-
-def self.of1(value)
-  new Node[value, EMPTY]
-end
-
-
- -
-

- - + (undocumented) of2(value1, value2) - - - - - -

- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 35
-
-def self.of2(value1, value2)
-  new Node[value1, Node[value2, EMPTY]]
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (undocumented) clear - - - - - -

- - - - -
-
-
-
-90
-91
-92
-93
-94
-95
-96
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 90
-
-def clear
-  while true
-    current_head = head
-    return false if current_head == EMPTY
-    return true if compare_and_set_head current_head, EMPTY
-  end
-end
-
-
- -
-

- - - (undocumented) clear_each(&block) - - - - - -

- - - - -
-
-
-
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 106
-
-def clear_each(&block)
-  while true
-    current_head = head
-    return self if current_head == EMPTY
-    if compare_and_set_head current_head, EMPTY
-      each current_head, &block
-      return self
-    end
-  end
-end
-
-
- -
-

- - - (undocumented) clear_if(head) - - - - - -

- - - - -
-
-
-
-98
-99
-100
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 98
-
-def clear_if(head)
-  compare_and_set_head head, EMPTY
-end
-
-
- -
-

- - - (undocumented) compare_and_clear(head) - - - - - -

- - - - -
-
-
-
-74
-75
-76
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 74
-
-def compare_and_clear(head)
-  compare_and_set_head head, EMPTY
-end
-
-
- -
-

- - - (undocumented) compare_and_pop(head) - - - - - -

- - - - -
-
-
-
-63
-64
-65
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 63
-
-def compare_and_pop(head)
-  compare_and_set_head head, head.next_node
-end
-
-
- -
-

- - - (undocumented) compare_and_push(head, value) - - - - - -

- - - - -
-
-
-
-48
-49
-50
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 48
-
-def compare_and_push(head, value)
-  compare_and_set_head head, Node[value, head]
-end
-
-
- -
-

- - - (undocumented) each(head = nil) - - - - - -

- - - - -
-
-
-
-80
-81
-82
-83
-84
-85
-86
-87
-88
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 80
-
-def each(head = nil)
-  return to_enum(:each, head) unless block_given?
-  it = head || peek
-  until it.equal?(EMPTY)
-    yield it.value
-    it = it.next_node
-  end
-  self
-end
-
-
- -
-

- - - (Boolean) empty?(head = self.head) - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 44
-
-def empty?(head = self.head)
-  head.equal? EMPTY
-end
-
-
- -
-

- - - (undocumented) peek - - - - - -

- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 59
-
-def peek
-  head
-end
-
-
- -
-

- - - (undocumented) pop - - - - - -

- - - - -
-
-
-
-67
-68
-69
-70
-71
-72
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 67
-
-def pop
-  while true
-    current_head = head
-    return current_head.value if compare_and_set_head current_head, current_head.next_node
-  end
-end
-
-
- -
-

- - - (undocumented) push(value) - - - - - -

- - - - -
-
-
-
-52
-53
-54
-55
-56
-57
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 52
-
-def push(value)
-  while true
-    current_head = head
-    return self if compare_and_set_head current_head, Node[value, current_head]
-  end
-end
-
-
- -
-

- - - (undocumented) replace_if(head, new_head) - - - - - -

- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 102
-
-def replace_if(head, new_head)
-  compare_and_set_head head, new_head
-end
-
-
- -
-

- - - (String) to_s - - - - - -

-
-

Returns Short string representation.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (String) - - - - — -

    Short string representation.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-118
-119
-120
-
-
# File 'lib/concurrent/edge/lock_free_stack.rb', line 118
-
-def to_s
-  format '<#%s:0x%x %s>', self.class, object_id << 1, to_a.to_s
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/LockFreeStack/Empty.html b/docs/1.0.5/Concurrent/LockFreeStack/Empty.html index 3be6592c5..c93516296 100644 --- a/docs/1.0.5/Concurrent/LockFreeStack/Empty.html +++ b/docs/1.0.5/Concurrent/LockFreeStack/Empty.html @@ -322,9 +322,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Logging - - - -

- -
- - - - - -
Includes:
-
Logger::Severity
- - - - -
Included in:
-
Concurrent, Actor::Core, Agent, RubyExecutor, SerializedExecution
- - - -
Defined in:
-
lib/concurrent/logging.rb
- -
-
- -

Overview

-
-

Include where logging is needed

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
- - - - -
-
-
-
-13
-14
-15
-16
-17
-18
-
-
# File 'lib/concurrent/logging.rb', line 13
-
-def log(level, progname, message = nil, &block)
-  (@logger || Concurrent.global_logger).call level, progname, message, &block
-rescue => error
-  $stderr.puts "`Concurrent.configuration.logger` failed to log #{[level, progname, message, block]}\n" +
-      "#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MVar.html b/docs/1.0.5/Concurrent/MVar.html index 1e0dd7dec..7b767e6fd 100644 --- a/docs/1.0.5/Concurrent/MVar.html +++ b/docs/1.0.5/Concurrent/MVar.html @@ -1409,9 +1409,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::MutexAtomic - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
AtomicDirectUpdate, AtomicNumericCompareAndSetWrapper
- - - - - -
Defined in:
-
lib/concurrent/atomic_reference/mutex_atomic.rb
- -
-
- -

Overview

-
-

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
-
-

Direct Known Subclasses

-

Atomic

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Constructor Details

- -
-

- - - (MutexAtomic) initialize(value = nil) - - - - - -

-
-

Returns a new instance of MutexAtomic

- - -
-
-
- - -
- - - - -
-
-
-
-13
-14
-15
-16
-
-
# File 'lib/concurrent/atomic_reference/mutex_atomic.rb', line 13
-
-def initialize(value = nil)
-  @mutex = Mutex.new
-  @value = value
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) _compare_and_set(old_value, new_value) - - - - - -

-
-

Atomically sets the value to the given updated value if -the current value == the expected value.

- -

that the actual value was not equal to the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if successful. A false return indicates

    -
    - -
  • - -
- -
- - - - -
-
-
-
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-
-
# File 'lib/concurrent/atomic_reference/mutex_atomic.rb', line 66
-
-def _compare_and_set(old_value, new_value) #:nodoc:
-  return false unless @mutex.try_lock
-  begin
-    return false unless @value.equal? old_value
-    @value = new_value
-  ensure
-    @mutex.unlock
-  end
-  true
-end
-
-
- -
-

- - - (Boolean) compare_and_set(old_value, new_value) - - - - Also known as: - compare_and_swap - - - - - - Originally defined in module - AtomicNumericCompareAndSetWrapper - - -

-
-

Atomically sets the value to the given updated value if -the current value == the expected value.

- -

that the actual value was not equal to the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if successful. A false return indicates

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) get - - - - Also known as: - value - - - - -

-
-

Gets the current value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-23
-24
-25
-
-
# File 'lib/concurrent/atomic_reference/mutex_atomic.rb', line 23
-
-def get
-  @mutex.synchronize { @value }
-end
-
-
- -
-

- - - (Object) get_and_set(new_value) - - - - Also known as: - swap - - - - -

-
-

Atomically sets to the given value and returns the old value.

- - -
-
-
-

Parameters:

-
    - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the old value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-47
-48
-49
-50
-51
-52
-53
-
-
# File 'lib/concurrent/atomic_reference/mutex_atomic.rb', line 47
-
-def get_and_set(new_value)
-  @mutex.synchronize do
-    old_value = @value
-    @value = new_value
-    old_value
-  end
-end
-
-
- -
-

- - - (Object) set(new_value) - - - - Also known as: - value= - - - - -

-
-

Sets to the given value.

- - -
-
-
-

Parameters:

-
    - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/concurrent/atomic_reference/mutex_atomic.rb', line 35
-
-def set(new_value)
-  @mutex.synchronize { @value = new_value }
-end
-
-
- -
-

- - - (Object) try_update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. Raise an exception if the update -fails.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
-

Raises:

- - -
-
- -
-

- - - (Object) update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. May retry if the value changes -during the block's execution.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MutexAtomicBoolean.html b/docs/1.0.5/Concurrent/MutexAtomicBoolean.html deleted file mode 100644 index 751461f3b..000000000 --- a/docs/1.0.5/Concurrent/MutexAtomicBoolean.html +++ /dev/null @@ -1,821 +0,0 @@ - - - - - - Class: Concurrent::MutexAtomicBoolean - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::MutexAtomicBoolean - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_boolean.rb
- -
-
- -

Overview

-
-

A boolean value that can be updated atomically. Reads and writes to an atomic -boolean and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicBoolean...
-  2.790000   0.000000   2.790000 (  2.791454)
-Testing with Concurrent::CAtomicBoolean...
-  0.740000   0.000000   0.740000 (  0.740206)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicBoolean...
-  5.240000   2.520000   7.760000 (  3.683000)
-Testing with Concurrent::JavaAtomicBoolean...
-  3.340000   0.010000   3.350000 (  0.855000)
-
- - -
-
-
- - -

See Also:

- - -
-

Direct Known Subclasses

-

AtomicBoolean

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (MutexAtomicBoolean) initialize(initial = false) - - - - - -

-
-

Creates a new AtomicBoolean with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - initial - - - (Boolean) - - - (defaults to: false) - - - — -

    the initial value

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-31
-32
-33
-34
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 31
-
-def initialize(initial = false)
-  @value = !!initial
-  @mutex = Mutex.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) false? - - - - - -

-
-

Is the current value false

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is false, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-80
-81
-82
-83
-84
-85
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 80
-
-def false?
-  @mutex.lock
-  !@value
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Boolean) make_false - - - - - -

-
-

Explicitly sets the value to false.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-106
-107
-108
-109
-110
-111
-112
-113
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 106
-
-def make_false
-  @mutex.lock
-  old = @value
-  @value = false
-  old
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Boolean) make_true - - - - - -

-
-

Explicitly sets the value to true.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true is value has changed, otherwise false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-92
-93
-94
-95
-96
-97
-98
-99
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 92
-
-def make_true
-  @mutex.lock
-  old = @value
-  @value = true
-  !old
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Boolean) true? - - - - - -

-
-

Is the current value true

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the current value is true, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-68
-69
-70
-71
-72
-73
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 68
-
-def true?
-  @mutex.lock
-  @value
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Boolean) value - - - - - -

-
-

Retrieves the current Boolean value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-41
-42
-43
-44
-45
-46
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 41
-
-def value
-  @mutex.lock
-  @value
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Boolean) value=(value) - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Boolean) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-55
-56
-57
-58
-59
-60
-61
-
-
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 55
-
-def value=(value)
-  @mutex.lock
-  @value = !!value
-  @value
-ensure
-  @mutex.unlock
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MutexAtomicFixnum.html b/docs/1.0.5/Concurrent/MutexAtomicFixnum.html deleted file mode 100644 index 5670f1fa0..000000000 --- a/docs/1.0.5/Concurrent/MutexAtomicFixnum.html +++ /dev/null @@ -1,847 +0,0 @@ - - - - - - Class: Concurrent::MutexAtomicFixnum - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::MutexAtomicFixnum - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/atomic_fixnum.rb
- -
-
- -

Overview

-
-

A numeric value that can be updated atomically. Reads and writes to an atomic -fixnum and thread-safe and guaranteed to succeed. Reads and writes may block -briefly but no explicit locking is required.

- -
Testing with ruby 2.1.2
-Testing with Concurrent::MutexAtomicFixnum...
-  3.130000   0.000000   3.130000 (  3.136505)
-Testing with Concurrent::CAtomicFixnum...
-  0.790000   0.000000   0.790000 (  0.785550)
-
-Testing with jruby 1.9.3
-Testing with Concurrent::MutexAtomicFixnum...
-  5.460000   2.460000   7.920000 (  3.715000)
-Testing with Concurrent::JavaAtomicFixnum...
-  4.520000   0.030000   4.550000 (  1.187000)
-
- - -
-
-
- - -

See Also:

- - -
-

Direct Known Subclasses

-

AtomicFixnum

-
- -

Constant Summary

- -
- -
MIN_VALUE = - -
- - -
-
-
- 2))
- -
MAX_VALUE = - -
-
(2**(0.size * 8 - 2) - 1)
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (MutexAtomicFixnum) initialize(init = 0) - - - - - -

-
-

Creates a new AtomicFixnum with the given initial value.

- - -
-
-
-

Parameters:

-
    - -
  • - - init - - - (Fixnum) - - - (defaults to: 0) - - - — -

    the initial value

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the initial value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-36
-37
-38
-39
-40
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 36
-
-def initialize(init = 0)
-  raise ArgumentError.new('initial value must be a Fixnum') unless init.is_a?(Fixnum)
-  @value = init
-  @mutex = Mutex.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) compare_and_set(expect, update) - - - - - -

-
-

Atomically sets the value to the given updated value if the current -value == the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - expect - - - (Fixnum) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - update - - - (Fixnum) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the value was updated else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 108
-
-def compare_and_set(expect, update)
-  @mutex.lock
-  if @value == expect
-    @value = update
-    true
-  else
-    false
-  end
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Fixnum) decrement - - - - Also known as: - down - - - - -

-
-

Decreases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after decrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-90
-91
-92
-93
-94
-95
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 90
-
-def decrement
-  @mutex.lock
-  @value -= 1
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Fixnum) increment - - - - Also known as: - up - - - - -

-
-

Increases the current value by 1.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value after incrementation

    -
    - -
  • - -
- -
- - - - -
-
-
-
-76
-77
-78
-79
-80
-81
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 76
-
-def increment
-  @mutex.lock
-  @value += 1
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Fixnum) value - - - - - -

-
-

Retrieves the current Fixnum value.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
- -
- - - - -
-
-
-
-47
-48
-49
-50
-51
-52
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 47
-
-def value
-  @mutex.lock
-  @value
-ensure
-  @mutex.unlock
-end
-
-
- -
-

- - - (Fixnum) value=(value) - - - - - -

-
-

Explicitly sets the value.

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Fixnum) - - - - — -

    the new value to be set

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if the new value is not a Fixnum

    -
    - -
  • - -
- -
- - - - -
-
-
-
-63
-64
-65
-66
-67
-68
-69
-
-
# File 'lib/concurrent/atomic/atomic_fixnum.rb', line 63
-
-def value=(value)
-  raise ArgumentError.new('value must be a Fixnum') unless value.is_a?(Fixnum)
-  @mutex.lock
-  @value = value
-ensure
-  @mutex.unlock
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MutexCountDownLatch.html b/docs/1.0.5/Concurrent/MutexCountDownLatch.html deleted file mode 100644 index 1a03beb0e..000000000 --- a/docs/1.0.5/Concurrent/MutexCountDownLatch.html +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - Class: Concurrent::MutexCountDownLatch - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::MutexCountDownLatch - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/count_down_latch.rb
- -
-
- -

Overview

-
-

A synchronization object that allows one thread to wait on multiple other threads. -The thread that will wait creates a CountDownLatch and sets the initial value -(normally equal to the number of other threads). The initiating thread passes the -latch to the other threads then waits for the other threads by calling the #wait -method. Each of the other threads calls #count_down when done with its work. -When the latch counter reaches zero the waiting thread is unblocked and continues -with its work. A CountDownLatch can be used only once. Its value cannot be reset.

- - -
-
-
- - -
-

Direct Known Subclasses

-

CountDownLatch

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (MutexCountDownLatch) initialize(count = 1) - - - - - -

-
-

Create a new CountDownLatch with the initial count.

- - -
-
-
-

Parameters:

-
    - -
  • - - count - - - (Fixnum) - - - (defaults to: 1) - - - — -

    the initial count

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if count is not an integer or is less than zero

    -
    - -
  • - -
- -
- - - - -
-
-
-
-23
-24
-25
-26
-27
-28
-29
-30
-
-
# File 'lib/concurrent/atomic/count_down_latch.rb', line 23
-
-def initialize(count = 1)
-  unless count.is_a?(Fixnum) && count >= 0
-    raise ArgumentError.new('count must be in integer greater than or equal zero')
-  end
-  @mutex = Mutex.new
-  @condition = Condition.new
-  @count = count
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Fixnum) count - - - - - -

-
-

The current value of the counter.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the current value of the counter

    -
    - -
  • - -
- -
- - - - -
-
-
-
-67
-68
-69
-
-
# File 'lib/concurrent/atomic/count_down_latch.rb', line 67
-
-def count
-  @mutex.synchronize { @count }
-end
-
-
- -
-

- - - (Object) count_down - - - - - -

-
-

Signal the latch to decrement the counter. Will signal all blocked threads when -the count reaches zero.

- - -
-
-
- - -
- - - - -
-
-
-
-55
-56
-57
-58
-59
-60
-
-
# File 'lib/concurrent/atomic/count_down_latch.rb', line 55
-
-def count_down
-  @mutex.synchronize do
-    @count -= 1 if @count > 0
-    @condition.broadcast if @count == 0
-  end
-end
-
-
- -
-

- - - (Boolean) wait(timeout = nil) - - - - - -

-
-

Block on the latch until the counter reaches zero or until timeout is reached.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Fixnum) - - - (defaults to: nil) - - - — -

    the number of seconds to wait for the counter or nil -to block indefinitely

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the count reaches zero else false on timeout

    -
    - -
  • - -
- -
- - - - -
-
-
-
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-
-
# File 'lib/concurrent/atomic/count_down_latch.rb', line 39
-
-def wait(timeout = nil)
-  @mutex.synchronize do
-
-    remaining = Condition::Result.new(timeout)
-    while @count > 0 && remaining.can_wait?
-      remaining = @condition.wait(@mutex, remaining.remaining_time)
-    end
-
-    @count == 0
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MutexPriorityQueue.html b/docs/1.0.5/Concurrent/MutexPriorityQueue.html deleted file mode 100644 index 3c5ce6724..000000000 --- a/docs/1.0.5/Concurrent/MutexPriorityQueue.html +++ /dev/null @@ -1,1126 +0,0 @@ - - - - - - Class: Concurrent::MutexPriorityQueue - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::MutexPriorityQueue - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/collection/priority_queue.rb
- -
-
- -

Overview

-
- -
- Note: -

This implementation is not thread safe and performs no blocking.

-
-
- -

A queue collection in which the elements are sorted based on their -comparison (spaceship) operator <=>. Items are added to the queue -at a position relative to their priority. On removal the element -with the "highest" priority is removed. By default the sort order is -from highest to lowest, but a lowest-to-highest sort order can be -set on construction.

- -

The API is based on the Queue class from the Ruby standard library.

- -

The pure Ruby implementation, MutexPriorityQueue uses a heap algorithm -stored in an array. The algorithm is based on the work of Robert Sedgewick -and Kevin Wayne.

- -

The JRuby native implementation is a thin wrapper around the standard -library java.util.PriorityQueue.

- -

When running under JRuby the class PriorityQueue extends JavaPriorityQueue. -When running under all other interpreters it extends MutexPriorityQueue.

- - -
-
-
-

Direct Known Subclasses

-

PriorityQueue

-
- - - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Object) clear - - - - - - - - - - - - - -

    Removes all of the elements from this priority queue.

    -
    - -
  • - - -
  • - - - - (Object) delete(item) - - - - - - - - - - - - - -

    Deletes all items from self that are equal to item.

    -
    - -
  • - - -
  • - - - - (Boolean) empty? - - - - - - - - - - - - - -

    Returns true if self contains no elements.

    -
    - -
  • - - -
  • - - - - (Boolean) include?(item) - - - - (also: #has_priority?) - - - - - - - - - - - -

    Returns true if the given item is present in self (that is, if any element == item), otherwise returns false.

    -
    - -
  • - - -
  • - - - - (MutexPriorityQueue) initialize(opts = {}) - - - - - - - constructor - - - - - - - - -

    Create a new priority queue with no items.

    -
    - -
  • - - -
  • - - - - (Fixnum) length - - - - (also: #size) - - - - - - - - - - - -

    The current length of the queue.

    -
    - -
  • - - -
  • - - - - (Object) peek - - - - - - - - - - - - - -

    Retrieves, but does not remove, the head of this queue, or returns nil if this queue is empty.

    -
    - -
  • - - -
  • - - - - (Object) pop - - - - (also: #deq, #shift) - - - - - - - - - - - -

    Retrieves and removes the head of this queue, or returns nil if this queue is empty.

    -
    - -
  • - - -
  • - - - - (Object) push(item) - - - - (also: #<<, #enq) - - - - - - - - - - - -

    Inserts the specified element into this priority queue.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (MutexPriorityQueue) initialize(opts = {}) - - - - - -

-
-

Create a new priority queue with no items.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options for creating the queue

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :order - (Symbol) - - - — default: - :max - - - - —

    dictates the order in which items are -stored: from highest to lowest when :max or :high; from lowest to -highest when :min or :low

    -
    - -
  • - -
- - - -
- - - - -
-
-
-
-43
-44
-45
-46
-47
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 43
-
-def initialize(opts = {})
-  order = opts.fetch(:order, :max)
-  @comparator = [:min, :low].include?(order) ? -1 : 1
-  clear
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - + (Object) from_list(list, opts = {}) - - - - - -

- - - - -
-
-
-
-161
-162
-163
-164
-165
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 161
-
-def self.from_list(list, opts = {})
-  queue = new(opts)
-  list.each{|item| queue << item }
-  queue
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (Object) clear - - - - - -

-
-

Removes all of the elements from this priority queue.

- - -
-
-
- - -
- - - - -
-
-
-
-52
-53
-54
-55
-56
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 52
-
-def clear
-  @queue = [nil]
-  @length = 0
-  true
-end
-
-
- -
-

- - - (Object) delete(item) - - - - - -

-
-

Deletes all items from self that are equal to item.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to be removed from the queue

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    true if the item is found else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 64
-
-def delete(item)
-  original_length = @length
-  k = 1
-  while k <= @length
-    if @queue[k] == item
-      swap(k, @length)
-      @length -= 1
-      sink(k)
-      @queue.pop
-    else
-      k += 1
-    end
-  end
-  @length != original_length
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if self contains no elements.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if there are no items in the queue else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-85
-86
-87
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 85
-
-def empty?
-  size == 0
-end
-
-
- -
-

- - - (Boolean) include?(item) - - - - Also known as: - has_priority? - - - - -

-
-

Returns true if the given item is present in self (that is, if any -element == item), otherwise returns false.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to search for

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the item is found else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-97
-98
-99
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 97
-
-def include?(item)
-  @queue.include?(item)
-end
-
-
- -
-

- - - (Fixnum) length - - - - Also known as: - size - - - - -

-
-

The current length of the queue.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Fixnum) - - - - — -

    the number of items in the queue

    -
    - -
  • - -
- -
- - - - -
-
-
-
-107
-108
-109
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 107
-
-def length
-  @length
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Retrieves, but does not remove, the head of this queue, or returns nil -if this queue is empty.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the head of the queue or nil when empty

    -
    - -
  • - -
- -
- - - - -
-
-
-
-118
-119
-120
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 118
-
-def peek
-  @queue[1]
-end
-
-
- -
-

- - - (Object) pop - - - - Also known as: - deq, shift - - - - -

-
-

Retrieves and removes the head of this queue, or returns nil if this -queue is empty.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the head of the queue or nil when empty

    -
    - -
  • - -
- -
- - - - -
-
-
-
-128
-129
-130
-131
-132
-133
-134
-135
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 128
-
-def pop
-  max = @queue[1]
-  swap(1, @length)
-  @length -= 1
-  sink(1)
-  @queue.pop
-  max
-end
-
-
- -
-

- - - (Object) push(item) - - - - Also known as: - <<, enq - - - - -

-
-

Inserts the specified element into this priority queue.

- - -
-
-
-

Parameters:

-
    - -
  • - - item - - - (Object) - - - - — -

    the item to insert onto the queue

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-144
-145
-146
-147
-148
-149
-
-
# File 'lib/concurrent/collection/priority_queue.rb', line 144
-
-def push(item)
-  @length += 1
-  @queue << item
-  swim(@length)
-  true
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/MutexSemaphore.html b/docs/1.0.5/Concurrent/MutexSemaphore.html deleted file mode 100644 index 0d95b2065..000000000 --- a/docs/1.0.5/Concurrent/MutexSemaphore.html +++ /dev/null @@ -1,974 +0,0 @@ - - - - - - Class: Concurrent::MutexSemaphore - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::MutexSemaphore - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/atomic/semaphore.rb
- -
-
- -
-

Direct Known Subclasses

-

Semaphore

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (MutexSemaphore) initialize(count) - - - - - -

-
-

Create a new Semaphore with the initial count.

- - -
-
-
-

Parameters:

-
    - -
  • - - count - - - (Fixnum) - - - - — -

    the initial count

    -
    - -
  • - -
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if count is not an integer or is less than zero

    -
    - -
  • - -
- -
- - - - -
-
-
-
-12
-13
-14
-15
-16
-17
-18
-19
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 12
-
-def initialize(count)
-  unless count.is_a?(Fixnum) && count >= 0
-    fail ArgumentError, 'count must be an non-negative integer'
-  end
-  @mutex = Mutex.new
-  @condition = Condition.new
-  @free = count
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Nil) acquire(permits = 1) - - - - - -

-
-

Acquires the given number of permits from this semaphore, - blocking until all are available.

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    Number of permits to acquire

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not an integer or is less than -one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-32
-33
-34
-35
-36
-37
-38
-39
-40
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 32
-
-def acquire(permits = 1)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  @mutex.synchronize do
-    try_acquire_timed(permits, nil)
-    nil
-  end
-end
-
-
- -
-

- - - (Integer) available_permits - - - - - -

-
-

Returns the current number of permits available in this semaphore.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-47
-48
-49
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 47
-
-def available_permits
-  @mutex.synchronize { @free }
-end
-
-
- -
-

- - - (Integer) drain_permits - - - - - -

-
-

Acquires and returns all permits that are immediately available.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-56
-57
-58
-59
-60
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 56
-
-def drain_permits
-  @mutex.synchronize do
-    @free.tap { |_| @free = 0 }
-  end
-end
-
-
- -
-

- - - (Nil) reduce_permits(reduction) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

-

Shrinks the number of available permits by the indicated reduction.

- - -
-
-
-

Parameters:

-
    - -
  • - - reduction - - - (Fixnum) - - - - — -

    Number of permits to remove.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if reduction is not an integer or is negative

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if @free - @reduction is less than zero

    -
    - -
  • - -
- -
- - - - -
-
-
-
-124
-125
-126
-127
-128
-129
-130
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 124
-
-def reduce_permits(reduction)
-  unless reduction.is_a?(Fixnum) && reduction >= 0
-    fail ArgumentError, 'reduction must be an non-negative integer'
-  end
-  @mutex.synchronize { @free -= reduction }
-  nil
-end
-
-
- -
-

- - - (Nil) release(permits = 1) - - - - - -

-
-

Releases the given number of permits, returning them to the semaphore.

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    Number of permits to return to the semaphore.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Nil) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not a number or is less than one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-100
-101
-102
-103
-104
-105
-106
-107
-108
-109
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 100
-
-def release(permits = 1)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  @mutex.synchronize do
-    @free += permits
-    permits.times { @condition.signal }
-  end
-  nil
-end
-
-
- -
-

- - - (Boolean) try_acquire(permits = 1, timeout = nil) - - - - - -

-
-

Acquires the given number of permits from this semaphore, - only if all are available at the time of invocation or within - timeout interval

- - -
-
-
-

Parameters:

-
    - -
  • - - permits - - - (Fixnum) - - - (defaults to: 1) - - - — -

    the number of permits to acquire

    -
    - -
  • - -
  • - - timeout - - - (Fixnum) - - - (defaults to: nil) - - - — -

    the number of seconds to wait for the counter -or nil to return immediately

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    false if no permits are available, true when -acquired a permit

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if permits is not an integer or is less than -one

    -
    - -
  • - -
- -
- - - - -
-
-
-
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-
-
# File 'lib/concurrent/atomic/semaphore.rb', line 78
-
-def try_acquire(permits = 1, timeout = nil)
-  unless permits.is_a?(Fixnum) && permits > 0
-    fail ArgumentError, 'permits must be an integer greater than zero'
-  end
-  @mutex.synchronize do
-    if timeout.nil?
-      try_acquire_now(permits)
-    else
-      try_acquire_timed(permits, timeout)
-    end
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/OptionsParser.html b/docs/1.0.5/Concurrent/OptionsParser.html deleted file mode 100644 index 5bd314f9d..000000000 --- a/docs/1.0.5/Concurrent/OptionsParser.html +++ /dev/null @@ -1,1112 +0,0 @@ - - - - - - Module: Concurrent::OptionsParser - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::OptionsParser - - - -

- -
- - - -
Extended by:
-
OptionsParser
- - - - - - -
Included in:
-
OptionsParser
- - - -
Defined in:
-
lib/concurrent/options_parser.rb
- -
-
- -

Overview

-
-

A mixin module for parsing options hashes related to gem-level configuration.

- - -
-
-
- - -
- - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Class Method Details

- - -
-

- - + (Object) get_arguments_from(opts = {}) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/options_parser.rb', line 26
-
-def get_arguments_from(opts = {})
-  [*opts.fetch(:args, [])]
-end
-
-
- -
-

- - + (Executor?) get_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
  • - :operation - (Boolean) - - - — default: - `false` - - - - —

    when true use the global operation pool

    -
    - -
  • - -
  • - :task - (Boolean) - - - — default: - `true` - - - - —

    when true use the global task pool

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor, nil) - - - - — -

    the requested thread pool, or nil when no option specified

    -
    - -
  • - -
- -
- - - - -
-
-
-
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-
-
# File 'lib/concurrent/options_parser.rb', line 14
-
-def get_executor_from(opts = {})
-  if opts[:executor]
-    opts[:executor]
-  elsif opts[:operation] == true || opts[:task] == false
-    Concurrent.configuration.global_operation_pool
-  elsif opts[:operation] == false || opts[:task] == true
-    Concurrent.configuration.global_task_pool
-  else
-    nil
-  end
-end
-
-
- -
-

- - + (Executor) get_operation_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :task_executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    the requested thread pool (default: global operation pool)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/options_parser.rb', line 46
-
-def get_operation_executor_from(opts = {})
-  opts[:operation_executor] || opts[:executor] || Concurrent.configuration.global_operation_pool
-end
-
-
- -
-

- - + (Executor) get_task_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :task_executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    the requested thread pool (default: global task pool)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-36
-37
-38
-
-
# File 'lib/concurrent/options_parser.rb', line 36
-
-def get_task_executor_from(opts = {})
-  opts[:task_executor] || opts[:executor] || Concurrent.configuration.global_task_pool
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (Object) get_arguments_from(opts = {}) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/options_parser.rb', line 26
-
-def get_arguments_from(opts = {})
-  [*opts.fetch(:args, [])]
-end
-
-
- -
-

- - - (Executor?) get_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
  • - :operation - (Boolean) - - - — default: - `false` - - - - —

    when true use the global operation pool

    -
    - -
  • - -
  • - :task - (Boolean) - - - — default: - `true` - - - - —

    when true use the global task pool

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor, nil) - - - - — -

    the requested thread pool, or nil when no option specified

    -
    - -
  • - -
- -
- - - - -
-
-
-
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-
-
# File 'lib/concurrent/options_parser.rb', line 14
-
-def get_executor_from(opts = {})
-  if opts[:executor]
-    opts[:executor]
-  elsif opts[:operation] == true || opts[:task] == false
-    Concurrent.configuration.global_operation_pool
-  elsif opts[:operation] == false || opts[:task] == true
-    Concurrent.configuration.global_task_pool
-  else
-    nil
-  end
-end
-
-
- -
-

- - - (Executor) get_operation_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :task_executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    the requested thread pool (default: global operation pool)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/options_parser.rb', line 46
-
-def get_operation_executor_from(opts = {})
-  opts[:operation_executor] || opts[:executor] || Concurrent.configuration.global_operation_pool
-end
-
-
- -
-

- - - (Executor) get_task_executor_from(opts = {}) - - - - - -

-
-

Get the requested Executor based on the values set in the options hash.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining the requested executor

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :task_executor - (Executor) - - - — default: - `nil` - - - - —

    when set use the given Executor instance

    -
    - -
  • - -
- - -

Returns:

-
    - -
  • - - - (Executor) - - - - — -

    the requested thread pool (default: global task pool)

    -
    - -
  • - -
- -
- - - - -
-
-
-
-36
-37
-38
-
-
# File 'lib/concurrent/options_parser.rb', line 36
-
-def get_task_executor_from(opts = {})
-  opts[:task_executor] || opts[:executor] || Concurrent.configuration.global_task_pool
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/PerThreadExecutor.html b/docs/1.0.5/Concurrent/PerThreadExecutor.html deleted file mode 100644 index 06ece90d4..000000000 --- a/docs/1.0.5/Concurrent/PerThreadExecutor.html +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - Class: Concurrent::PerThreadExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::PerThreadExecutor - - Deprecated - -

- -
- -
Inherits:
-
- SimpleExecutorService - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/simple_executor_service.rb
- -
-
- -

Overview

-
-
Deprecated.
- - -
-
-
- - -
-

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

- - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (PerThreadExecutor) initialize - - - - - -

-
-

Returns a new instance of PerThreadExecutor

- - -
-
-
- - -
- - - - -
-
-
-
-104
-105
-106
-107
-
-
# File 'lib/concurrent/executor/simple_executor_service.rb', line 104
-
-def initialize
-  deprecated 'use SimpleExecutorService instead'
-  super
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in class - RubyExecutorService - - -

-
- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in class - AbstractExecutorService - - -

-
-

Returns the value of attribute fallback_policy

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Postable.html b/docs/1.0.5/Concurrent/Postable.html deleted file mode 100644 index 3be3b193f..000000000 --- a/docs/1.0.5/Concurrent/Postable.html +++ /dev/null @@ -1,707 +0,0 @@ - - - - - - Module: Concurrent::Postable - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Postable - - - -

- -
- - - - - - - -
Included in:
-
Actor
- - - -
Defined in:
-
lib/concurrent/actor/postable.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) <<(message) - - - - - -

- - - - -
-
-
-
-45
-46
-47
-48
-
-
# File 'lib/concurrent/actor/postable.rb', line 45
-
-def <<(message)
-  post(*message)
-  self
-end
-
-
- -
-

- - - (Object) forward(receiver, *message) - - - - - -

-
-
Deprecated.

+Actor+ is being replaced with a completely new framework prior to v1.0.0

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-79
-80
-81
-82
-83
-84
-
-
# File 'lib/concurrent/actor/postable.rb', line 79
-
-def forward(receiver, *message)
-  raise ArgumentError.new('empty message') if message.empty?
-  return false unless ready?
-  queue.push(Package.new(message, receiver))
-  queue.length
-end
-
-
- -
-

- - - (Object) post(*message) - - - - - -

-
-

Sends a message to and returns. It's a fire-and-forget interaction.

- - -
-
-
- -
-

Examples:

- - -
class EchoActor < Concurrent::Actor
-  def act(*message)
-    p message
-  end
-end
-
-echo = EchoActor.new
-echo.run!
-
-echo.post("Don't panic") #=> true
-#=> ["Don't panic"]
-
-echo.post(1, 2, 3, 4, 5) #=> true
-#=> [1, 2, 3, 4, 5]
-
-echo << "There's a frood who really knows where his towel is." #=> #<EchoActor:0x007fc8012b8448...
-#=> ["There's a frood who really knows where his towel is."]
- -
-

Parameters:

-
    - -
  • - - message - - - (Array) - - - - — -

    one or more arguments representing a single message -to be sent to the receiver.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    false when the message cannot be queued else the number -of messages in the queue after this message has been post

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - - - - - -

    ArgumentError when the message is empty

    -
    - -
  • - -
- -
- - - - -
-
-
-
-38
-39
-40
-41
-42
-43
-
-
# File 'lib/concurrent/actor/postable.rb', line 38
-
-def post(*message)
-  raise ArgumentError.new('empty message') if message.empty?
-  return false unless ready?
-  queue.push(Package.new(message))
-  true
-end
-
-
- -
-

- - - (Object) post!(seconds, *message) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-
-
# File 'lib/concurrent/actor/postable.rb', line 58
-
-def post!(seconds, *message)
-  raise ArgumentError.new('empty message') if message.empty?
-  raise Concurrent::LifecycleError unless ready?
-  raise Concurrent::TimeoutError if seconds.to_f <= 0.0
-  event = Event.new
-  cback = Queue.new
-  queue.push(Package.new(message, cback, event))
-  if event.wait(seconds)
-    result = cback.pop
-    if result.is_a?(Exception)
-      raise result
-    else
-      return result
-    end
-  else
-    event.set # attempt to cancel
-    raise Concurrent::TimeoutError
-  end
-end
-
-
- -
-

- - - (Boolean) post?(*message) - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-50
-51
-52
-53
-54
-55
-56
-
-
# File 'lib/concurrent/actor/postable.rb', line 50
-
-def post?(*message)
-  raise ArgumentError.new('empty message') if message.empty?
-  return nil unless ready?
-  ivar = IVar.new
-  queue.push(Package.new(message, ivar))
-  ivar
-end
-
-
- -
-

- - - (Boolean) ready? - - - - - -

-
-
Deprecated.

+Actor+ is being replaced with a completely new framework prior to v1.0.0

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-87
-88
-89
-90
-91
-92
-93
-
-
# File 'lib/concurrent/actor/postable.rb', line 87
-
-def ready?
-  if self.respond_to?(:running?) && ! running?
-    false
-  else
-    true
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/PriorityQueue.html b/docs/1.0.5/Concurrent/PriorityQueue.html deleted file mode 100644 index cd7428ed5..000000000 --- a/docs/1.0.5/Concurrent/PriorityQueue.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - Class: Concurrent::PriorityQueue - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::PriorityQueue - - - -

- -
- -
Inherits:
-
- MutexPriorityQueue - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/collection/priority_queue.rb,
- lib/concurrent/collection/priority_queue.rb
-
- -
-
- -

Overview

-
- -
- Note: -

This implementation is not thread safe and performs no blocking.

-
-
- -

A queue collection in which the elements are sorted based on their -comparison (spaceship) operator <=>. Items are added to the queue -at a position relative to their priority. On removal the element -with the "highest" priority is removed. By default the sort order is -from highest to lowest, but a lowest-to-highest sort order can be -set on construction.

- -

The API is based on the Queue class from the Ruby standard library.

- -

The pure Ruby implementation, MutexPriorityQueue uses a heap algorithm -stored in an array. The algorithm is based on the work of Robert Sedgewick -and Kevin Wayne.

- -

The JRuby native implementation is a thin wrapper around the standard -library java.util.PriorityQueue.

- -

When running under JRuby the class PriorityQueue extends JavaPriorityQueue. -When running under all other interpreters it extends MutexPriorityQueue.

- - -
-
- - - - - - - - - -
-

Constructor Details

- -

This class inherits a constructor from Concurrent::MutexPriorityQueue

- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ProcessingActor.html b/docs/1.0.5/Concurrent/ProcessingActor.html index 6e06a43b0..66482b055 100644 --- a/docs/1.0.5/Concurrent/ProcessingActor.html +++ b/docs/1.0.5/Concurrent/ProcessingActor.html @@ -1161,9 +1161,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::ProcessorCounter - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/utility/processor_count.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (ProcessorCounter) initialize - - - - - -

-
-

Returns a new instance of ProcessorCounter

- - -
-
-
- - -
- - - - -
-
-
-
-7
-8
-9
-10
-
-
# File 'lib/concurrent/utility/processor_count.rb', line 7
-
-def initialize
-  @processor_count          = LazyReference.new { compute_processor_count }
-  @physical_processor_count = LazyReference.new { compute_physical_processor_count }
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Integer) physical_processor_count - - - - - -

-
-

Number of physical processor cores on the current system. For performance -reasons the calculated value will be memoized on the first call.

- -

On Windows the Win32 API will be queried for the NumberOfCores from -Win32_Processor. This will return the total number "of cores for the -current instance of the processor." On Unix-like operating systems either -the hwprefs or sysctl utility will be called in a subshell and the -returned value will be used. In the rare case where none of these methods -work or an exception is raised the function will simply return 1.

- - -
-
- - - - - -
-
-
-
-67
-68
-69
-
-
# File 'lib/concurrent/utility/processor_count.rb', line 67
-
-def physical_processor_count
-  @physical_processor_count.value
-end
-
-
- -
-

- - - (Integer) processor_count - - - - - -

-
-

Number of processors seen by the OS and used for process scheduling. For -performance reasons the calculated value will be memoized on the first -call.

- -

When running under JRuby the Java runtime call -java.lang.Runtime.getRuntime.availableProcessors will be used. According -to the Java documentation this "value may change during a particular -invocation of the virtual machine... [applications] should therefore -occasionally poll this property." Subsequently the result will NOT be -memoized under JRuby.

- -

On Windows the Win32 API will be queried for the -NumberOfLogicalProcessors from Win32_Processor. This will return the -total number "logical processors for the current instance of the -processor", which taked into account hyperthreading.

- -
    -
  • AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
  • -
  • BSD: /sbin/sysctl
  • -
  • Cygwin: /proc/cpuinfo
  • -
  • Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
  • -
  • HP-UX: /usr/sbin/ioscan
  • -
  • IRIX: /usr/sbin/sysconf
  • -
  • Linux: /proc/cpuinfo
  • -
  • Minix 3+: /proc/cpuinfo
  • -
  • Solaris: /usr/sbin/psrinfo
  • -
  • Tru64 UNIX: /usr/sbin/psrinfo
  • -
  • UnixWare: /usr/sbin/psrinfo
  • -
- - -
-
- - - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/utility/processor_count.rb', line 46
-
-def processor_count
-  @processor_count.value
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Promise.html b/docs/1.0.5/Concurrent/Promise.html index f460ab9c7..7a0225423 100644 --- a/docs/1.0.5/Concurrent/Promise.html +++ b/docs/1.0.5/Concurrent/Promise.html @@ -2698,9 +2698,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::RbxAtomic - - - -

- -
- -
Inherits:
-
- Rubinius::AtomicReference - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - -
Includes:
-
AtomicDirectUpdate, AtomicNumericCompareAndSetWrapper
- - - - - -
Defined in:
-
lib/concurrent/atomic_reference/rbx.rb
- -
-
- -

Overview

-
- -
- Note: -

Extends Rubinius::AtomicReference version adding aliases -and numeric logic.

-
-
- -

An object reference that may be updated atomically.

- -
Testing with ruby 2.1.2
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.000000   0.000000   0.000000 (  0.005502)
-mutex        0.030000   0.000000   0.030000 (  0.025158)
-MutexAtomic  0.100000   0.000000   0.100000 (  0.103096)
-CAtomic      0.040000   0.000000   0.040000 (  0.034012)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.010000   0.000000   0.010000 (  0.009387)
-mutex        0.030000   0.010000   0.040000 (  0.032545)
-MutexAtomic  0.830000   2.280000   3.110000 (  2.146622)
-CAtomic      0.040000   0.000000   0.040000 (  0.038332)
-
-Testing with jruby 1.9.3
-
-*** Sequential updates ***
-                 user     system      total        real
-no lock      0.170000   0.000000   0.170000 (  0.051000)
-mutex        0.370000   0.010000   0.380000 (  0.121000)
-MutexAtomic  1.530000   0.020000   1.550000 (  0.471000)
-JavaAtomic   0.370000   0.010000   0.380000 (  0.112000)
-
-*** Parallel updates ***
-                 user     system      total        real
-no lock      0.390000   0.000000   0.390000 (  0.105000)
-mutex        0.480000   0.040000   0.520000 (  0.145000)
-MutexAtomic  1.600000   0.180000   1.780000 (  0.511000)
-JavaAtomic   0.460000   0.010000   0.470000 (  0.131000)
-
- - -
-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Boolean) compare_and_set(old_value, new_value) - - - - Also known as: - compare_and_swap - - - - - - Originally defined in module - AtomicNumericCompareAndSetWrapper - - -

-
-

Atomically sets the value to the given updated value if -the current value == the expected value.

- -

that the actual value was not equal to the expected value.

- - -
-
-
-

Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the expected value

    -
    - -
  • - -
  • - - new_value - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if successful. A false return indicates

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) try_update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. Raise an exception if the update -fails.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
-

Raises:

- - -
-
- -
-

- - - (Object) update {|Object| ... } - - - - - - - Originally defined in module - AtomicDirectUpdate - - -

-
-

Pass the current value to the given block, replacing it -with the block's result. May retry if the value changes -during the block's execution.

- - -
-
-
- -

Yields:

-
    - -
  • - - - (Object) - - - - — -

    Calculate a new value for the atomic reference using -given (old) value

    -
    - -
  • - -
-

Yield Parameters:

-
    - -
  • - - old_value - - - (Object) - - - - — -

    the starting value of the atomic reference

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the new value

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ReadWriteLock.html b/docs/1.0.5/Concurrent/ReadWriteLock.html index 5596dd120..c03ef1f21 100644 --- a/docs/1.0.5/Concurrent/ReadWriteLock.html +++ b/docs/1.0.5/Concurrent/ReadWriteLock.html @@ -1181,9 +1181,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::RingBuffer - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/collection/ring_buffer.rb
- -
-
- -

Overview

-
-

non-thread safe buffer

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- -
    - -
  • - - - - (Integer) capacity - - - - - - - - - - - - - -

    The capacity of the buffer.

    -
    - -
  • - - -
  • - - - - (Integer) count - - - - - - - - - - - - - -

    The number of elements currently in the buffer.

    -
    - -
  • - - -
  • - - - - (Boolean) empty? - - - - - - - - - - - - - -

    True if buffer is empty, false otherwise.

    -
    - -
  • - - -
  • - - - - (Boolean) full? - - - - - - - - - - - - - -

    True if buffer is full, false otherwise.

    -
    - -
  • - - -
  • - - - - (RingBuffer) initialize(capacity) - - - - - - - constructor - - - - - - - - -

    A new instance of RingBuffer.

    -
    - -
  • - - -
  • - - - - (Boolean) offer(value) - - - - - - - - - - - - - -

    True if value has been inserted, false otherwise.

    -
    - -
  • - - -
  • - - - - (Object) peek - - - - - - - - - - - - - -

    The first available value and without removing it from the buffer.

    -
    - -
  • - - -
  • - - - - (Object) poll - - - - - - - - - - - - - -

    The first available value and removes it from the buffer.

    -
    - -
  • - - -
- - -
-

Constructor Details

- -
-

- - - (RingBuffer) initialize(capacity) - - - - - -

-
-

Returns a new instance of RingBuffer

- - -
-
-
- - -
- - - - -
-
-
-
-6
-7
-8
-9
-10
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 6
-
-def initialize(capacity)
-  @buffer = Array.new(capacity)
-  @first = @last = 0
-  @count = 0
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Integer) capacity - - - - - -

-
-

Returns the capacity of the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the capacity of the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 14
-
-def capacity
-  @buffer.size
-end
-
-
- -
-

- - - (Integer) count - - - - - -

-
-

Returns the number of elements currently in the buffer

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the number of elements currently in the buffer

    -
    - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 19
-
-def count
-  @count
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
-

Returns true if buffer is empty, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is empty, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-24
-25
-26
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 24
-
-def empty?
-  @count == 0
-end
-
-
- -
-

- - - (Boolean) full? - - - - - -

-
-

Returns true if buffer is full, false otherwise

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if buffer is full, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 29
-
-def full?
-  @count == capacity
-end
-
-
- -
-

- - - (Boolean) offer(value) - - - - - -

-
-

Returns true if value has been inserted, false otherwise

- - -
-
-
-

Parameters:

-
    - -
  • - - value - - - (Object) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if value has been inserted, false otherwise

    -
    - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-38
-39
-40
-41
-42
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 35
-
-def offer(value)
-  return false if full?
-
-  @buffer[@last] = value
-  @last = (@last + 1) % @buffer.size
-  @count += 1
-  true
-end
-
-
- -
-

- - - (Object) peek - - - - - -

-
-

Returns the first available value and without removing it from -the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and without removing it from -the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-55
-56
-57
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 55
-
-def peek
-  @buffer[@first]
-end
-
-
- -
-

- - - (Object) poll - - - - - -

-
-

Returns the first available value and removes it from the buffer. If buffer is empty returns nil

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the first available value and removes it from the buffer. If buffer is empty returns nil

    -
    - -
  • - -
- -
- - - - -
-
-
-
-45
-46
-47
-48
-49
-50
-51
-
-
# File 'lib/concurrent/collection/ring_buffer.rb', line 45
-
-def poll
-  result = @buffer[@first]
-  @buffer[@first] = nil
-  @first = (@first + 1) % @buffer.size
-  @count -= 1
-  result
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubyCachedThreadPool.html b/docs/1.0.5/Concurrent/RubyCachedThreadPool.html deleted file mode 100644 index 6ef7f16cd..000000000 --- a/docs/1.0.5/Concurrent/RubyCachedThreadPool.html +++ /dev/null @@ -1,1124 +0,0 @@ - - - - - - Class: Concurrent::RubyCachedThreadPool - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::RubyCachedThreadPool - - - -

- -
- -
Inherits:
-
- RubyThreadPoolExecutor - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/ruby_cached_thread_pool.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

A thread pool that dynamically grows and shrinks to fit the current workload. -New threads are created as needed, existing threads are reused, and threads -that remain idle for too long are killed and removed from the pool. These -pools are particularly suited to applications that perform a high volume of -short-lived tasks.

- -

On creation a CachedThreadPool has zero running threads. New threads are -created on the pool as new operations are #post. The size of the pool -will grow until #max_length threads are in the pool or until the number -of threads exceeds the number of running and pending operations. When a new -operation is post to the pool the first available idle thread will be tasked -with the new operation.

- -

Should a thread crash for any reason the thread will immediately be removed -from the pool. Similarly, threads which remain idle for an extended period -of time will be killed and reclaimed. Thus these thread pools are very -efficient at reclaiming unused resources.

- -

The API and behavior of this class are based on Java's CachedThreadPool

- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
-
-

Direct Known Subclasses

-

CachedThreadPool

-
- -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

- - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (RubyCachedThreadPool) initialize(opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining pool behavior.

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :fallback_policy - (Symbol) - - - — default: - `:abort` - - - - —

    the fallback policy

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if fallback_policy is not a known policy

    -
    - -
  • - -
- -
- - - - -
-
-
-
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-
-
# File 'lib/concurrent/executor/ruby_cached_thread_pool.rb', line 15
-
-def initialize(opts = {})
-  fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
-
-  raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(fallback_policy)
-
-  opts = opts.merge(
-    min_threads: 0,
-    max_threads: DEFAULT_MAX_POOL_SIZE,
-    fallback_policy: fallback_policy,
-    max_queue: DEFAULT_MAX_QUEUE_SIZE,
-    idletime: DEFAULT_THREAD_IDLETIMEOUT
-  )
-  super(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) completed_task_count (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of tasks that have been completed by the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) idletime (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of seconds that a thread may be idle before being reclaimed.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) largest_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The largest number of threads that have been created in the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) max_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The maximum number of threads that may be created in the pool.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) max_queue (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The maximum number of tasks that may be waiting in the work queue at any one time. -When the queue size reaches max_queue subsequent tasks will be rejected in -accordance with the configured fallback_policy.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) min_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The minimum number of threads that may be retained in the pool.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) mutex (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute mutex

- - -
-
-
- - -
-
- - - -
-

- - - (Object) scheduled_task_count (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of tasks that have been scheduled for execution on the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stop_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stop_event

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stopped_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stopped_event

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubyExecutor.html b/docs/1.0.5/Concurrent/RubyExecutor.html deleted file mode 100644 index 8c865747b..000000000 --- a/docs/1.0.5/Concurrent/RubyExecutor.html +++ /dev/null @@ -1,1954 +0,0 @@ - - - - - - Module: Concurrent::RubyExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::RubyExecutor - - - -

- -
- - - - - -
Includes:
-
Executor, Logging
- - - - -
Included in:
-
RubySingleThreadExecutor, RubyThreadPoolExecutor, TimerSet, TimerTask
- - - -
Defined in:
-
lib/concurrent/executor/executor.rb
- -
-
- - -

Constant Summary

- -
- -
FALLBACK_POLICIES = -
-
-

The set of possible fallback policies that may be set at thread pool creation.

- - -
-
-
- - -
-
-
[:abort, :discard, :caller_runs]
- -
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
  • - - - - (Object) mutex - - - - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute mutex.

    -
    - -
  • - - -
  • - - - - (Object) stop_event - - - - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stop_event.

    -
    - -
  • - - -
  • - - - - (Object) stopped_event - - - - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stopped_event.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) mutex (readonly, protected) - - - - - -

-
-

Returns the value of attribute mutex

- - -
-
-
- - -
- - - - -
-
-
-
-239
-240
-241
-
-
# File 'lib/concurrent/executor/executor.rb', line 239
-
-def mutex
-  @mutex
-end
-
-
- - - -
-

- - - (Object) stop_event (readonly, protected) - - - - - -

-
-

Returns the value of attribute stop_event

- - -
-
-
- - -
- - - - -
-
-
-
-239
-240
-241
-
-
# File 'lib/concurrent/executor/executor.rb', line 239
-
-def stop_event
-  @stop_event
-end
-
-
- - - -
-

- - - (Object) stopped_event (readonly, protected) - - - - - -

-
-

Returns the value of attribute stopped_event

- - -
-
-
- - -
- - - - -
-
-
-
-239
-240
-241
-
-
# File 'lib/concurrent/executor/executor.rb', line 239
-
-def stopped_event
-  @stopped_event
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (self) <<(task) - - - - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - task - - - (Proc) - - - - — -

    the asynchronous task to perform

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (self) - - - - — -

    returns itself

    -
    - -
  • - -
- -
- - - - -
-
-
-
-160
-161
-162
-163
-
-
# File 'lib/concurrent/executor/executor.rb', line 160
-
-def <<(task)
-  post(&task)
-  self
-end
-
-
- -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) execute(*args, &task) (protected) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-252
-253
-254
-
-
# File 'lib/concurrent/executor/executor.rb', line 252
-
-def execute(*args, &task)
-  raise NotImplementedError
-end
-
-
- -
-

- - - (Object) init_executor (protected) - - - - - -

-
-

Initialize the executor by creating and initializing all the -internal synchronization objects.

- - -
-
-
- - -
- - - - -
-
-
-
-245
-246
-247
-248
-249
-
-
# File 'lib/concurrent/executor/executor.rb', line 245
-
-def init_executor
-  @mutex = Mutex.new
-  @stop_event = Event.new
-  @stopped_event = Event.new
-end
-
-
- -
-

- - - (Object) kill - - - - - -

-
-

Begin an immediate shutdown. In-progress tasks will be allowed to -complete but enqueued tasks will be dismissed and no new tasks -will be accepted. Has no additional effect if the thread pool is -not running.

- - -
-
-
- - -
- - - - -
-
-
-
-212
-213
-214
-215
-216
-217
-218
-219
-220
-
-
# File 'lib/concurrent/executor/executor.rb', line 212
-
-def kill
-  mutex.synchronize do
-    break if shutdown?
-    stop_event.set
-    kill_execution
-    stopped_event.set
-  end
-  true
-end
-
-
- -
-

- - - (Object) kill_execution (protected) - - - - - -

-
-

Callback method called when the executor has been killed. -The default behavior is to do nothing.

- - -
-
-
- - -
- - - - -
-
-
-
-268
-269
-270
-
-
# File 'lib/concurrent/executor/executor.rb', line 268
-
-def kill_execution
-  # do nothing
-end
-
-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Logging - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) post(*args) { ... } - - - - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to be passed to the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the asynchronous task to perform

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the task is queued, false if the executor -is not running

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no task is given

    -
    - -
  • - -
- -
- - - - -
-
-
-
-143
-144
-145
-146
-147
-148
-149
-150
-151
-
-
# File 'lib/concurrent/executor/executor.rb', line 143
-
-def post(*args, &task)
-  raise ArgumentError.new('no block given') unless block_given?
-  mutex.synchronize do
-    # If the executor is shut down, reject this task
-    return handle_fallback(*args, &task) unless running?
-    execute(*args, &task)
-    true
-  end
-end
-
-
- -
-

- - - (Boolean) running? - - - - - -

-
-

Is the executor running?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when running, false when shutting down or shutdown

    -
    - -
  • - -
- -
- - - - -
-
-
-
-170
-171
-172
-
-
# File 'lib/concurrent/executor/executor.rb', line 170
-
-def running?
-  ! stop_event.set?
-end
-
-
- -
-

- - - (Boolean) serialized? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) shutdown - - - - - -

-
-

Begin an orderly shutdown. Tasks already in the queue will be executed, -but no new tasks will be accepted. Has no additional effect if the -thread pool is not running.

- - -
-
-
- - -
- - - - -
-
-
-
-197
-198
-199
-200
-201
-202
-203
-204
-
-
# File 'lib/concurrent/executor/executor.rb', line 197
-
-def shutdown
-  mutex.synchronize do
-    break unless running?
-    stop_event.set
-    shutdown_execution
-  end
-  true
-end
-
-
- -
-

- - - (Boolean) shutdown? - - - - - -

-
-

Is the executor shutdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when shutdown, false when shutting down or running

    -
    - -
  • - -
- -
- - - - -
-
-
-
-188
-189
-190
-
-
# File 'lib/concurrent/executor/executor.rb', line 188
-
-def shutdown?
-  stopped_event.set?
-end
-
-
- -
-

- - - (Object) shutdown_execution (protected) - - - - - -

-
-

Callback method called when an orderly shutdown has completed. -The default behavior is to signal all waiting threads.

- - -
-
-
- - -
- - - - -
-
-
-
-260
-261
-262
-
-
# File 'lib/concurrent/executor/executor.rb', line 260
-
-def shutdown_execution
-  stopped_event.set
-end
-
-
- -
-

- - - (Boolean) shuttingdown? - - - - - -

-
-

Is the executor shuttingdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when not running and not shutdown, else false

    -
    - -
  • - -
- -
- - - - -
-
-
-
-179
-180
-181
-
-
# File 'lib/concurrent/executor/executor.rb', line 179
-
-def shuttingdown?
-  ! (running? || shutdown?)
-end
-
-
- -
-

- - - (Boolean) wait_for_termination(timeout = nil) - - - - - -

-
- -
- Note: -

Does not initiate shutdown or termination. Either shutdown or kill -must be called before this method (or on another thread).

-
-
- -

Block until executor shutdown is complete or until timeout seconds have -passed.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Integer) - - - (defaults to: nil) - - - — -

    the maximum number of seconds to wait for shutdown to complete

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if shutdown complete or false on timeout

    -
    - -
  • - -
- -
- - - - -
-
-
-
-233
-234
-235
-
-
# File 'lib/concurrent/executor/executor.rb', line 233
-
-def wait_for_termination(timeout = nil)
-  stopped_event.wait(timeout)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubyFixedThreadPool.html b/docs/1.0.5/Concurrent/RubyFixedThreadPool.html deleted file mode 100644 index 7b6709d67..000000000 --- a/docs/1.0.5/Concurrent/RubyFixedThreadPool.html +++ /dev/null @@ -1,1144 +0,0 @@ - - - - - - Class: Concurrent::RubyFixedThreadPool - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::RubyFixedThreadPool - - - -

- -
- -
Inherits:
-
- RubyThreadPoolExecutor - - - show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/ruby_fixed_thread_pool.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

A thread pool with a set number of threads. The number of threads in the pool -is set on construction and remains constant. When all threads are busy new -tasks #post to the thread pool are enqueued until a thread becomes available. -Should a thread crash for any reason the thread will immediately be removed -from the pool and replaced.

- -

The API and behavior of this class are based on Java's FixedThreadPool

- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
-
-

Direct Known Subclasses

-

FixedThreadPool

-
- -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

- - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (RubyFixedThreadPool) initialize(num_threads, opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - num_threads - - - (Integer) - - - - — -

    the number of threads to allocate

    -
    - -
  • - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options defining pool behavior.

    -
    - -
  • - -
- - - - - - -

Options Hash (opts):

-
    - -
  • - :fallback_policy - (Symbol) - - - — default: - `:abort` - - - - —

    the fallback policy

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if num_threads is less than or equal to zero

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if fallback_policy is not a known policy

    -
    - -
  • - -
- -
- - - - -
-
-
-
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-
-
# File 'lib/concurrent/executor/ruby_fixed_thread_pool.rb', line 17
-
-def initialize(num_threads, opts = {})
-  fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
-
-  raise ArgumentError.new('number of threads must be greater than zero') if num_threads < 1
-  raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(fallback_policy)
-
-  opts = {
-    min_threads: num_threads,
-    max_threads: num_threads,
-    fallback_policy: fallback_policy,
-    max_queue: DEFAULT_MAX_QUEUE_SIZE,
-    idletime: DEFAULT_THREAD_IDLETIMEOUT,
-  }.merge(opts)
-  super(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) completed_task_count (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of tasks that have been completed by the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) idletime (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of seconds that a thread may be idle before being reclaimed.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) largest_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The largest number of threads that have been created in the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) max_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The maximum number of threads that may be created in the pool.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) max_queue (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The maximum number of tasks that may be waiting in the work queue at any one time. -When the queue size reaches max_queue subsequent tasks will be rejected in -accordance with the configured fallback_policy.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) min_length (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The minimum number of threads that may be retained in the pool.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) mutex (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute mutex

- - -
-
-
- - -
-
- - - -
-

- - - (Object) scheduled_task_count (readonly) - - - - - - - Originally defined in class - RubyThreadPoolExecutor - - -

-
-

The number of tasks that have been scheduled for execution on the pool since construction.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stop_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stop_event

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stopped_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stopped_event

- - -
-
-
- - -
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubySingleThreadExecutor.html b/docs/1.0.5/Concurrent/RubySingleThreadExecutor.html deleted file mode 100644 index 54477c5ad..000000000 --- a/docs/1.0.5/Concurrent/RubySingleThreadExecutor.html +++ /dev/null @@ -1,1868 +0,0 @@ - - - - - - Class: Concurrent::RubySingleThreadExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::RubySingleThreadExecutor - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
RubyExecutor, SerialExecutor
- - - - - -
Defined in:
-
lib/concurrent/executor/ruby_single_thread_executor.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

A thread pool with a set number of threads. The number of threads in the pool -is set on construction and remains constant. When all threads are busy new -tasks #post to the thread pool are enqueued until a thread becomes available. -Should a thread crash for any reason the thread will immediately be removed -from the pool and replaced.

- -

The API and behavior of this class are based on Java's SingleThreadExecutor

- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
-
-

Direct Known Subclasses

-

SingleThreadExecutor

-
- -

Constant Summary

- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
  • - - - - (Object) mutex - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute mutex.

    -
    - -
  • - - -
  • - - - - (Object) stop_event - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stop_event.

    -
    - -
  • - - -
  • - - - - (Object) stopped_event - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stopped_event.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (RubySingleThreadExecutor) initialize(opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    a customizable set of options

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :fallback_policy - (Symbol) - - - — default: - :discard - - - - —

    the policy for -handling new tasks that are received when the queue size has -reached max_queue or after the executor has shut down

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-20
-21
-22
-23
-24
-25
-26
-27
-
-
# File 'lib/concurrent/executor/ruby_single_thread_executor.rb', line 20
-
-def initialize(opts = {})
-  @queue = Queue.new
-  @thread = nil
-  @fallback_policy = opts.fetch(:fallback_policy, :discard)
-  raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(@fallback_policy)
-  init_executor
-  enable_at_exit_handler!(opts)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) mutex (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute mutex

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stop_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stop_event

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stopped_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stopped_event

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (self) <<(task) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - task - - - (Proc) - - - - — -

    the asynchronous task to perform

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (self) - - - - — -

    returns itself

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) init_executor (protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Initialize the executor by creating and initializing all the -internal synchronization objects.

- - -
-
-
- - -
-
- -
-

- - - (Object) kill - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Begin an immediate shutdown. In-progress tasks will be allowed to -complete but enqueued tasks will be dismissed and no new tasks -will be accepted. Has no additional effect if the thread pool is -not running.

- - -
-
-
- - -
-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Logging - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) post(*args) { ... } - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to be passed to the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the asynchronous task to perform

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the task is queued, false if the executor -is not running

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no task is given

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) running? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor running?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when running, false when shutting down or shutdown

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) serialized? - - - - - - - Originally defined in module - SerialExecutor - - -

-
- -
- Note: -

Always returns true

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) shutdown - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Begin an orderly shutdown. Tasks already in the queue will be executed, -but no new tasks will be accepted. Has no additional effect if the -thread pool is not running.

- - -
-
-
- - -
-
- -
-

- - - (Boolean) shutdown? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor shutdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when shutdown, false when shutting down or running

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) shuttingdown? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor shuttingdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when not running and not shutdown, else false

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) wait_for_termination(timeout = nil) - - - - - - - Originally defined in module - RubyExecutor - - -

-
- -
- Note: -

Does not initiate shutdown or termination. Either shutdown or kill -must be called before this method (or on another thread).

-
-
- -

Block until executor shutdown is complete or until timeout seconds have -passed.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Integer) - - - (defaults to: nil) - - - — -

    the maximum number of seconds to wait for shutdown to complete

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if shutdown complete or false on timeout

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubyThreadPoolExecutor.html b/docs/1.0.5/Concurrent/RubyThreadPoolExecutor.html deleted file mode 100644 index 217253253..000000000 --- a/docs/1.0.5/Concurrent/RubyThreadPoolExecutor.html +++ /dev/null @@ -1,2880 +0,0 @@ - - - - - - Class: Concurrent::RubyThreadPoolExecutor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::RubyThreadPoolExecutor - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
RubyExecutor
- - - - - -
Defined in:
-
lib/concurrent/executor/ruby_thread_pool_executor.rb
- -
-
- -

Overview

-
- -
- Note: -

Failure to properly shutdown a thread pool can lead to unpredictable results. -Please read Shutting Down Thread Pools for more information.

-
-
- -
- Note: -

When running on the JVM (JRuby) this class will inherit from JavaThreadPoolExecutor. -On all other platforms it will inherit from RubyThreadPoolExecutor.

-
-
- -

An abstraction composed of one or more threads and a task queue. Tasks -(blocks or proc objects) are submit to the pool and added to the queue. -The threads in the pool remove the tasks and execute them in the order -they were received. When there are more tasks queued than there are -threads to execute them the pool will create new threads, up to the -configured maximum. Similarly, threads that are idle for too long will -be garbage collected, down to the configured minimum options. Should a -thread crash it, too, will be garbage collected.

- -

ThreadPoolExecutor is based on the Java class of the same name. From -the official Java documentationa;

- -
-

Thread pools address two different problems: they usually provide -improved performance when executing large numbers of asynchronous tasks, -due to reduced per-task invocation overhead, and they provide a means -of bounding and managing the resources, including threads, consumed -when executing a collection of tasks. Each ThreadPoolExecutor also -maintains some basic statistics, such as the number of completed tasks.

- -

To be useful across a wide range of contexts, this class provides many -adjustable parameters and extensibility hooks. However, programmers are -urged to use the more convenient Executors factory methods -CachedThreadPool, -FixedThreadPool and SingleThreadExecutor, that preconfigure settings for the most common usage -scenarios.

-
- -

Thread pools support several configuration options:

- -
    -
  • idletime: The number of seconds that a thread may be idle before being reclaimed.
  • -
  • max_queue: The maximum number of tasks that may be waiting in the work queue at -any one time. When the queue size reaches max_queue subsequent tasks will be -rejected in accordance with the configured fallback_policy.
  • -
  • stop_on_exit: When true (default) an at_exit handler will be registered which -will stop the thread pool when the application exits. See below for more information -on shutting down thread pools.
  • -
  • fallback_policy: The policy defining how rejected tasks are handled.
  • -
- -

Three fallback policies are supported:

- -
    -
  • :abort: Raise a RejectedExecutionError exception and discard the task.
  • -
  • :discard: Discard the task and return false.
  • -
  • :caller_runs: Execute the task on the calling thread.
  • -
- -

Shutting Down Thread Pools

- -

Killing a thread pool while tasks are still being processed, either by calling -the #kill method or at application exit, will have unpredictable results. There -is no way for the thread pool to know what resources are being used by the -in-progress tasks. When those tasks are killed the impact on those resources -cannot be predicted. The best practice is to explicitly shutdown all thread -pools using the provided methods:

- -
    -
  • Call #shutdown to initiate an orderly termination of all in-progress tasks
  • -
  • Call #wait_for_termination with an appropriate timeout interval an allow -the orderly shutdown to complete
  • -
  • Call #kill only when the thread pool fails to shutdown in the allotted time
  • -
- -

On some runtime platforms (most notably the JVM) the application will not -exit until all thread pools have been shutdown. To prevent applications from -"hanging" on exit all thread pools include an at_exit handler that will -stop the thread pool when the application exists. This handler uses a brute -force method to stop the pool and makes no guarantees regarding resources being -used by any tasks still running. Registration of this at_exit handler can be -prevented by setting the thread pool's constructor :stop_on_exit option to -false when the thread pool is created. All thread pools support this option.

- -
pool1 = Concurrent::FixedThreadPool.new(5) # an `at_exit` handler will be registered
-pool2 = Concurrent::FixedThreadPool.new(5, stop_on_exit: false) # prevent `at_exit` handler registration
-
- - -
-
- - -

Constant Summary

- -
- -
DEFAULT_MAX_POOL_SIZE = -
-
-

Default maximum number of threads that will be created in the pool.

- - -
-
-
- - -
-
-
2**15
- -
DEFAULT_MIN_POOL_SIZE = -
-
-

Default minimum number of threads that will be retained in the pool.

- - -
-
-
- - -
-
-
0
- -
DEFAULT_MAX_QUEUE_SIZE = -
-
-

Default maximum number of tasks that may be added to the task queue.

- - -
-
-
- - -
-
-
0
- -
DEFAULT_THREAD_IDLETIMEOUT = -
-
-

Default maximum number of seconds a thread in the pool may remain idle -before being reclaimed.

- - -
-
-
- - -
-
-
60
- -
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) completed_task_count - - - - - - - - - readonly - - - - - - - - - -

    The number of tasks that have been completed by the pool since construction.

    -
    - -
  • - - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
  • - - - - (Object) idletime - - - - - - - - - readonly - - - - - - - - - -

    The number of seconds that a thread may be idle before being reclaimed.

    -
    - -
  • - - -
  • - - - - (Object) largest_length - - - - - - - - - readonly - - - - - - - - - -

    The largest number of threads that have been created in the pool since construction.

    -
    - -
  • - - -
  • - - - - (Object) max_length - - - - - - - - - readonly - - - - - - - - - -

    The maximum number of threads that may be created in the pool.

    -
    - -
  • - - -
  • - - - - (Object) max_queue - - - - - - - - - readonly - - - - - - - - - -

    The maximum number of tasks that may be waiting in the work queue at any one time.

    -
    - -
  • - - -
  • - - - - (Object) min_length - - - - - - - - - readonly - - - - - - - - - -

    The minimum number of threads that may be retained in the pool.

    -
    - -
  • - - -
  • - - - - (Object) mutex - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute mutex.

    -
    - -
  • - - -
  • - - - - (Object) scheduled_task_count - - - - - - - - - readonly - - - - - - - - - -

    The number of tasks that have been scheduled for execution on the pool since construction.

    -
    - -
  • - - -
  • - - - - (Object) stop_event - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stop_event.

    -
    - -
  • - - -
  • - - - - (Object) stopped_event - - - - - - - included - from RubyExecutor - - - - - - readonly - - - - protected - - - - - -

    Returns the value of attribute stopped_event.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - - - - -
-

Constructor Details

- -
-

- - - (RubyThreadPoolExecutor) initialize(opts = {}) - - - - - -

-
-

Create a new thread pool.

- - -
-
-
-

Parameters:

-
    - -
  • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

    the options which configure the thread pool

    -
    - -
  • - -
- - - - -

Options Hash (opts):

-
    - -
  • - :max_threads - (Integer) - - - — default: - DEFAULT_MAX_POOL_SIZE - - - - —

    the maximum -number of threads to be created

    -
    - -
  • - -
  • - :min_threads - (Integer) - - - — default: - DEFAULT_MIN_POOL_SIZE - - - - —

    the minimum -number of threads to be retained

    -
    - -
  • - -
  • - :idletime - (Integer) - - - — default: - DEFAULT_THREAD_IDLETIMEOUT - - - - —

    the maximum -number of seconds a thread may be idle before being reclaimed

    -
    - -
  • - -
  • - :max_queue - (Integer) - - - — default: - DEFAULT_MAX_QUEUE_SIZE - - - - —

    the maximum -number of tasks allowed in the work queue at any one time; a value of -zero means the queue may grow without bound

    -
    - -
  • - -
  • - :fallback_policy - (Symbol) - - - — default: - :abort - - - - —

    the policy for handling new -tasks that are received when the queue size has reached -max_queue or the executor has shut down

    -
    - -
  • - -
- - -

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if :max_threads is less than one

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if :min_threads is less than zero

    -
    - -
  • - -
  • - - - (ArgumentError) - - - - — -

    if :fallback_policy is not one of the values specified -in FALLBACK_POLICIES

    -
    - -
  • - -
- -

See Also:

- - -
- - - - -
-
-
-
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 74
-
-def initialize(opts = {})
-  @min_length      = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i
-  @max_length      = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
-  @idletime        = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
-  @max_queue       = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
-  @fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
-  warn '[DEPRECATED] :overflow_policy is deprecated terminology, please use :fallback_policy instead' if opts.has_key?(:overflow_policy)
-
-  raise ArgumentError.new('max_threads must be greater than zero') if @max_length <= 0
-  raise ArgumentError.new('min_threads cannot be less than zero') if @min_length < 0
-  raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(@fallback_policy)
-  raise ArgumentError.new('min_threads cannot be more than max_threads') if min_length > max_length
-
-  init_executor
-  enable_at_exit_handler!(opts)
-
-  @pool                 = []
-  @queue                = Queue.new
-  @scheduled_task_count = 0
-  @completed_task_count = 0
-  @largest_length       = 0
-
-  @gc_interval  = opts.fetch(:gc_interval, 1).to_i # undocumented
-  @last_gc_time = Concurrent.monotonic_time - [1.0, (@gc_interval * 2.0)].max
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) completed_task_count (readonly) - - - - - -

-
-

The number of tasks that have been completed by the pool since construction.

- - -
-
-
- - -
- - - - -
-
-
-
-41
-42
-43
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 41
-
-def completed_task_count
-  @completed_task_count
-end
-
-
- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- - - -
-

- - - (Object) idletime (readonly) - - - - - -

-
-

The number of seconds that a thread may be idle before being reclaimed.

- - -
-
-
- - -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 44
-
-def idletime
-  @idletime
-end
-
-
- - - -
-

- - - (Object) largest_length (readonly) - - - - - -

-
-

The largest number of threads that have been created in the pool since construction.

- - -
-
-
- - -
- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 35
-
-def largest_length
-  @largest_length
-end
-
-
- - - -
-

- - - (Object) max_length (readonly) - - - - - -

-
-

The maximum number of threads that may be created in the pool.

- - -
-
-
- - -
- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 29
-
-def max_length
-  @max_length
-end
-
-
- - - -
-

- - - (Object) max_queue (readonly) - - - - - -

-
-

The maximum number of tasks that may be waiting in the work queue at any one time. -When the queue size reaches max_queue subsequent tasks will be rejected in -accordance with the configured fallback_policy.

- - -
-
-
- - -
- - - - -
-
-
-
-49
-50
-51
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 49
-
-def max_queue
-  @max_queue
-end
-
-
- - - -
-

- - - (Object) min_length (readonly) - - - - - -

-
-

The minimum number of threads that may be retained in the pool.

- - -
-
-
- - -
- - - - -
-
-
-
-32
-33
-34
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 32
-
-def min_length
-  @min_length
-end
-
-
- - - -
-

- - - (Object) mutex (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute mutex

- - -
-
-
- - -
-
- - - -
-

- - - (Object) scheduled_task_count (readonly) - - - - - -

-
-

The number of tasks that have been scheduled for execution on the pool since construction.

- - -
-
-
- - -
- - - - -
-
-
-
-38
-39
-40
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 38
-
-def scheduled_task_count
-  @scheduled_task_count
-end
-
-
- - - -
-

- - - (Object) stop_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stop_event

- - -
-
-
- - -
-
- - - -
-

- - - (Object) stopped_event (readonly, protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Returns the value of attribute stopped_event

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (self) <<(task) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - task - - - (Proc) - - - - — -

    the asynchronous task to perform

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (self) - - - - — -

    returns itself

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - -

-
-

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-101
-102
-103
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 101
-
-def can_overflow?
-  @max_queue != 0
-end
-
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) init_executor (protected) - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Initialize the executor by creating and initializing all the -internal synchronization objects.

- - -
-
-
- - -
-
- -
-

- - - (Object) kill - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Begin an immediate shutdown. In-progress tasks will be allowed to -complete but enqueued tasks will be dismissed and no new tasks -will be accepted. Has no additional effect if the thread pool is -not running.

- - -
-
-
- - -
-
- -
-

- - - (Integer) length - - - - Also known as: - current_length - - - - -

-
-

The number of threads currently in the pool.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the length

    -
    - -
  • - -
- -
- - - - -
-
-
-
-108
-109
-110
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 108
-
-def length
-  mutex.synchronize { running? ? @pool.length : 0 }
-end
-
-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Logging - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) post(*args) { ... } - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Submit a task to the executor for asynchronous processing.

- - -
-
-
-

Parameters:

-
    - -
  • - - args - - - (Array) - - - - — -

    zero or more arguments to be passed to the task

    -
    - -
  • - -
- -

Yields:

-
    - -
  • - - - - - - - -

    the asynchronous task to perform

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if the task is queued, false if the executor -is not running

    -
    - -
  • - -
-

Raises:

-
    - -
  • - - - (ArgumentError) - - - - — -

    if no task is given

    -
    - -
  • - -
- -
-
- -
-

- - - (Integer) queue_length - - - - - -

-
-

The number of tasks in the queue awaiting execution.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the queue_length

    -
    - -
  • - -
- -
- - - - -
-
-
-
-117
-118
-119
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 117
-
-def queue_length
-  mutex.synchronize { running? ? @queue.length : 0 }
-end
-
-
- -
-

- - - (Integer) remaining_capacity - - - - - -

-
-

Number of tasks that may be enqueued before reaching max_queue and rejecting -new tasks. A value of -1 indicates that the queue may grow without bound.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - - — -

    the remaining_capacity

    -
    - -
  • - -
- -
- - - - -
-
-
-
-125
-126
-127
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 125
-
-def remaining_capacity
-  mutex.synchronize { @max_queue == 0 ? -1 : @max_queue - @queue.length }
-end
-
-
- -
-

- - - (Boolean) running? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor running?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when running, false when shutting down or shutdown

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) serialized? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) shutdown - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Begin an orderly shutdown. Tasks already in the queue will be executed, -but no new tasks will be accepted. Has no additional effect if the -thread pool is not running.

- - -
-
-
- - -
-
- -
-

- - - (Boolean) shutdown? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor shutdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when shutdown, false when shutting down or running

    -
    - -
  • - -
- -
-
- -
-

- - - (Boolean) shuttingdown? - - - - - - - Originally defined in module - RubyExecutor - - -

-
-

Is the executor shuttingdown?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true when not running and not shutdown, else false

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) status - - - - - -

-
-

Returns an array with the status of each thread in the pool

- -

This method is deprecated and will be removed soon.

- - -
-
-
- - -
- - - - -
-
-
-
-132
-133
-134
-135
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_executor.rb', line 132
-
-def status
-  warn '[DEPRECATED] `status` is deprecated and will be removed soon.'
-  mutex.synchronize { @pool.collect { |worker| worker.status } }
-end
-
-
- -
-

- - - (Boolean) wait_for_termination(timeout = nil) - - - - - - - Originally defined in module - RubyExecutor - - -

-
- -
- Note: -

Does not initiate shutdown or termination. Either shutdown or kill -must be called before this method (or on another thread).

-
-
- -

Block until executor shutdown is complete or until timeout seconds have -passed.

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Integer) - - - (defaults to: nil) - - - — -

    the maximum number of seconds to wait for shutdown to complete

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    true if shutdown complete or false on timeout

    -
    - -
  • - -
- -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/RubyThreadPoolWorker.html b/docs/1.0.5/Concurrent/RubyThreadPoolWorker.html deleted file mode 100644 index d98a0e06d..000000000 --- a/docs/1.0.5/Concurrent/RubyThreadPoolWorker.html +++ /dev/null @@ -1,694 +0,0 @@ - - - - - - Class: Concurrent::RubyThreadPoolWorker - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::RubyThreadPoolWorker - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
Logging
- - - - - -
Defined in:
-
lib/concurrent/executor/ruby_thread_pool_worker.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Constructor Details

- -
-

- - - (RubyThreadPoolWorker) initialize(queue, parent) (private) - - - - - -

-
-

Returns a new instance of RubyThreadPoolWorker

- - -
-
-
- - -
- - - - -
-
-
-
-11
-12
-13
-14
-15
-16
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 11
-
-def initialize(queue, parent)
-  @queue = queue
-  @parent = parent
-  @mutex = Mutex.new
-  @last_activity = Time.now.to_f
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) dead? (private) - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-22
-23
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 19
-
-def dead?
-  return @mutex.synchronize do
-    @thread.nil? ? false : ! @thread.alive?
-  end
-end
-
-
- -
-

- - - (Object) kill (private) - - - - - -

- - - - -
-
-
-
-38
-39
-40
-41
-42
-43
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 38
-
-def kill
-  @mutex.synchronize do
-    Thread.kill(@thread) unless @thread.nil?
-    @thread = nil
-  end
-end
-
-
- -
-

- - - (Object) last_activity (private) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 26
-
-def last_activity
-  @mutex.synchronize { @last_activity }
-end
-
-
- -
-

- - - (Object) log(level, progname, message = nil, &block) - - - - - - - Originally defined in module - Logging - - -

-
-

Logs through Configuration#logger, it can be overridden by setting @logger

- - -
-
-
-

Parameters:

-
    - -
  • - - level - - - (Integer) - - - - — -

    one of Logger::Severity constants

    -
    - -
  • - -
  • - - progname - - - (String) - - - - — -

    e.g. a path of an Actor

    -
    - -
  • - -
  • - - message - - - (String, nil) - - - (defaults to: nil) - - - — -

    when nil block is used to generate the message

    -
    - -
  • - -
- -

Yield Returns:

-
    - -
  • - - - (String) - - - - — -

    a message

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) run(thread = Thread.current) (private) - - - - - -

- - - - -
-
-
-
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 46
-
-def run(thread = Thread.current)
-  @mutex.synchronize do
-    raise StandardError.new('already running') unless @thread.nil?
-    @thread = thread
-  end
-
-  loop do
-    task = @queue.pop
-    if task == :stop
-      @thread = nil
-      @parent.on_worker_exit(self)
-      break
-    end
-
-    begin
-      task.last.call(*task.first)
-    rescue => ex
-      # let it fail
-      log DEBUG, ex
-    ensure
-      @mutex.synchronize { @last_activity = Time.now.to_f }
-      @parent.on_end_task
-    end
-  end
-end
-
-
- -
-

- - - (Object) status - - - - - -

- - - - -
-
-
-
-30
-31
-32
-33
-34
-35
-
-
# File 'lib/concurrent/executor/ruby_thread_pool_worker.rb', line 30
-
-def status
-  @mutex.synchronize do
-    return 'not running' if @thread.nil?
-    @thread.status
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Runnable.html b/docs/1.0.5/Concurrent/Runnable.html deleted file mode 100644 index 388bce94d..000000000 --- a/docs/1.0.5/Concurrent/Runnable.html +++ /dev/null @@ -1,518 +0,0 @@ - - - - - - Module: Concurrent::Runnable - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::Runnable - - - -

- -
- - - - - - - -
Included in:
-
Actor
- - - -
Defined in:
-
lib/concurrent/runnable.rb
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: Context - - -

- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) mutex (protected) - - - - - -

- - - - -
-
-
-
-86
-87
-88
-
-
# File 'lib/concurrent/runnable.rb', line 86
-
-def mutex
-  @mutex ||= Mutex.new
-end
-
-
- -
-

- - - (Object) run - - - - - -

- - - - -
-
-
-
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-
-
# File 'lib/concurrent/runnable.rb', line 44
-
-def run
-  mutex.synchronize do
-    raise LifecycleError.new('already running') if @running
-    raise LifecycleError.new('#on_task not implemented') unless self.respond_to?(:on_task, true)
-    on_run if respond_to?(:on_run, true)
-    @running = true
-  end
-
-  loop do
-    break unless @running
-    on_task
-    break unless @running
-    Thread.pass
-  end
-
-  after_run if respond_to?(:after_run, true)
-  return true
-rescue LifecycleError => ex
-  @running = false
-  raise ex
-rescue => ex
-  @running = false
-  return false
-end
-
-
- -
-

- - - (Object) run!(abort_on_exception = false) - - - - - -

-
- - -
-
-
- -

Raises:

- - -
- - - - -
-
-
-
-34
-35
-36
-37
-38
-39
-40
-41
-42
-
-
# File 'lib/concurrent/runnable.rb', line 34
-
-def run!(abort_on_exception = false)
-  raise LifecycleError.new('already running') if @running
-  thread = Thread.new do
-    Thread.current.abort_on_exception = abort_on_exception
-    self.run
-  end
-  thread.join(0.1) # let the thread start
-  return thread
-end
-
-
- -
-

- - - (Boolean) running? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-80
-81
-82
-
-
# File 'lib/concurrent/runnable.rb', line 80
-
-def running?
-  return @running == true
-end
-
-
- -
-

- - - (Object) stop - - - - - -

- - - - -
-
-
-
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-
-
# File 'lib/concurrent/runnable.rb', line 69
-
-def stop
-  return true unless @running
-  mutex.synchronize do
-    @running = false
-    on_stop if respond_to?(:on_stop, true)
-  end
-  return true
-rescue => ex
-  return false
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Runnable/Context.html b/docs/1.0.5/Concurrent/Runnable/Context.html deleted file mode 100644 index bc0a5bc33..000000000 --- a/docs/1.0.5/Concurrent/Runnable/Context.html +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - Class: Concurrent::Runnable::Context - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Runnable::Context - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/runnable.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) runner - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute runner.

    -
    - -
  • - - -
  • - - - - (Object) thread - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute thread.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (Context) initialize(runner) - - - - - -

-
-

Returns a new instance of Context

- - -
-
-
- - -
- - - - -
-
-
-
-11
-12
-13
-14
-15
-16
-17
-18
-
-
# File 'lib/concurrent/runnable.rb', line 11
-
-def initialize(runner)
-  @runner = runner
-  @thread = Thread.new(runner) do |runner|
-    Thread.abort_on_exception = false
-    runner.run
-  end
-  @thread.join(0.1) # let the thread start
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) runner (readonly) - - - - - -

-
-

Returns the value of attribute runner

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/runnable.rb', line 10
-
-def runner
-  @runner
-end
-
-
- - - -
-

- - - (Object) thread (readonly) - - - - - -

-
-

Returns the value of attribute thread

- - -
-
-
- - -
- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/runnable.rb', line 10
-
-def thread
-  @thread
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/SafeTaskExecutor.html b/docs/1.0.5/Concurrent/SafeTaskExecutor.html index 91624ba19..419104705 100644 --- a/docs/1.0.5/Concurrent/SafeTaskExecutor.html +++ b/docs/1.0.5/Concurrent/SafeTaskExecutor.html @@ -318,9 +318,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::SerialExecutor - - - -

- -
- - - - - -
Includes:
-
Executor
- - - - -
Included in:
-
ImmediateExecutor, JavaSingleThreadExecutor, RubySingleThreadExecutor, SerializedExecutionDelegator
- - - -
Defined in:
-
lib/concurrent/executor/executor.rb
- -
-
- -

Overview

-
-

Indicates that the including Executor or ExecutorService guarantees -that all operations will occur in the order they are post and that no -two operations may occur simultaneously. This module provides no -functionality and provides no guarantees. That is the responsibility -of the including class. This module exists solely to allow the including -object to be interrogated for its serialization status.

- - -
-
-
- -
-

Examples:

- - -
class Foo
-  include Concurrent::SerialExecutor
-end
-
-foo = Foo.new
-
-foo.is_a? Concurrent::Executor       #=> true
-foo.is_a? Concurrent::SerialExecutor #=> true
-foo.serialized?                      #=> true
- -
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) fallback_policy - - - - - - - included - from Executor - - - - - - readonly - - - - - - - - - -

    The policy defining how rejected tasks (tasks received once the queue size reaches the configured max_queue, or after the executor has shut down) are handled.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) fallback_policy (readonly) - - - - - - - Originally defined in module - Executor - - -

-
-

The policy defining how rejected tasks (tasks received once the -queue size reaches the configured max_queue, or after the -executor has shut down) are handled. Must be one of the values -specified in FALLBACK_POLICIES.

- - -
-
-
- - -
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Boolean) auto_terminate? - - - - - - - Originally defined in module - Executor - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
-
- -
-

- - - (Boolean) can_overflow? - - - - - - - Originally defined in module - Executor - - -

-
- -
- Note: -

Always returns false

-
-
- -

Does the task queue have a maximum size?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the task queue has a maximum size else false.

    -
    - -
  • - -
- -
-
- -
-

- - - (Object) create_at_exit_handler!(this) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) create_mri_at_exit_handler!(id) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Object) enable_at_exit_handler!(opts = {}) (protected) - - - - - - - Originally defined in module - Executor - - -

-
- -
-

- - - (Boolean) serialized? - - - - - -

-
- -
- Note: -

Always returns true

-
-
- -

Does this executor guarantee serialization of its operations?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -

    True if the executor guarantees that all operations -will be post in the order they are received and no two operations may -occur simultaneously. Else false.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-119
-120
-121
-
-
# File 'lib/concurrent/executor/executor.rb', line 119
-
-def serialized?
-  true
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/SerializedExecution.html b/docs/1.0.5/Concurrent/SerializedExecution.html index 95b087447..a6080c1cf 100644 --- a/docs/1.0.5/Concurrent/SerializedExecution.html +++ b/docs/1.0.5/Concurrent/SerializedExecution.html @@ -624,9 +624,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Stoppable - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/stoppable.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) before_stop(&block) - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-7
-8
-9
-10
-11
-12
-
-
# File 'lib/concurrent/stoppable.rb', line 7
-
-def before_stop(&block)
-  raise ArgumentError.new('no block given') unless block_given?
-  raise Runnable::LifecycleError.new('#before_stop already set') if @before_stop_proc
-  @before_stop_proc = block
-  self
-end
-
-
- -
-

- - - (Object) before_stop_proc (protected) - - - - - -

- - - - -
-
-
-
-16
-17
-18
-
-
# File 'lib/concurrent/stoppable.rb', line 16
-
-def before_stop_proc
-  @before_stop_proc
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Supervisor.html b/docs/1.0.5/Concurrent/Supervisor.html deleted file mode 100644 index 4278fc0de..000000000 --- a/docs/1.0.5/Concurrent/Supervisor.html +++ /dev/null @@ -1,1531 +0,0 @@ - - - - - - Class: Concurrent::Supervisor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Supervisor - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/supervisor.rb
- -
-
- -

Defined Under Namespace

-

- - - - - Classes: WorkerContext, WorkerCounts - - -

- -

Constant Summary

- -
- -
DEFAULT_MONITOR_INTERVAL = - -
-
1
- -
RESTART_STRATEGIES = - -
-
[:one_for_one, :one_for_all, :rest_for_one]
- -
DEFAULT_MAX_RESTART = - -
-
5
- -
DEFAULT_MAX_TIME = - -
-
60
- -
WORKER_API = - -
-
{run: 0, stop: 0, running?: 0}
- -
CHILD_TYPES = - -
-
[:worker, :supervisor]
- -
CHILD_RESTART_OPTIONS = - -
-
[:permanent, :transient, :temporary]
- -
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) max_restart - - - - (also: #max_r) - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute max_restart.

    -
    - -
  • - - -
  • - - - - (Object) max_time - - - - (also: #max_t) - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute max_time.

    -
    - -
  • - - -
  • - - - - (Object) monitor_interval - - - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute monitor_interval.

    -
    - -
  • - - -
  • - - - - (Object) restart_strategy - - - - (also: #strategy) - - - - - - - readonly - - - - - - - - - -

    Returns the value of attribute restart_strategy.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (Supervisor) initialize(opts = {}) - - - - - -

-
-

Returns a new instance of Supervisor

- - -
-
-
- -

Raises:

-
    - -
  • - - - (ArgumentError) - - - -
  • - -
- -
- - - - -
-
-
-
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-
-
# File 'lib/concurrent/supervisor.rb', line 63
-
-def initialize(opts = {})
-  @restart_strategy = opts[:restart_strategy] || opts[:strategy] || :one_for_one
-  @monitor_interval = (opts[:monitor_interval] || DEFAULT_MONITOR_INTERVAL).to_f
-  @max_restart = (opts[:max_restart] || opts[:max_r] || DEFAULT_MAX_RESTART).to_i
-  @max_time = (opts[:max_time] || opts[:max_t] || DEFAULT_MAX_TIME).to_i
-
-  raise ArgumentError.new(":#{@restart_strategy} is not a valid restart strategy") unless RESTART_STRATEGIES.include?(@restart_strategy)
-  raise ArgumentError.new(':monitor_interval must be greater than zero') unless @monitor_interval > 0.0
-  raise ArgumentError.new(':max_restart must be greater than zero') unless @max_restart > 0
-  raise ArgumentError.new(':max_time must be greater than zero') unless @max_time > 0
-
-  @running = false
-  @mutex = Mutex.new
-  @workers = []
-  @monitor = nil
-
-  @count = WorkerCounts.new(0, 0, 0)
-  @restart_times = []
-
-  add_worker(opts[:worker]) unless opts[:worker].nil?
-  add_workers(opts[:workers]) unless opts[:workers].nil?
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - - (Object) max_restart (readonly) - - - - Also known as: - max_r - - - - -

-
-

Returns the value of attribute max_restart

- - -
-
-
- - -
- - - - -
-
-
-
-56
-57
-58
-
-
# File 'lib/concurrent/supervisor.rb', line 56
-
-def max_restart
-  @max_restart
-end
-
-
- - - -
-

- - - (Object) max_time (readonly) - - - - Also known as: - max_t - - - - -

-
-

Returns the value of attribute max_time

- - -
-
-
- - -
- - - - -
-
-
-
-57
-58
-59
-
-
# File 'lib/concurrent/supervisor.rb', line 57
-
-def max_time
-  @max_time
-end
-
-
- - - -
-

- - - (Object) monitor_interval (readonly) - - - - - -

-
-

Returns the value of attribute monitor_interval

- - -
-
-
- - -
- - - - -
-
-
-
-54
-55
-56
-
-
# File 'lib/concurrent/supervisor.rb', line 54
-
-def monitor_interval
-  @monitor_interval
-end
-
-
- - - -
-

- - - (Object) restart_strategy (readonly) - - - - Also known as: - strategy - - - - -

-
-

Returns the value of attribute restart_strategy

- - -
-
-
- - -
- - - - -
-
-
-
-55
-56
-57
-
-
# File 'lib/concurrent/supervisor.rb', line 55
-
-def restart_strategy
-  @restart_strategy
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) add_worker(worker, opts = {}) - - - - Also known as: - add_child - - - - -

- - - - -
-
-
-
-151
-152
-153
-154
-155
-156
-157
-158
-159
-160
-161
-162
-163
-164
-
-
# File 'lib/concurrent/supervisor.rb', line 151
-
-def add_worker(worker, opts = {})
-  return nil if worker.nil? || ! behaves_as_worker?(worker)
-  @mutex.synchronize {
-    restart = opts[:restart] || :permanent
-    type = opts[:type] || (worker.is_a?(Supervisor) ? :supervisor : nil) || :worker
-    raise ArgumentError.new(":#{restart} is not a valid restart option") unless CHILD_RESTART_OPTIONS.include?(restart)
-    raise ArgumentError.new(":#{type} is not a valid child type") unless CHILD_TYPES.include?(type)
-    context = WorkerContext.new(worker, type, restart)
-    @workers << context
-    @count.add(context)
-    worker.run if @running
-    context.object_id
-  }
-end
-
-
- -
-

- - - (Object) add_workers(workers, opts = {}) - - - - Also known as: - add_children - - - - -

- - - - -
-
-
-
-167
-168
-169
-170
-171
-
-
# File 'lib/concurrent/supervisor.rb', line 167
-
-def add_workers(workers, opts = {})
-  workers.collect do |worker|
-    add_worker(worker, opts)
-  end
-end
-
-
- -
-

- - - (Object) count - - - - - -

- - - - -
-
-
-
-144
-145
-146
-147
-148
-149
-
-
# File 'lib/concurrent/supervisor.rb', line 144
-
-def count
-  @mutex.synchronize do
-    @count.status = @workers.collect{|w| w.thread ? w.thread.status : false }
-    @count.dup.freeze
-  end
-end
-
-
- -
-

- - - (Object) current_restart_count - - - - - -

- - - - -
-
-
-
-140
-141
-142
-
-
# File 'lib/concurrent/supervisor.rb', line 140
-
-def current_restart_count
-  @restart_times.length
-end
-
-
- -
-

- - - (Object) length - - - - Also known as: - size - - - - -

- - - - -
-
-
-
-135
-136
-137
-
-
# File 'lib/concurrent/supervisor.rb', line 135
-
-def length
-  @mutex.synchronize { @workers.length }
-end
-
-
- -
-

- - - (Object) remove_worker(worker_id) - - - - Also known as: - remove_child - - - - -

- - - - -
-
-
-
-174
-175
-176
-177
-178
-179
-180
-181
-182
-
-
# File 'lib/concurrent/supervisor.rb', line 174
-
-def remove_worker(worker_id)
-  @mutex.synchronize do
-    index, context = find_worker(worker_id)
-    break(nil) if context.nil?
-    break(false) if context.alive?
-    @workers.delete_at(index)
-    context.worker
-  end
-end
-
-
- -
-

- - - (Object) restart_worker(worker_id) - - - - Also known as: - restart_child - - - - -

- - - - -
-
-
-
-212
-213
-214
-215
-216
-217
-218
-219
-220
-221
-222
-223
-224
-
-
# File 'lib/concurrent/supervisor.rb', line 212
-
-def restart_worker(worker_id)
-  @mutex.synchronize do
-    return false unless @running
-
-    index, context = find_worker(worker_id)
-    break(nil) if context.nil?
-    break(false) if context.restart == :temporary
-    context.terminated = false
-    terminate_worker(context)
-    run_worker(context)
-    true
-  end
-end
-
-
- -
-

- - - (Object) run - - - - - -

- - - - -
-
-
-
-98
-99
-100
-101
-102
-103
-104
-105
-
-
# File 'lib/concurrent/supervisor.rb', line 98
-
-def run
-  @mutex.synchronize do
-    raise StandardError.new('already running') if @running
-    @running = true
-  end
-  monitor
-  true
-end
-
-
- -
-

- - - (Object) run! - - - - - -

- - - - -
-
-
-
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-
-
# File 'lib/concurrent/supervisor.rb', line 86
-
-def run!
-  @mutex.synchronize do
-    raise StandardError.new('already running') if @running
-    @running = true
-    @monitor = Thread.new do
-      Thread.current.abort_on_exception = false
-      monitor
-    end
-  end
-  Thread.pass
-end
-
-
- -
-

- - - (Boolean) running? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-131
-132
-133
-
-
# File 'lib/concurrent/supervisor.rb', line 131
-
-def running?
-  @mutex.synchronize { @running }
-end
-
-
- -
-

- - - (Object) start_worker(worker_id) - - - - Also known as: - start_child - - - - -

- - - - -
-
-
-
-199
-200
-201
-202
-203
-204
-205
-206
-207
-208
-209
-
-
# File 'lib/concurrent/supervisor.rb', line 199
-
-def start_worker(worker_id)
-  @mutex.synchronize do
-    return false unless @running
-
-    index, context = find_worker(worker_id)
-    break(nil) if context.nil?
-    context.terminated = false
-    run_worker(context) unless context.alive?
-    true
-  end
-end
-
-
- -
-

- - - (Object) stop - - - - - -

- - - - -
-
-
-
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-123
-124
-125
-126
-127
-128
-129
-
-
# File 'lib/concurrent/supervisor.rb', line 107
-
-def stop
-  @mutex.synchronize do
-    return true unless @running
-
-    @running = false
-    unless @monitor.nil?
-      @monitor.run if @monitor.status == 'sleep'
-      if @monitor.join(0.1).nil?
-        @monitor.kill
-      end
-      @monitor = nil
-    end
-    @restart_times.clear
-
-    @workers.length.times do |i|
-      context = @workers[-1-i]
-      terminate_worker(context)
-    end
-    prune_workers
-  end
-
-  true
-end
-
-
- -
-

- - - (Object) stop_worker(worker_id) - - - - Also known as: - stop_child - - - - -

- - - - -
-
-
-
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-
-
# File 'lib/concurrent/supervisor.rb', line 185
-
-def stop_worker(worker_id)
-  @mutex.synchronize do
-    return true unless @running
-
-    index, context = find_worker(worker_id)
-    break(nil) if index.nil?
-    context.terminated = true
-    terminate_worker(context)
-    @workers.delete_at(index) if @workers[index].restart == :temporary
-    true
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Supervisor/WorkerContext.html b/docs/1.0.5/Concurrent/Supervisor/WorkerContext.html deleted file mode 100644 index 1bb4684d8..000000000 --- a/docs/1.0.5/Concurrent/Supervisor/WorkerContext.html +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - Class: Concurrent::Supervisor::WorkerContext - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Supervisor::WorkerContext - - - -

- -
- -
Inherits:
-
- Struct - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/supervisor.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) restart - - - - - - - - - - - - - - - - -

    Returns the value of attribute restart.

    -
    - -
  • - - -
  • - - - - (Object) type - - - - - - - - - - - - - - - - -

    Returns the value of attribute type.

    -
    - -
  • - - -
  • - - - - (Object) worker - - - - - - - - - - - - - - - - -

    Returns the value of attribute worker.

    -
    - -
  • - - -
- - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) restart - - - - - -

-
-

Returns the value of attribute restart

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of restart

    -
    - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/supervisor.rb', line 19
-
-def restart
-  @restart
-end
-
-
- - - -
-

- - - (Object) type - - - - - -

-
-

Returns the value of attribute type

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of type

    -
    - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/supervisor.rb', line 19
-
-def type
-  @type
-end
-
-
- - - -
-

- - - (Object) worker - - - - - -

-
-

Returns the value of attribute worker

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of worker

    -
    - -
  • - -
- -
- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/concurrent/supervisor.rb', line 19
-
-def worker
-  @worker
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Supervisor/WorkerCounts.html b/docs/1.0.5/Concurrent/Supervisor/WorkerCounts.html deleted file mode 100644 index 19e6d44e9..000000000 --- a/docs/1.0.5/Concurrent/Supervisor/WorkerCounts.html +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - Class: Concurrent::Supervisor::WorkerCounts - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Concurrent::Supervisor::WorkerCounts - - - -

- -
- -
Inherits:
-
- Struct - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/supervisor.rb
- -
-
- - - - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) specs - - - - - - - - - - - - - - - - -

    Returns the value of attribute specs.

    -
    - -
  • - - -
  • - - - - (Object) supervisors - - - - - - - - - - - - - - - - -

    Returns the value of attribute supervisors.

    -
    - -
  • - - -
  • - - - - (Object) workers - - - - - - - - - - - - - - - - -

    Returns the value of attribute workers.

    -
    - -
  • - - -
- - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) specs - - - - - -

-
-

Returns the value of attribute specs

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of specs

    -
    - -
  • - -
- -
- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/supervisor.rb', line 39
-
-def specs
-  @specs
-end
-
-
- - - -
-

- - - (Object) supervisors - - - - - -

-
-

Returns the value of attribute supervisors

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of supervisors

    -
    - -
  • - -
- -
- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/supervisor.rb', line 39
-
-def supervisors
-  @supervisors
-end
-
-
- - - -
-

- - - (Object) workers - - - - - -

-
-

Returns the value of attribute workers

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of workers

    -
    - -
  • - -
- -
- - - - -
-
-
-
-39
-40
-41
-
-
# File 'lib/concurrent/supervisor.rb', line 39
-
-def workers
-  @workers
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Synchronization.html b/docs/1.0.5/Concurrent/Synchronization.html index fd6e9119e..d07e9239a 100644 --- a/docs/1.0.5/Concurrent/Synchronization.html +++ b/docs/1.0.5/Concurrent/Synchronization.html @@ -242,9 +242,9 @@

Constant Summary

- - - - - - - - - - - - - -

Class: Concurrent::Synchronization::LockableObject - - - -

- -
- -
Inherits:
-
- LockableObjectImplementation - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/synchronization/lockable_object.rb,
- lib/concurrent/synchronization/condition.rb
-
- -
-
- -

Overview

-
-

TODO (pitr 12-Sep-2015): make private for c-r, prohibit subclassing

- - -
-
-
- - -
- - - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (Object) initialize(*args, &block) - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 36
-
-
-
-
- -
- - -
-

Class Method Details

- - -
-

- - + (Object) allow_only_direct_descendants! - - - - - -

-
-

TODO (pitr 12-Sep-2015): we inherit too much ourselves :/

- - -
-
-
- - -
- - - - -
-
-
-
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 25
-
-def self.allow_only_direct_descendants!
-  this = self
-  singleton_class.send :define_method, :inherited do |child|
-    # super child
-
-    if child.superclass != this
-      warn "all children of #{this} are final, subclassing is not supported use composition."
-    end
-  end
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (Object) broadcast - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 54
-
-
-
-
- -
-

- - - (Object) new_condition - - - - - -

- - - - -
-
-
-
-50
-51
-52
-
-
# File 'lib/concurrent/synchronization/condition.rb', line 50
-
-def new_condition
-  Condition.private_new(self)
-end
-
-
- -
-

- - - (Object) signal - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 51
-
-
-
-
- -
-

- - - (Object) synchronize - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 39
-
-
-
-
- -
-

- - - (Object) wait(timeout = nil) - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 48
-
-
-
-
- -
-

- - - (Object) wait_until(timeout = nil, &condition) - - - - - -

- - - - -
-
-
-
-
-
-
# File 'lib/concurrent/synchronization/lockable_object.rb', line 45
-
-
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Synchronization/MriAttrVolatile.html b/docs/1.0.5/Concurrent/Synchronization/MriAttrVolatile.html index 1e1810909..5e9d280cc 100644 --- a/docs/1.0.5/Concurrent/Synchronization/MriAttrVolatile.html +++ b/docs/1.0.5/Concurrent/Synchronization/MriAttrVolatile.html @@ -177,9 +177,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::Synchronized - - - -

- -
- - - - - - - - -
Defined in:
-
lib/concurrent/atomic/synchronized.rb
- -
-
- -

Overview

-
- -
- Note: -

synchronized needs to be called in #initialize for this module to work properly

-
-
- -

Safe synchronization to an object under JRuby and MRI

- - -
-
-
- -
-

Examples:

- - -

usage

-

- -
class AClass
-  include Synchronized
-
-  def initialize
-    synchronize do
-      # body of the constructor ...
-    end
-  end
-
-  def a_method
-    synchronize do
-      # body of a_method ...
-    end
-  end
-end
- -
- - -
- - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) synchronize - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/atomic/synchronized.rb', line 26
-
-def synchronize
-  JRuby.reference0(self).synchronized { yield }
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/TVar.html b/docs/1.0.5/Concurrent/TVar.html index db0dd3e78..ebb135ba4 100644 --- a/docs/1.0.5/Concurrent/TVar.html +++ b/docs/1.0.5/Concurrent/TVar.html @@ -626,9 +626,9 @@

- - - - - - - - - - - - - -

Module: Concurrent::ThreadLocalJavaStorage - - - -

- -
- - - - - - - -
Included in:
-
ThreadLocalVar
- - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage (protected) - - - - - -

- - - - -
-
-
-
-25
-26
-27
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 25
-
-def allocate_storage
-  @var = java.lang.ThreadLocal.new
-end
-
-
- -
-

- - - (Object) get (protected) - - - - - -

- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 29
-
-def get
-  @var.get
-end
-
-
- -
-

- - - (Object) set(value) (protected) - - - - - -

- - - - -
-
-
-
-33
-34
-35
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 33
-
-def set(value)
-  @var.set(value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ThreadLocalNewStorage.html b/docs/1.0.5/Concurrent/ThreadLocalNewStorage.html deleted file mode 100644 index 575bb60d7..000000000 --- a/docs/1.0.5/Concurrent/ThreadLocalNewStorage.html +++ /dev/null @@ -1,345 +0,0 @@ - - - - - - Module: Concurrent::ThreadLocalNewStorage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::ThreadLocalNewStorage - - - -

- -
- - - - - -
Includes:
-
ThreadLocalSymbolAllocator
- - - - -
Included in:
-
ThreadLocalVar
- - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - -

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage (protected) - - - - - -

- - - - -
-
-
-
-42
-43
-44
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 42
-
-def allocate_storage
-  allocate_symbol
-end
-
-
- -
-

- - - (Object) allocate_symbol (protected) - - - - - - - Originally defined in module - ThreadLocalSymbolAllocator - - -

-
- -
-

- - - (Object) get (protected) - - - - - -

- - - - -
-
-
-
-46
-47
-48
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 46
-
-def get
-  Thread.current.thread_variable_get(@symbol)
-end
-
-
- -
-

- - - (Object) set(value) (protected) - - - - - -

- - - - -
-
-
-
-50
-51
-52
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 50
-
-def set(value)
-  Thread.current.thread_variable_set(@symbol, value)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ThreadLocalOldStorage.html b/docs/1.0.5/Concurrent/ThreadLocalOldStorage.html deleted file mode 100644 index 153401dd8..000000000 --- a/docs/1.0.5/Concurrent/ThreadLocalOldStorage.html +++ /dev/null @@ -1,345 +0,0 @@ - - - - - - Module: Concurrent::ThreadLocalOldStorage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::ThreadLocalOldStorage - - - -

- -
- - - - - -
Includes:
-
ThreadLocalSymbolAllocator
- - - - -
Included in:
-
ThreadLocalVar
- - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - -

Constant Summary

- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage (protected) - - - - - -

- - - - -
-
-
-
-22
-23
-24
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 22
-
-def allocate_storage
-  allocate_symbol
-end
-
-
- -
-

- - - (Object) allocate_symbol (protected) - - - - - - - Originally defined in module - ThreadLocalSymbolAllocator - - -

-
- -
-

- - - (Object) get (protected) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 26
-
-def get
-  Thread.current[@symbol]
-end
-
-
- -
-

- - - (Object) set(value) (protected) - - - - - -

- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 30
-
-def set(value)
-  Thread.current[@symbol] = value
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ThreadLocalRubyStorage.html b/docs/1.0.5/Concurrent/ThreadLocalRubyStorage.html deleted file mode 100644 index b5db94c28..000000000 --- a/docs/1.0.5/Concurrent/ThreadLocalRubyStorage.html +++ /dev/null @@ -1,292 +0,0 @@ - - - - - - Module: Concurrent::ThreadLocalRubyStorage - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::ThreadLocalRubyStorage - - - -

- -
- - - - - - - -
Included in:
-
ThreadLocalVar
- - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_storage - - - - - -

- - - - -
-
-
-
-7
-8
-9
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 7
-
-def allocate_storage
-  @storage = Atomic.new Hash.new
-end
-
-
- -
-

- - - (Object) get - - - - - -

- - - - -
-
-
-
-11
-12
-13
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 11
-
-def get
-  @storage.get[Thread.current]
-end
-
-
- -
-

- - - (Object) set(value) - - - - - -

- - - - -
-
-
-
-15
-16
-17
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 15
-
-def set(value)
-  @storage.update { |s| s.merge Thread.current => value }
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ThreadLocalSymbolAllocator.html b/docs/1.0.5/Concurrent/ThreadLocalSymbolAllocator.html deleted file mode 100644 index 1c60be3b7..000000000 --- a/docs/1.0.5/Concurrent/ThreadLocalSymbolAllocator.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - Module: Concurrent::ThreadLocalSymbolAllocator - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Module: Concurrent::ThreadLocalSymbolAllocator - - - -

- -
- - - - - - - -
Included in:
-
ThreadLocalNewStorage, ThreadLocalOldStorage
- - - -
Defined in:
-
lib/concurrent/atomic/thread_local_var.rb
- -
-
- - -

Constant Summary

- -
- -
COUNTER = - -
-
AtomicFixnum.new
- -
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) allocate_symbol (protected) - - - - - -

- - - - -
-
-
-
-9
-10
-11
-12
-
-
# File 'lib/concurrent/atomic/thread_local_var.rb', line 9
-
-def allocate_symbol
-  # Warning: this symbol may never be deallocated
-  @symbol = :thread_local_symbol_#{COUNTER.increment}"
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/ThreadLocalVar.html b/docs/1.0.5/Concurrent/ThreadLocalVar.html index e196ec1a9..4799b652e 100644 --- a/docs/1.0.5/Concurrent/ThreadLocalVar.html +++ b/docs/1.0.5/Concurrent/ThreadLocalVar.html @@ -581,9 +581,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::TimerSet::Task - - - -

- -
- -
Inherits:
-
- Struct - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/executor/timer_set.rb
- -
-
- -

Overview

-
-

A struct for encapsulating a task and its intended execution time. -It facilitates proper prioritization by overriding the comparison -(spaceship) operator as a comparison of the intended execution -times.

- - -
-
-
- - -
- - - -

Instance Attribute Summary (collapse)

-
    - -
  • - - - - (Object) args - - - - - - - - - - - private - - - - - -

    Returns the value of attribute args.

    -
    - -
  • - - -
  • - - - - (Object) op - - - - - - - - - - - private - - - - - -

    Returns the value of attribute op.

    -
    - -
  • - - -
  • - - - - (Object) time - - - - - - - - - - - private - - - - - -

    Returns the value of attribute time.

    -
    - -
  • - - -
- - - - - - -
-

Instance Attribute Details

- - - -
-

- - - (Object) args (private) - - - - - -

-
-

Returns the value of attribute args

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of args

    -
    - -
  • - -
- -
- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/executor/timer_set.rb', line 102
-
-def args
-  @args
-end
-
-
- - - -
-

- - - (Object) op (private) - - - - - -

-
-

Returns the value of attribute op

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of op

    -
    - -
  • - -
- -
- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/executor/timer_set.rb', line 102
-
-def op
-  @op
-end
-
-
- - - -
-

- - - (Object) time (private) - - - - - -

-
-

Returns the value of attribute time

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Object) - - - - — -

    the current value of time

    -
    - -
  • - -
- -
- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/executor/timer_set.rb', line 102
-
-def time
-  @time
-end
-
-
- -
- - -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/TimerTask.html b/docs/1.0.5/Concurrent/TimerTask.html index 60090639b..79abb2fc0 100644 --- a/docs/1.0.5/Concurrent/TimerTask.html +++ b/docs/1.0.5/Concurrent/TimerTask.html @@ -2006,9 +2006,9 @@

- - - - - - - - - - - - - -

Class: Concurrent::UnbufferedChannel - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/unbuffered_channel.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (UnbufferedChannel) initialize - - - - - -

-
-

Returns a new instance of UnbufferedChannel

- - -
-
-
- - -
- - - - -
-
-
-
-6
-7
-8
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 6
-
-def initialize
-  @probe_set = WaitableList.new
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) pop - - - - - -

- - - - -
-
-
-
-20
-21
-22
-23
-24
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 20
-
-def pop
-  probe = Channel::Probe.new
-  select(probe)
-  probe.value
-end
-
-
- -
-

- - - (Object) probe_set_size - - - - - -

- - - - -
-
-
-
-10
-11
-12
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 10
-
-def probe_set_size
-  @probe_set.size
-end
-
-
- -
-

- - - (Object) push(value) - - - - - -

- - - - -
-
-
-
-14
-15
-16
-17
-18
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 14
-
-def push(value)
-  # TODO set_unless_assigned define on IVar as #set_state? or #try_set_state
-  until @probe_set.take.set_unless_assigned(value, self)
-  end
-end
-
-
- -
-

- - - (Object) remove_probe(probe) - - - - - -

- - - - -
-
-
-
-30
-31
-32
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 30
-
-def remove_probe(probe)
-  @probe_set.delete(probe)
-end
-
-
- -
-

- - - (Object) select(probe) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-
-
# File 'lib/concurrent/channel/unbuffered_channel.rb', line 26
-
-def select(probe)
-  @probe_set.put(probe)
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Utility.html b/docs/1.0.5/Concurrent/Utility.html index e6517913b..09aa37fc2 100644 --- a/docs/1.0.5/Concurrent/Utility.html +++ b/docs/1.0.5/Concurrent/Utility.html @@ -98,9 +98,9 @@ - - - - - - - - - - - - - -

Class: Concurrent::WaitableList - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/channel/waitable_list.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - -
-

Constructor Details

- -
-

- - - (WaitableList) initialize - - - - - -

-
-

Returns a new instance of WaitableList

- - -
-
-
- - -
- - - - -
-
-
-
-6
-7
-8
-9
-10
-11
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 6
-
-def initialize
-  @mutex = Mutex.new
-  @condition = Condition.new
-
-  @list = []
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) delete(value) - - - - - -

- - - - -
-
-
-
-28
-29
-30
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 28
-
-def delete(value)
-  @mutex.synchronize { @list.delete(value) }
-end
-
-
- -
-

- - - (Boolean) empty? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-17
-18
-19
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 17
-
-def empty?
-  @mutex.synchronize { @list.empty? }
-end
-
-
- -
-

- - - (Object) put(value) - - - - - -

- - - - -
-
-
-
-21
-22
-23
-24
-25
-26
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 21
-
-def put(value)
-  @mutex.synchronize do
-    @list << value
-    @condition.signal
-  end
-end
-
-
- -
-

- - - (Object) size - - - - - -

- - - - -
-
-
-
-13
-14
-15
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 13
-
-def size
-  @mutex.synchronize { @list.size }
-end
-
-
- -
-

- - - (Object) take - - - - - -

- - - - -
-
-
-
-32
-33
-34
-35
-36
-37
-
-
# File 'lib/concurrent/channel/waitable_list.rb', line 32
-
-def take
-  @mutex.synchronize do
-    @condition.wait(@mutex) while @list.empty?
-    @list.shift
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Counter.html b/docs/1.0.5/Counter.html deleted file mode 100644 index ffe892816..000000000 --- a/docs/1.0.5/Counter.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - Class: Counter - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Counter - - - -

- -
- -
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
- - - - - - -
Includes:
-
Context
- - - - - -
Defined in:
-
lib/concurrent/actor/play.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - -
-

Constructor Details

- -
-

- - - (Counter) initialize(initial_value) - - - - - -

-
-

Returns a new instance of Counter

- - -
-
-
- - -
- - - - -
-
-
-
-4
-5
-6
-
-
# File 'lib/concurrent/actor/play.rb', line 4
-
-def initialize(initial_value)
-  @count = initial_value
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) on_message(message) - - - - - -

- - - - -
-
-
-
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-
-
# File 'lib/concurrent/actor/play.rb', line 8
-
-def on_message(message)
-  case message
-  when Integer
-    @count += message
-  when :terminate
-    terminate!
-  else
-    raise 'unknown'
-  end
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/Event.html b/docs/1.0.5/Event.html deleted file mode 100644 index 0a9ca04b9..000000000 --- a/docs/1.0.5/Event.html +++ /dev/null @@ -1,2238 +0,0 @@ - - - - - - Class: Event - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: Event - - - -

- -
- -
Inherits:
-
- SynchronizedObject - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- - - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - -
-

Constructor Details

- -
-

- - - (Event) initialize(promise, default_executor = :fast) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

-

Returns a new instance of Event

- - -
-
-
- - -
- - - - -
-
-
-
-47
-48
-49
-50
-51
-52
-53
-54
-55
-
-
# File 'lib/concurrent/next2.rb', line 47
-
-def initialize(promise, default_executor = :fast)
-  super()
-  synchronize do
-    @promise          = promise
-    @state            = :pending
-    @callbacks        = []
-    @default_executor = default_executor
-  end
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - - (Object) add_callback(method, *args) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-215
-216
-217
-218
-219
-220
-221
-222
-223
-224
-
-
# File 'lib/concurrent/next2.rb', line 215
-
-def add_callback(method, *args)
-  synchronize do
-    if completed?
-      call_callback method, *args
-    else
-      @callbacks << [method, *args]
-    end
-  end
-  self
-end
-
-
- -
-

- - - (Array<Promise>) blocks - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Promise>) - - - -
  • - -
- -
- - - - -
-
-
-
-160
-161
-162
-163
-164
-
-
# File 'lib/concurrent/next2.rb', line 160
-
-def blocks
-  synchronize { @callbacks }.each_with_object([]) do |callback, promises|
-    promises.push *callback.select { |v| v.is_a? Promise }
-  end
-end
-
-
- -
-

- - - (Object) callbacks - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

-

just for inspection

- - -
-
-
- - -
- - - - -
-
-
-
-210
-211
-212
-
-
# File 'lib/concurrent/next2.rb', line 210
-
-def callbacks
-  synchronize { @callbacks }.clone.freeze
-end
-
-
- -
-

- - - (Object) chain(executor = default_executor) {|success, value, reason| ... } - - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    of the parent

    -
    - -
  • - -
- -
- - - - -
-
-
-
-97
-98
-99
-
-
# File 'lib/concurrent/next2.rb', line 97
-
-def chain(executor = default_executor, &callback)
-  ChainPromise.new([self], default_executor, executor, &callback).future
-end
-
-
- -
-

- - - (Object) complete(success, value, reason, raise = true) - - - - - -

-
-

- This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

- - -
-
-
- - -
- - - - -
-
-
-
-181
-182
-183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-203
-204
-205
-206
-
-
# File 'lib/concurrent/next2.rb', line 181
-
-def complete(success, value, reason, raise = true) # :nodoc:
-  callbacks = synchronize do
-    if completed?
-      if raise
-        raise Concurrent::MultipleAssignmentError.new('multiple assignment')
-      else
-        return nil
-      end
-    end
-    if success
-      @value = value
-      @state = :success
-    else
-      @reason = reason
-      @state  = :failed
-    end
-    notify_all
-    @callbacks
-  end
-
-  # TODO pass in local vars to avoid syncing
-  callbacks.each { |method, *args| call_callback method, *args }
-  callbacks.clear
-
-  self
-end
-
-
- -
-

- - - (Boolean) completed? - - - - - -

-
- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-65
-66
-67
-
-
# File 'lib/concurrent/next2.rb', line 65
-
-def completed?
-  state == :success
-end
-
-
- -
-

- - - (Object) default_executor - - - - - -

- - - - -
-
-
-
-88
-89
-90
-
-
# File 'lib/concurrent/next2.rb', line 88
-
-def default_executor
-  synchronize { @default_executor }
-end
-
-
- -
-

- - - (Object) delay(executor = default_executor, &task) - - - - - -

- - - - -
-
-
-
-111
-112
-113
-
-
# File 'lib/concurrent/next2.rb', line 111
-
-def delay(executor = default_executor, &task)
-  Delay.new([self], default_executor, executor, &task).future
-end
-
-
- -
-

- - - (Object) flat - - - - - -

- - - - -
-
-
-
-115
-116
-117
-
-
# File 'lib/concurrent/next2.rb', line 115
-
-def flat
-  FlattingPromise.new([self], default_executor).future
-end
-
-
- -
-

- - - (Object) inspect - - - - - -

- - - - -
-
-
-
-170
-171
-172
-
-
# File 'lib/concurrent/next2.rb', line 170
-
-def inspect
-  "#{to_s[0..-2]} blocks:[#{blocks.map(&:to_s).join(', ')}]>"
-end
-
-
- -
-

- - - (Object) join(*futures) - - - - Also known as: - + - - - - -

- - - - -
-
-
-
-174
-175
-176
-
-
# File 'lib/concurrent/next2.rb', line 174
-
-def join(*futures)
-  JoiningPromise.new([self, *futures], default_executor).future
-end
-
-
- -
-

- - - (Object) on_completion(executor = default_executor) {|success, value, reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    executed async on executor when completed

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-125
-126
-127
-
-
# File 'lib/concurrent/next2.rb', line 125
-
-def on_completion(executor = default_executor, &callback)
-  add_callback :async_callback_on_completion, executor, callback
-end
-
-
- -
-

- - - (Object) on_completion! {|success, value, reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (success, value, reason) - - - - — -

    executed sync when completed

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-143
-144
-145
-
-
# File 'lib/concurrent/next2.rb', line 143
-
-def on_completion!(&callback)
-  add_callback :callback_on_completion, callback
-end
-
-
- -
-

- - - (Object) on_failure(executor = default_executor) {|reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed async on executor when failed?

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-137
-138
-139
-
-
# File 'lib/concurrent/next2.rb', line 137
-
-def on_failure(executor = default_executor, &callback)
-  add_callback :async_callback_on_failure, executor, callback
-end
-
-
- -
-

- - - (Object) on_failure! {|reason| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed sync when failed?

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-155
-156
-157
-
-
# File 'lib/concurrent/next2.rb', line 155
-
-def on_failure!(&callback)
-  add_callback :callback_on_failure, callback
-end
-
-
- -
-

- - - (Object) on_success(executor = default_executor) {|value| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed async on executor when success

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-131
-132
-133
-
-
# File 'lib/concurrent/next2.rb', line 131
-
-def on_success(executor = default_executor, &callback)
-  add_callback :async_callback_on_success, executor, callback
-end
-
-
- -
-

- - - (Object) on_success! {|value| ... } - - - - - -

-
-

Returns self

- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed sync when success

    -
    - -
  • - -
-

Returns:

-
    - -
  • - - - - - - - -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-149
-150
-151
-
-
# File 'lib/concurrent/next2.rb', line 149
-
-def on_success!(&callback)
-  add_callback :callback_on_success, callback
-end
-
-
- -
-

- - - (Boolean) pending? - - - - Also known as: - incomplete? - - - - -

-
-

Is obligation completion still pending?

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - -
  • - -
- -
- - - - -
-
-
-
-59
-60
-61
-
-
# File 'lib/concurrent/next2.rb', line 59
-
-def pending?
-  state == :pending
-end
-
-
- -
-

- - - (Object) promise - - - - - -

-
- - -
-
-
- - -
- - - - -
-
-
-
-227
-228
-229
-
-
# File 'lib/concurrent/next2.rb', line 227
-
-def promise
-  synchronize { @promise }
-end
-
-
- -
-

- - - (Object) rescue(executor = default_executor) {|reason| ... } - - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (reason) - - - - — -

    executed only on parent failure

    -
    - -
  • - -
- -
- - - - -
-
-
-
-107
-108
-109
-
-
# File 'lib/concurrent/next2.rb', line 107
-
-def rescue(executor = default_executor, &callback)
-  RescuePromise.new([self], default_executor, executor, &callback).future
-end
-
-
- -
-

- - - (Object) schedule(intended_time) - - - - - -

- - - - -
-
-
-
-119
-120
-121
-
-
# File 'lib/concurrent/next2.rb', line 119
-
-def schedule(intended_time)
-  Scheduled.new(intended_time, [self], default_executor).future
-end
-
-
- -
-

- - - (Object) state - - - - - -

- - - - -
-
-
-
-84
-85
-86
-
-
# File 'lib/concurrent/next2.rb', line 84
-
-def state
-  synchronize { @state }
-end
-
-
- -
-

- - - (Object) then(executor = default_executor) {|value| ... } - - - - - -

-
- - -
-
-
- -

Yields:

-
    - -
  • - - - (value) - - - - — -

    executed only on parent success

    -
    - -
  • - -
- -
- - - - -
-
-
-
-102
-103
-104
-
-
# File 'lib/concurrent/next2.rb', line 102
-
-def then(executor = default_executor, &callback)
-  ThenPromise.new([self], default_executor, executor, &callback).future
-end
-
-
- -
-

- - - (Object) to_s - - - - - -

- - - - -
-
-
-
-166
-167
-168
-
-
# File 'lib/concurrent/next2.rb', line 166
-
-def to_s
-  "<##{self.class}:0x#{'%x' % (object_id << 1)} #{state}>"
-end
-
-
- -
-

- - - (Object) touch - - - - - -

- - - - -
-
-
-
-80
-81
-82
-
-
# File 'lib/concurrent/next2.rb', line 80
-
-def touch
-  promise.touch
-end
-
-
- -
-

- - - (Obligation) wait(timeout = nil) - - - - - -

-
-

wait until Obligation is #complete?

- - -
-
-
-

Parameters:

-
    - -
  • - - timeout - - - (Numeric) - - - (defaults to: nil) - - - — -

    the maximum time in second to wait.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Obligation) - - - - — -

    self

    -
    - -
  • - -
- -
- - - - -
-
-
-
-72
-73
-74
-75
-76
-77
-78
-
-
# File 'lib/concurrent/next2.rb', line 72
-
-def wait(timeout = nil)
-  synchronize do
-    touch
-    super timeout if incomplete?
-    self
-  end
-end
-
-
- -
-

- - - (Object) with_default_executor(executor = default_executor) - - - - - -

- - - - -
-
-
-
-92
-93
-94
-
-
# File 'lib/concurrent/next2.rb', line 92
-
-def with_default_executor(executor = default_executor)
-  JoiningPromise.new([self], executor).future
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/InnerPromise.html b/docs/1.0.5/InnerPromise.html deleted file mode 100644 index d5e262c19..000000000 --- a/docs/1.0.5/InnerPromise.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - Class: InnerPromise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: InnerPromise - Abstract - - -

- -
- -
Inherits:
-
- Promise - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/next2.rb
- -
-
- -

Overview

-
-
- This class is abstract. -
-
- - -
-
-
- - -
-

Direct Known Subclasses

-

BlockedPromise

-
- - - - - - - - -

- Instance Method Summary - (collapse) -

- - - - - - - -
-

Instance Method Details

- - -
-

- - - (Object) completion - - - - - -

-
- - -
-
-
- -

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-7
-8
-9
-
-
# File 'lib/concurrent/next2.rb', line 7
-
-def completion
-  raise NotImplementedError
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/ProcessingActor.html b/docs/1.0.5/ProcessingActor.html deleted file mode 100644 index f2c5bc93c..000000000 --- a/docs/1.0.5/ProcessingActor.html +++ /dev/null @@ -1,731 +0,0 @@ - - - - - - Class: ProcessingActor - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Class: ProcessingActor - - - -

- -
- -
Inherits:
-
- Synchronization::Object - -
    -
  • Object
  • - - - - - -
- show all - -
- - - - - - - - - -
Defined in:
-
lib/concurrent/edge/processing_actor.rb
- -
-
- - - - - - - - - -

- Class Method Summary - (collapse) -

- - - -

- Instance Method Summary - (collapse) -

- - - - - -
-

Constructor Details

- -
-

- - - (ProcessingActor) initialize(channel = Promises::Channel.new) - - - - - -

-
-

Returns a new instance of ProcessingActor

- - -
-
-
- - -
- - - - -
-
-
-
-8
-9
-10
-11
-12
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 8
-
-def initialize(channel = Promises::Channel.new)
-  @Mailbox              = channel
-  @Terminated           = Promises.resolvable_future
-  super()
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - + (undocumented) act(*args, &process) - - - - - -

- - - - -
-
-
-
-22
-23
-24
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 22
-
-def self.act(*args, &process)
-  act_on Promises::Channel.new, *args, &process
-end
-
-
- -
-

- - + (undocumented) act_on(channel, *args, &process) - - - - - -

- - - - -
-
-
-
-26
-27
-28
-29
-30
-31
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 26
-
-def self.act_on(channel, *args, &process)
-  actor  = ProcessingActor.new channel
-  future = Promises.future(actor, *args, &process)
-  future.run.chain_resolvable(actor.instance_variable_get(:@Terminated))
-  actor
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - - (undocumented) ask(*message, probe: Promises.resolvable_future) - - - - - -

- - - - -
-
-
-
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 47
-
-def ask(*message, probe: Promises.resolvable_future)
-  tell *message, probe
-  (probe | @Terminated).chain do |fulfilled, value, reason|
-    if @Terminated.resolved?
-      raise @Terminated.fulfilled? ? 'actor terminated before answering' : @Terminated
-    else
-      fulfilled ? value : raise(reason)
-    end
-  end
-end
-
-
- -
-

- - - (undocumented) inspect - - - - - -

- - - - -
-
-
-
-58
-59
-60
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 58
-
-def inspect
-  format '<#%s:0x%x termination:%s>', self.class, object_id << 1, termination.state
-end
-
-
- -
-

- - - (undocumented) mailbox - - - - - -

- - - - -
-
-
-
-14
-15
-16
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 14
-
-def mailbox
-  @Mailbox
-end
-
-
- -
-

- - - (undocumented) push(*message) - - - - - -

- - - - -
-
-
-
-43
-44
-45
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 43
-
-def push(*message)
-  @Mailbox.push message
-end
-
-
- -
-

- - - (undocumented) receive(probe = Promises.resolvable_future) - - - - - -

- - - - -
-
-
-
-33
-34
-35
-36
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 33
-
-def receive(probe = Promises.resolvable_future)
-  # TODO (pitr-ch 27-Dec-2016): patterns
-  @Mailbox.pop probe
-end
-
-
- -
-

- - - (undocumented) tell(*message) - - - - - -

- - - - -
-
-
-
-38
-39
-40
-41
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 38
-
-def tell(*message)
-  @Mailbox.push message
-  self
-end
-
-
- -
-

- - - (undocumented) termination - - - - - -

- - - - -
-
-
-
-18
-19
-20
-
-
# File 'lib/concurrent/edge/processing_actor.rb', line 18
-
-def termination
-  @Terminated.with_hidden_resolvable
-end
-
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/_index.html b/docs/1.0.5/_index.html index 0c0c1605e..7bfb8352c 100644 --- a/docs/1.0.5/_index.html +++ b/docs/1.0.5/_index.html @@ -1345,9 +1345,9 @@

Namespace Listing A-Z

- + \ No newline at end of file diff --git a/docs/1.0.5/file.agent.html b/docs/1.0.5/file.agent.html deleted file mode 100644 index ec4265ca0..000000000 --- a/docs/1.0.5/file.agent.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - File: agent - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Agents are inspired by Clojure's agent function. An Agent is a single atomic value that represents an identity. The current value of the Agent can be requested at any time (deref). Each Agent has a work queue and operates on the global thread pool (see below). Consumers can post code blocks to the Agent. The code block (function) will receive the current value of the Agent as its sole parameter. The return value of the block will become the new value of the Agent. Agents support two error handling modes: fail and continue. A good example of an Agent is a shared incrementing counter, such as the score in a video game.

- -

An Agent must be initialize with an initial value. This value is always accessible via the value (or deref) methods. Code blocks sent to the Agent will be processed in the order received. As each block is processed the current value is updated with the result from the block. This update is an atomic operation so a deref will never block and will always return the current value.

- -

When an Agent is created it may be given an optional validate block and zero or more rescue blocks. When a new value is calculated the value will be checked against the validator, if present. If the validator returns true the new value will be accepted. If it returns false it will be rejected. If a block raises an exception during execution the list of rescue blocks will be seacrhed in order until one matching the current exception is found. That rescue block will then be called an passed the exception object. If no matching rescue block is found, or none were configured, then the exception will be suppressed.

- -

Agents also implement Ruby's Observable. Code that observes an Agent will receive a callback with the new value any time the value is changed.

- -

Copy Options

- -

Object references in Ruby are mutable. This can lead to serious problems when the value of an Agent is a mutable reference. Which is always the case unless the value is a Fixnum, Symbol, or similar "primative" data type. Each Agent instance can be configured with a few options that can help protect the program from potentially dangerous operations. Each of these options can be optionally set when the Agent is created:

- -
    -
  • :dup_on_deref when true the Agent will call the #dup method on the value object every time the #value methid is called (default: false)
  • -
  • :freeze_on_deref when true the Agent will call the #freeze method on the value object every time the #value method is called (default: false)
  • -
  • :copy_on_deref when given a Proc object the Proc will be run every time the #value method is called. The Proc will be given the current value as its only parameter and the result returned by the block will be the return value of the #value call. When nil this option will be ignored (default: nil)
  • -
- -

Examples

- -

A simple example:

- -
require 'concurrent'
-
-score = Concurrent::Agent.new(10)
-score.value #=> 10
-
-score << proc{|current| current + 100 }
-sleep(0.1)
-score.value #=> 110
-
-score << proc{|current| current * 2 }
-sleep(0.1)
-score.value #=> 220
-
-score << proc{|current| current - 50 }
-sleep(0.1)
-score.value #=> 170
-
- -

With validation and error handling:

- -
score = Concurrent::Agent.new(0).validate{|value| value <= 1024 }.
-          rescue(NoMethodError){|ex| puts "Bam!" }.
-          rescue(ArgumentError){|ex| puts "Pow!" }.
-          rescue{|ex| puts "Boom!" }
-score.value #=> 0
-
-score << proc{|current| current + 2048 }
-sleep(0.1)
-score.value #=> 0
-
-score << proc{|current| raise ArgumentError }
-sleep(0.1)
-#=> puts "Pow!"
-score.value #=> 0
-
-score << proc{|current| current + 100 }
-sleep(0.1)
-score.value #=> 100
-
- -

With observation:

- -
bingo = Class.new{
-  def update(time, score)
-    puts "Bingo! [score: #{score}, time: #{time}]" if score >= 100
-  end
-}.new
-
-score = Concurrent::Agent.new(0)
-score.add_observer(bingo)
-
-score << proc{|current| sleep(0.1); current += 30 }
-score << proc{|current| sleep(0.1); current += 30 }
-score << proc{|current| sleep(0.1); current += 30 }
-score << proc{|current| sleep(0.1); current += 30 }
-
-sleep(1)
-#=> Bingo! [score: 120, time: 2013-07-22 21:26:08 -0400]
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.async.html b/docs/1.0.5/file.async.html deleted file mode 100644 index d966089bd..000000000 --- a/docs/1.0.5/file.async.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - File: async - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

A mixin module that provides simple asynchronous behavior to any standard -class/object or object.

- -
Feature:
-  As a stateful, plain old Ruby class/object
-  I want safe, asynchronous behavior
-  So my long-running methods don't block the main thread
-
- -

Stateful, mutable objects must be managed carefully when used asynchronously. -But Ruby is an object-oriented language so designing with objects and classes -plays to Ruby's strengths and is often more natural to many Ruby programmers. -The Async module is a way to mix simple yet powerful asynchronous capabilities -into any plain old Ruby object or class. These capabilities provide a reasonable -level of thread safe guarantees when used correctly.

- -

When this module is mixed into a class or object it provides to new methods: -async and await. These methods are thread safe with respect to the enclosing -object. The former method allows methods to be called asynchronously by posting -to the global thread pool. The latter allows a method to be called synchronously -on the current thread but does so safely with respect to any pending asynchronous -method calls. Both methods return an Obligation which can be inspected for -the result of the method call. Calling a method with async will return a -:pending Obligation whereas await will return a :complete Obligation.

- -

Very loosely based on the async and await keywords in C#.

- -

An Important Note About Initialization

- -
-

This module depends on several internal synchronization objects that -must be initialized prior to calling any of the async/await/executor methods. -The best practice is to call init_mutex from within the constructor -of the including class. A less ideal but acceptable practice is for the -thread creating the asynchronous object to explicitly call the init_mutex -method prior to calling any of the async/await/executor methods. If -init_mutex is not called explicitly the async/await/executor methods -will raise a Concurrent::InitializationError. This is the only way -thread-safe initialization can be guaranteed.

-
- -

An Important Note About Thread Safe Guarantees

- -
-

Thread safe guarantees can only be made when asynchronous method calls -are not mixed with synchronous method calls. Use only synchronous calls -when the object is used exclusively on a single thread. Use only -async and await when the object is shared between threads. Once you -call a method using async, you should no longer call any methods -directly on the object. Use async and await exclusively from then on. -With careful programming it is possible to switch back and forth but it's -also very easy to create race conditions and break your application. -Basically, it's "async all the way down."

-
- -

Examples

- -

Defining an asynchronous class

- -
Scenario: Defining an asynchronous class
-  Given a class definition
-  When I include the Concurrent::Async module
-  Then an `async` method is defined for all objects of the class
-  And an `await` method is defined for all objects of the class
-
-Scenario: Calling the `async` method
-  Given a class which includes Concurrent::Async module
-  When I call a normal method through the `async` delegate method
-  Then the method returns a Concurrent::Future object
-  And the method is executed on a background thread using the global thread pool
-  And the current thread does not block
-  And thread safety is provided with respect to other `async` and `await` calls
-  And the returned future can be interrogated for the status of the method call
-  And the returned future will eventually contain the `value` of the method call
-  Or the returned future will eventually contain the `reason` the method call failed
-
-Scenario: Calling the `await` method
-  Given a class which includes Concurrent::Async module
-  When I call a normal method through the `await` delegate method
-  Then the method returns a Concurrent::IVar object
-  And the method is executed on the current thread
-  And thread safety is provided with respect to other `async` and `await` calls
-  And the returned ivar will be in the :fulfilled state
-  Or the returned ivar will be in the :rejected state
-  And the returned ivar will immediately contain the `value` of the method call
-  Or the returned ivar will immediately contain the `reason` the method call failed
-
- -
class Echo
-  include Concurrent::Async
-
-  def initialize
-    init_mutex # initialize the internal synchronization objects
-  end
-
-  def echo(msg)
-    sleep(rand)
-    print "#{msg}\n"
-    nil
-  end
-end
-
-horn = Echo.new
-horn.echo('zero') # synchronous, not thread-safe
-
-horn.async.echo('one') # asynchronous, non-blocking, thread-safe
-horn.await.echo('two') # synchronous, blocking, thread-safe
-
- -

Monkey-patching an existing object

- -
Scenario: Monkey-patching an existing object
-  Given an object of a class that does not include the Concurrent::Async module
-  When I extend the object with the Concurrent::Async module
-  Then an `async` method is monkey-patched onto the object
-  And an `await` method is monkey-patched onto the object
-  And the object behaved as though Concurrent::Async were included in the class
-  And the `async` and `await` methods perform as expected
-  And no other objects of that class are affected
-
- -
numbers = 1_000_000.times.collect{ rand }
-numbers.extend(Concurrent::Async)
-numbers.init_mutex # initialize the internal synchronization objects
-
-future = numbers.async.max
-future.state #=> :pending
-
-sleep(2)
-
-future.state #=> :fulfilled
-future.value #=> 0.999999138918843
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.dataflow.html b/docs/1.0.5/file.dataflow.html deleted file mode 100644 index 20a205d8e..000000000 --- a/docs/1.0.5/file.dataflow.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - File: dataflow - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available. Data dependencies are Future values. The dataflow task itself is also a Future value, so you can build up a graph of these tasks, each of which is run when all the data and other tasks it depends on are available or completed.

- -

Our syntax is somewhat related to that of Akka's flow and Habanero Java's DataDrivenFuture. However unlike Akka we don't schedule a task at all until it is ready to run, and unlike Habanero Java we pass the data values into the task instead of dereferencing them again in the task.

- -

The theory of dataflow goes back to the 70s. In the terminology of the literature, our implementation is coarse-grained, in that each task can be many instructions, and dynamic in that you can create more tasks within other tasks.

- -

Example

- -

A dataflow task is created with the dataflow method, passing in a block.

- -
task = Concurrent::dataflow { 14 }
-
- -

This produces a simple Future value. The task will run immediately, as it has no dependencies. We can also specify Future values that must be available before a task will run. When we do this we get the value of those futures passed to our block.

- -
a = Concurrent::dataflow { 1 }
-b = Concurrent::dataflow { 2 }
-c = Concurrent::dataflow(a, b) { |av, bv| av + bv }
-
- -

Using the dataflow method you can build up a directed acyclic graph (DAG) of tasks that depend on each other, and have the tasks run as soon as their dependencies are ready and there is CPU capacity to schedule them. This can help you create a program that uses more of the CPU resources available to you.

- -

Derivation

- -

This section describes how we could derive dataflow from other primitives in this library.

- -

Consider a naive fibonacci calculator.

- -
def fib(n)
-  if n < 2
-    n
-  else
-    fib(n - 1) + fib(n - 2)
-  end
-end
-
-puts fib(14) #=> 377
-
- -

We could modify this to use futures.

- -
def fib(n)
-  if n < 2
-    Concurrent::Future.new { n }
-  else
-    n1 = fib(n - 1).execute
-    n2 = fib(n - 2).execute
-    Concurrent::Future.new { n1.value + n2.value }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x000001019ef5a0 ...
-f.execute   #=> #<Concurrent::Future:0x000001019ef5a0 ...
-
-sleep(0.5)
-
-puts f.value #=> 377
-
- -

One of the drawbacks of this approach is that all the futures start, and then most of them immediately block on their dependencies. We know that there's no point executing those futures until their dependencies are ready, so let's not execute each future until all their dependencies are ready.

- -

To do this we'll create an object that counts the number of times it observes a future finishing before it does something - and for us that something will be to execute the next future.

- -
class CountingObserver
-
-  def initialize(count, &block)
-    @count = count
-    @block = block
-  end
-
-  def update(time, value, reason)
-    @count -= 1
-
-    if @count <= 0
-      @block.call()
-    end
-  end
-
-end
-
-def fib(n)
-  if n < 2
-    Concurrent::Future.new { n }.execute
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-
-    result = Concurrent::Future.new { n1.value + n2.value }
-
-    barrier = CountingObserver.new(2) { result.execute }
-    n1.add_observer barrier
-    n2.add_observer barrier
-
-    n1.execute
-    n2.execute
-
-    result
-  end
-end
-
- -

We can wrap this up in a dataflow utility.

- -
f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
-def dataflow(*inputs, &block)
-  result = Concurrent::Future.new(&block)
-
-  if inputs.empty?
-    result.execute
-  else
-    barrier = CountingObserver.new(inputs.size) { result.execute }
-
-    inputs.each do |input|
-      input.add_observer barrier
-    end
-  end
-
-  result
-end
-
-def fib(n)
-  if n < 2
-    dataflow { n }
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-    dataflow(n1, n2) { n1.value + n2.value }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
- -

Since we know that the futures the dataflow computation depends on are already going to be available when the future is executed, we might as well pass the values into the block so we don't have to reference the futures inside the block. This allows us to write the dataflow block as straight non-concurrent code without reference to futures.

- -
def dataflow(*inputs, &block)
-  result = Concurrent::Future.new do
-    values = inputs.map { |input| input.value }
-    block.call(*values)
-  end
-
-  if inputs.empty?
-    result.execute
-  else
-    barrier = CountingObserver.new(inputs.size) { result.execute }
-
-    inputs.each do |input|
-      input.add_observer barrier
-    end
-  end
-
-  result
-end
-
-def fib(n)
-  if n < 2
-    Concurrent::dataflow { n }
-  else
-    n1 = fib(n - 1)
-    n2 = fib(n - 2)
-    Concurrent::dataflow(n1, n2) { |v1, v2| v1 + v2 }
-  end
-end
-
-f = fib(14) #=> #<Concurrent::Future:0x000001019a26d8 ...
-sleep(0.5)
-
-puts f.value #=> 377
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.dataflow_top_stock_calc.html b/docs/1.0.5/file.dataflow_top_stock_calc.html deleted file mode 100644 index aa1805a79..000000000 --- a/docs/1.0.5/file.dataflow_top_stock_calc.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - File: dataflow_top_stock_calc - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

This program determines which stock had the highest price in a given year. -It as an example from chapter 1 "Introduction", section 1.2 "What's Scala?" of the book -Programming Scala: Tackle Multi-Core Complexity on the Java Virtual Machine.

- -

What It Does

- -

This program takes a list of one or more stock symbols and a year. It then concurrently -obtains the relevant stock data from Yahoo's iChart service for each symbol. Once all -the data has been retrieved the program determines which stock had the highest year-end -closing price.

- -
    -
  • A sample of the data can be downloaded here.
  • -
- -

The Ruby Code

- -
require 'concurrent'
-require 'open-uri'
-
-def get_year_end_closing(symbol, year)
-  uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
-  data = open(uri) {|f| f.collect{|line| line.strip } }
-  price = data[1].split(',')[4]
-  price.to_f
-  [symbol, price.to_f]
-end
-
-def get_top_stock(symbols, year, timeout = 5)
-  stock_prices = symbols.collect{|symbol| Concurrent::dataflow{ get_year_end_closing(symbol, year) }}
-  Concurrent::dataflow(*stock_prices) { |*prices|
-    prices.reduce(['', 0.0]){|highest, price| price.last > highest.last ? price : highest}
-  }.value(timeout)
-end
-
-symbols = ['AAPL', 'GOOG', 'IBM', 'ORCL', 'MSFT']
-year = 2008
-
-top_stock, highest_price = get_top_stock(symbols, year)
-
-puts "Top stock of #{year} is #{top_stock} closing at price $#{highest_price}"
-
- -

The Scala Code

- -
//START:PART1
-import scala.actors._
-import Actor._
-
-val symbols = List( "AAPL", "GOOG", "IBM", "JAVA", "MSFT")
-val receiver = self
-val year = 2008
-
-symbols.foreach { symbol =>
-  actor { receiver ! getYearEndClosing(symbol, year) }
-}
-
-val (topStock, highestPrice) = getTopStock(symbols.length)
-
-printf("Top stock of %d is %s closing at price %f\n", year, topStock, highestPrice)
-//END:PART1
-
-//START:PART2    
-def getYearEndClosing(symbol : String, year : Int) = {
-  val url = "http://ichart.finance.yahoo.com/table.csv?s=" +
-    symbol + "&a=11&b=01&c=" + year + "&d=11&e=31&f=" + year + "&g=m"
-
-  val data = io.Source.fromURL(url).mkString
-  val price = data.split("\n")(1).split(",")(4).toDouble  
-  (symbol, price)
-} 
-//END:PART2    
-
-//START:PART3
-def getTopStock(count : Int) : (String, Double) = {
-  (1 to count).foldLeft("", 0.0) { (previousHigh, index) =>
-    receiveWithin(10000) {
-      case (symbol : String, price : Double) =>
-        if (price > previousHigh._2) (symbol, price) else previousHigh
-    }
-  }
-} 
-//START:PART3
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.future.html b/docs/1.0.5/file.future.html deleted file mode 100644 index ba3308fee..000000000 --- a/docs/1.0.5/file.future.html +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - File: future - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Future is inspired by Clojure's future function. A future represents a promise to complete an action at some time in the future. The action is atomic and permanent. The idea behind a future is to send an operation for asynchronous completion, do other stuff, then return and retrieve the result of the async operation at a later time. Futures run on the global thread pool.

- -
Feature:
-  As a highly responsive Ruby application
-  I want long-running tasks on a separate thread
-  So I can perform other tasks without waiting
-
- -

Futures have four possible states: :unscheduled, :pending, :rejected, and :fulfilled. When a Future is created it is set to :unscheduled. Once the #execute method is called the state becomes :pending and will remain in that state until processing is complete. A completed Future is either :rejected, indicating that an exception was thrown during processing, or :fulfilled, indicating success. If a Future is :fulfilled its #value will be updated to reflect the result of the operation. If :rejected the reason will be updated with a reference to the thrown exception. The predicate methods #unscheduled?, #pending?, #rejected?, and #fulfilled? can be called at any time to obtain the state of the Future, as can the #state method, which returns a symbol.

- -

Retrieving the value of a Future is done through the #value (alias: #deref) method. Obtaining the value of a Future is a potentially blocking operation. When a Future is :rejected a call to #value will return nil immediately. When a Future is :fulfilled a call to #value will immediately return the current value. When a Future is :pending a call to #value will block until the Future is either :rejected or :fulfilled. A timeout value can be passed to #value to limit how long the call will block. If nil the call will block indefinitely. If 0 the call will not block. Any other integer or float value will indicate the maximum number of seconds to block.

- -

The constructor can also be given zero or more processing options. Currently the only supported options are those recognized by the Dereferenceable module.

- -

The Future class also includes the behavior of the Ruby standard library Observable module, but does so in a thread-safe way. On fulfillment or rejection all observers will be notified according to the normal Observable behavior. The observer callback function will be called with three parameters: the Time of fulfillment/rejection, the final value, and the final reason. Observers added after fulfillment/rejection will still be notified as normal. The notification will occur on the global thread pool.

- -

Examples

- -

A fulfilled example:

- -
require 'concurrent'
-require 'thread'   # for Queue
-require 'open-uri' # for open(uri)
-
-class Ticker
-  def get_year_end_closing(symbol, year)
-    uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
-    data = open(uri) {|f| f.collect{|line| line.strip } }
-    data[1].split(',')[4].to_f
-  end
-end
-
-# Future
-price = Concurrent::Future.execute{ Ticker.new.get_year_end_closing('TWTR', 2013) }
-price.state #=> :pending
-price.pending? #=> true
-price.value(0) #=> nil (does not block)
-
-sleep(1)    # do other stuff
-
-price.value #=> 63.65 (after blocking if neccesary)
-price.state #=> :fulfilled
-price.fulfilled? #=> true
-price.value #=> 63.65
-
- -

A rejected example:

- -
count = Concurrent::Future.execute{ sleep(10); raise StandardError.new("Boom!") }
-count.state #=> :pending
-count.pending? #=> true
-
-count.value #=> nil (after blocking)
-count.rejected? #=> true
-count.reason #=> #<StandardError: Boom!> 
-
- -

An example with observation:

- -
class Ticker
-  Stock = Struct.new(:symbol, :name, :exchange)
-
-  def update(time, value, reason)
-    ticker = value.collect do |symbol|
-      Stock.new(symbol['symbol'], symbol['name'], symbol['exch'])
-    end
-
-    output = ticker.join("\n")
-    print "#{output}\n"
-  end
-end
-
-yahoo = Finance.new('YAHOO')
-future = Concurrent::Future.new { yahoo.update.suggested_symbols }
-future.add_observer(Ticker.new)
-future.execute
-
-# do important stuff...
-
-#>> #<struct Ticker::Stock symbol="YHOO", name="Yahoo! Inc.", exchange="NMS">
-#>> #<struct Ticker::Stock symbol="YHO.DE", name="Yahoo! Inc.", exchange="GER">
-#>> #<struct Ticker::Stock symbol="YAHOY", name="Yahoo Japan Corporation", exchange="PNK">
-#>> #<struct Ticker::Stock symbol="YAHOF", name="YAHOO JAPAN CORP", exchange="PNK">
-#>> #<struct Ticker::Stock symbol="YOJ.SG", name="YAHOO JAPAN", exchange="STU">
-#>> #<struct Ticker::Stock symbol="YHO.SG", name="YAHOO", exchange="STU">
-#>> #<struct Ticker::Stock symbol="YHOO.BA", name="Yahoo! Inc.", exchange="BUE">
-#>> #<struct Ticker::Stock symbol="YHO.DU", name="YAHOO", exchange="DUS">
-#>> #<struct Ticker::Stock symbol="YHO.HM", name="YAHOO", exchange="HAM">
-#>> #<struct Ticker::Stock symbol="YHO.BE", name="YAHOO", exchange="BER">
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.promise.html b/docs/1.0.5/file.promise.html deleted file mode 100644 index 868fb0683..000000000 --- a/docs/1.0.5/file.promise.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - File: promise - - — Concurrent - - - - - - - - - - - - - - - - - - - - - -

Promises are inspired by the JavaScript Promises/A and Promises/A+ specifications.

- -
-

A promise represents the eventual value returned from the single completion of an operation.

-
- -

Promises are similar to futures and share many of the same behaviours. Promises are far more robust, however. Promises can be chained in a tree structure where each promise may have zero or more children. Promises are chained using the then method. The result of a call to then is always another promise. Promises are resolved asynchronously (with respect to the main thread) but in a strict order: parents are guaranteed to be resolved before their children, children before their younger siblings. The then method takes two parameters: an optional block to be executed upon parent resolution and an optional callable to be executed upon parent failure. The result of each promise is passed to each of its children upon resolution. When a promise is rejected all its children will be summarily rejected and will receive the reason.

- -

Promises have four possible states: unscheduled, pending, rejected, and fulfilled. A Promise created using .new will be unscheduled. It is scheduled by calling the execute method. Upon execution the Promise and all its children will be set to pending. When a promise is pending it will remain in that state until processing is complete. A completed Promise is either rejected, indicating that an exception was thrown during processing, or fulfilled, indicating it succeeded. If a Promise is fulfilled its value will be updated to reflect the result of the operation. If rejected the reason will be updated with a reference to the thrown exception. The predicate methods unscheduled?, pending?, rejected?, and fulfilled? can be called at any time to obtain the state of the Promise, as can the state method, which returns a symbol. A Promise created using .execute will be pending, a Promise created using .fulfill(value) will be fulfilled with the given value and a Promise created using .reject(reason) will be rejected with the given reason.

- -

Retrieving the value of a promise is done through the value (alias: deref) method. Obtaining the value of a promise is a potentially blocking operation. When a promise is rejected a call to value will return nil immediately. When a promise is fulfilled a call to value will immediately return the current value. When a promise is pending a call to value will block until the promise is either rejected or fulfilled. A timeout value can be passed to value to limit how long the call will block. If nil the call will block indefinitely. If 0 the call will not block. Any other integer or float value will indicate the maximum number of seconds to block.

- -

Promises run on the global thread pool.

- -

Examples

- -

Start by requiring promises

- -
require 'concurrent'
-
- -

Then create one

- -
p = Promise.execute do
-      # do something
-      42
-    end
-
- -

Promises can be chained using the then method. The then method accepts a block, to be executed on fulfillment, and a callable argument to be executed on rejection. The result of the each promise is passed as the block argument to chained promises.

- -
p = Concurrent::Promise.new{10}.then{|x| x * 2}.then{|result| result - 10 }.execute
-
- -

And so on, and so on, and so on...

- -
p = Concurrent::Promise.fulfill(20).
-    then{|result| result - 10 }.
-    then{|result| result * 3 }.
-    then{|result| result % 5 }.execute
-
- -

The initial state of a newly created Promise depends on the state of its parent:

- -
    -
  • if parent is unscheduled the child will be unscheduled
  • -
  • if parent is pending the child will be pending
  • -
  • if parent is fulfilled the child will be pending
  • -
  • if parent is rejected the child will be pending (but will ultimately be rejected)
  • -
- -

Promises are executed asynchronously from the main thread. By the time a child Promise finishes initialization it may be in a different state that its parent (by the time a child is created its parent may have completed execution and changed state). Despite being asynchronous, however, the order of execution of Promise objects in a chain (or tree) is strictly defined.

- -

There are multiple ways to create and execute a new Promise. Both ways provide identical behavior:

- -
# create, operate, then execute
-p1 = Concurrent::Promise.new{ "Hello World!" }
-p1.state #=> :unscheduled
-p1.execute
-
-# create and immediately execute
-p2 = Concurrent::Promise.new{ "Hello World!" }.execute
-
-# execute during creation
-p3 = Concurrent::Promise.execute{ "Hello World!" }
-
- -

Once the execute method is called a Promise becomes pending:

- -
p = Concurrent::Promise.execute{ "Hello, world!" }
-p.state    #=> :pending
-p.pending? #=> true
-
- -

Wait a little bit, and the promise will resolve and provide a value:

- -
p = Concurrent::Promise.execute{ "Hello, world!" }
-sleep(0.1)
-
-p.state      #=> :fulfilled
-p.fulfilled? #=> true
-p.value      #=> "Hello, world!"
-
- -

If an exception occurs, the promise will be rejected and will provide -a reason for the rejection:

- -
p = Concurrent::Promise.execute{ raise StandardError.new("Here comes the Boom!") }
-sleep(0.1)
-
-p.state     #=> :rejected
-p.rejected? #=> true
-p.reason    #=> "#<StandardError: Here comes the Boom!>"
-
- -

Rejection

- -

When a promise is rejected all its children will be rejected and will receive the rejection reason as the rejection callable parameter:

- -
p = [ Concurrent::Promise.execute{ Thread.pass; raise StandardError } ]
-
-c1 = p.then(Proc.new{ |reason| 42 })
-c2 = p.then(Proc.new{ |reason| raise 'Boom!' })
-
-sleep(0.1)
-
-c1.state  #=> :rejected
-c2.state  #=> :rejected
-
- -

Once a promise is rejected it will continue to accept children that will receive immediately rejection (they will be executed asynchronously).

- -

Aliases

- -

The then method is the most generic alias: it accepts a block to be executed upon parent fulfillment and a callable to be executed upon parent rejection. At least one of them should be passed. The default block is { |result| result } that fulfills the child with the parent value. The default callable is { |reason| raise reason } that rejects the child with the parent reason.

- -
    -
  • on_success { |result| ... } is the same as then {|result| ... }
  • -
  • rescue { |reason| ... } is the same as then(Proc.new { |reason| ... } )
  • -
  • rescue is aliased by catch and on_error
  • -
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.promises.out.html b/docs/1.0.5/file.promises.out.html index 0588a368a..df523e376 100644 --- a/docs/1.0.5/file.promises.out.html +++ b/docs/1.0.5/file.promises.out.html @@ -108,13 +108,13 @@

Factory methods

resolvable_event end end.new.a_method -# => <#Concurrent::Promises::ResolvableEvent:0x7fe34f68af30 pending> +# => <#Concurrent::Promises::ResolvableEvent:0x7fb5e090d308 pending> mod = Module.new do extend Concurrent::Promises::FactoryMethods end mod.resolvable_event -# => <#Concurrent::Promises::ResolvableEvent:0x7fe34f689400 pending> +# => <#Concurrent::Promises::ResolvableEvent:0x7fb5e0907750 pending>

The default executor can be changed by overriding default_executor method @@ -134,7 +134,7 @@

Factory methods

The module is already extended into Concurrent::Promises for convenience.

Concurrent::Promises.resolvable_event
-# => <#Concurrent::Promises::ResolvableEvent:0x7fe34f673560 pending>
+# => <#Concurrent::Promises::ResolvableEvent:0x7fb5e1a6c680 pending>
 

Asynchronous task

@@ -149,7 +149,7 @@

Asynchronous task

sleep duration :result end -# => <#Concurrent::Promises::Future:0x7fe34f66bdd8 pending> +# => <#Concurrent::Promises::Future:0x7fb5e1a64a70 pending>

Asks if the future is resolved, here it will be still in the middle of the @@ -167,7 +167,7 @@

Asynchronous task

If the task fails we talk about the future being rejected.

future = Concurrent::Promises.future { raise 'Boom' }
-# => <#Concurrent::Promises::Future:0x7fe34f662da0 rejected>
+# => <#Concurrent::Promises::Future:0x7fb5e22ca930 rejected>
 

There is no result, the future was rejected with a reason.

@@ -255,19 +255,19 @@

Direct creation of resolved futures

through evaluation as follows.

Concurrent::Promises.future { :value }
-# => <#Concurrent::Promises::Future:0x7fe34f6232b8 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e22a05b8 pending>
 

Instead it can be created directly.

Concurrent::Promises.fulfilled_future(:value)
-# => <#Concurrent::Promises::Future:0x7fe3501ab388 fulfilled>
+# => <#Concurrent::Promises::Future:0x7fb5e38052c8 fulfilled>
 Concurrent::Promises.rejected_future(StandardError.new('Ups'))
-# => <#Concurrent::Promises::Future:0x7fe3501aa348 rejected>
+# => <#Concurrent::Promises::Future:0x7fb5e08f7be8 rejected>
 Concurrent::Promises.resolved_future(true, :value, nil)
-# => <#Concurrent::Promises::Future:0x7fe3501a93d0 fulfilled>
+# => <#Concurrent::Promises::Future:0x7fb5e08f61a8 fulfilled>
 Concurrent::Promises.resolved_future(false, nil, StandardError.new('Ups'))
-# => <#Concurrent::Promises::Future:0x7fe3501a8278 rejected>
+# => <#Concurrent::Promises::Future:0x7fb5e08f4150 rejected>
 

Chaining

@@ -305,9 +305,9 @@

Chaining

arg = 1                                  # => 1
 Thread.new { do_stuff arg }
-# => #<Thread:0x007fe34f603670@promises.in.md:203 run>
+# => #<Thread:0x0000000000000002@promises.in.md:203 run>
 Concurrent::Promises.future { do_stuff arg }
-# => <#Concurrent::Promises::Future:0x7fe34f6021d0 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e11cd010 pending>
 

Branching, and zipping

@@ -366,7 +366,7 @@

Error handling

result # => [false, # nil, -# #<NoMethodError: undefined method `succ' for #<Object:0x007fe34f5e1a48>>] +# #<NoMethodError: undefined method `succ' for #<Object:0x0000000000000003>>]

As then chained tasks execute only on fulfilled futures, there is a rescue @@ -410,7 +410,7 @@

Error handling

rejected_zip = Concurrent::Promises.zip(
     Concurrent::Promises.fulfilled_future(1),
     Concurrent::Promises.rejected_future(StandardError.new('Ups')))
-# => <#Concurrent::Promises::Future:0x7fe34f5b9548 rejected>
+# => <#Concurrent::Promises::Future:0x7fb5e19c6640 rejected>
 rejected_zip.result
 # => [false, [1, nil], [nil, #<StandardError: Ups>]]
 rejected_zip.
@@ -424,11 +424,11 @@ 

Delayed futures

requiring resolution.

future = Concurrent::Promises.delay { sleep 0.1; 'lazy' }
-# => <#Concurrent::Promises::Future:0x7fe34f5aa160 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e19b60d8 pending>
 sleep 0.1 
 future.resolved?                         # => false
 future.touch
-# => <#Concurrent::Promises::Future:0x7fe34f5aa160 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e19b60d8 pending>
 sleep 0.2 
 future.resolved?                         # => true
 
@@ -499,7 +499,7 @@

Scheduling

Schedule task to be executed in 0.1 seconds.

scheduled = Concurrent::Promises.schedule(0.1) { 1 }
-# => <#Concurrent::Promises::Future:0x7fe34f569f70 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e118f670 pending>
 scheduled.resolved?                      # => false
 
@@ -521,7 +521,7 @@

Scheduling

Time can be used as well.

Concurrent::Promises.schedule(Time.now + 10) { :val }
-# => <#Concurrent::Promises::Future:0x7fe350178140 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e1868cd0 pending>
 

Resolvable Future and Event:

@@ -532,14 +532,14 @@

Resolvable Future and Event:

Concurrent::Promises::ResolvableEvent.

future = Concurrent::Promises.resolvable_future
-# => <#Concurrent::Promises::ResolvableFuture:0x7fe34f552758 pending>
+# => <#Concurrent::Promises::ResolvableFuture:0x7fb5e225bf80 pending>
 

The thread will be blocked until the future is resolved

thread = Thread.new { future.value } 
 future.fulfill 1
-# => <#Concurrent::Promises::ResolvableFuture:0x7fe34f552758 fulfilled>
+# => <#Concurrent::Promises::ResolvableFuture:0x7fb5e225bf80 fulfilled>
 thread.value                             # => 1
 
@@ -579,9 +579,9 @@

Advanced

Callbacks

-
queue  = Queue.new                       # => #<Thread::Queue:0x007fe34f53b918>
+
queue  = Queue.new                       # => #<Thread::Queue:0x0000000000000004>
 future = Concurrent::Promises.delay { 1 + 1 }
-# => <#Concurrent::Promises::Future:0x7fe34f53a680 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e222a610 pending>
 
 future.on_fulfillment { queue << 1 } # evaluated asynchronously
 future.on_fulfillment! { queue << 2 } # evaluated on resolving thread
@@ -616,7 +616,7 @@ 

Run (simulated process)

v += 1 v < 5 ? Concurrent::Promises.future_on(:fast, v, &count) : v end -# => #<Proc:0x007fe350158980@promises.in.md:511 (lambda)> +# => #<Proc:0x0000000000000005@promises.in.md:511 (lambda)> 400.times. map { Concurrent::Promises.future_on(:fast, 0, &count).run.value! }. all? { |v| v == 5 } # => true @@ -634,7 +634,7 @@

Actors

actor = Concurrent::Actor::Utils::AdHoc.spawn :square do
   -> v { v ** 2 }
 end
-# => #<Concurrent::Actor::Reference:0x7fe34f668e08 /square (Concurrent::Actor::Utils::AdHoc)>
+# => #<Concurrent::Actor::Reference:0x7fb5e08190f0 /square (Concurrent::Actor::Utils::AdHoc)>
 

Send result of 1+1 to the actor, and add 2 to the result send back from the @@ -660,7 +660,7 @@

Channel

channel with capacity 2 messages.

ch1 = Concurrent::Promises::Channel.new 2
-# => <#Concurrent::Promises::Channel:0x7fe34f648608 size:2>
+# => <#Concurrent::Promises::Channel:0x7fb5e1a74128 size:2>
 

We push 3 messages, it can be observed that the last future representing the @@ -670,14 +670,14 @@

Channel

more messages.

pushes = 3.times.map { |i| ch1.push i }
-# => [<#Concurrent::Promises::Future:0x7fe3501b2098 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe3501b1af8 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe3501b0fe0 pending>]
+# => [<#Concurrent::Promises::Future:0x7fb5e1a6d3a0 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a6cae0 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a67ab8 pending>]
 ch1.pop.value!                           # => 0
 pushes
-# => [<#Concurrent::Promises::Future:0x7fe3501b2098 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe3501b1af8 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe3501b0fe0 fulfilled>]
+# => [<#Concurrent::Promises::Future:0x7fb5e1a6d3a0 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a6cae0 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a67ab8 fulfilled>]
 

A selection over channels can be created with select_channel factory method. It @@ -685,19 +685,19 @@

Channel

returns a pair to be able to find out which channel had the message available.

ch2    = Concurrent::Promises::Channel.new 2
-# => <#Concurrent::Promises::Channel:0x7fe34f633078 size:2>
+# => <#Concurrent::Promises::Channel:0x7fb5e22c8bd0 size:2>
 result = Concurrent::Promises.select_channel(ch1, ch2)
-# => <#Concurrent::Promises::ResolvableFuture:0x7fe34f631f70 fulfilled>
+# => <#Concurrent::Promises::ResolvableFuture:0x7fb5e22c3d38 fulfilled>
 result.value!
-# => [<#Concurrent::Promises::Channel:0x7fe34f648608 size:2>, 1]
+# => [<#Concurrent::Promises::Channel:0x7fb5e1a74128 size:2>, 1]
 
 Concurrent::Promises.future { 1+1 }.then_push_channel(ch1)
-# => <#Concurrent::Promises::Future:0x7fe34f629f50 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e1a5d860 pending>
 result = (
     Concurrent::Promises.fulfilled_future('%02d') &      
         Concurrent::Promises.select_channel(ch1, ch2)).
     then { |format, (channel, value)| format format, value }
-# => <#Concurrent::Promises::Future:0x7fe34f622a70 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e22b9f90 pending>
 result.value!                            # => "02"
 
@@ -715,7 +715,7 @@

ProcessingActor

actor = Concurrent::ProcessingActor.act(an_argument = 2) do |actor, number|
   number ** 3
 end
-# => <#Concurrent::ProcessingActor:0x7fe3501a9740 termination:pending>
+# => <#Concurrent::ProcessingActor:0x7fb5e1a54490 termination:pending>
 actor.termination.value!                 # => 8
 
@@ -728,10 +728,10 @@

ProcessingActor

end end add_2_messages.tell 1 -# => <#Concurrent::Promises::Future:0x7fe34f619240 pending> +# => <#Concurrent::Promises::Future:0x7fb5e1a44518 pending> add_2_messages.termination.resolved? # => false add_2_messages.tell 3 -# => <#Concurrent::Promises::Future:0x7fe34f612828 pending> +# => <#Concurrent::Promises::Future:0x7fb5e22a9e10 pending> add_2_messages.termination.value! # => 4
@@ -755,7 +755,7 @@

ProcessingActor

Concurrent::Promises::Channel.new(2), 0, &slow_counter) -# => <#Concurrent::ProcessingActor:0x7fe350189da0 termination:pending> +# => <#Concurrent::ProcessingActor:0x7fb5e11dd960 termination:pending>

Now we can create a producer which will push messages only when there is a @@ -777,7 +777,7 @@

ProcessingActor

end Concurrent::Promises.future(actor, 0, &produce).run.wait! -# => <#Concurrent::Promises::Future:0x7fe34f5e8780 fulfilled> +# => <#Concurrent::Promises::Future:0x7fb5e1a1fd80 fulfilled> actor.termination.value! # => 45
@@ -787,16 +787,16 @@

Use-cases

Simple background processing

Concurrent::Promises.future { do_stuff }
-# => <#Concurrent::Promises::Future:0x7fe34f593e60 pending>
+# => <#Concurrent::Promises::Future:0x7fb5e19cff88 pending>
 

Parallel background processing

tasks = 4.times.map { |i| Concurrent::Promises.future(i) { |i| i*2 } }
-# => [<#Concurrent::Promises::Future:0x7fe34f58bd28 pending>,
-#     <#Concurrent::Promises::Future:0x7fe34f58add8 pending>,
-#     <#Concurrent::Promises::Future:0x7fe34f589e88 pending>,
-#     <#Concurrent::Promises::Future:0x7fe34f588f38 pending>]
+# => [<#Concurrent::Promises::Future:0x7fb5e19cc450 pending>,
+#     <#Concurrent::Promises::Future:0x7fb5e229b428 pending>,
+#     <#Concurrent::Promises::Future:0x7fb5e229a0a0 pending>,
+#     <#Concurrent::Promises::Future:0x7fb5e2298480 pending>]
 Concurrent::Promises.zip(*tasks).value!
 # => [0, 2, 4, 6]
 
@@ -848,11 +848,11 @@

Actor background processing

Create the computer actor and send it 3 jobs.

computer = Concurrent::Actor.spawn Computer, :computer
-# => #<Concurrent::Actor::Reference:0x7fe34f540d78 /computer (Computer)>
+# => #<Concurrent::Actor::Reference:0x7fb5e11a6b90 /computer (Computer)>
 results = 3.times.map { computer.ask [:run, -> { sleep 0.1; :result }] }
-# => [<#Concurrent::Promises::Future:0x7fe34f4834f8 pending>,
-#     <#Concurrent::Promises::Future:0x7fe34f4824b8 pending>,
-#     <#Concurrent::Promises::Future:0x7fe34f4814a0 pending>]
+# => [<#Concurrent::Promises::Future:0x7fb5e1873d38 pending>,
+#     <#Concurrent::Promises::Future:0x7fb5e1872cd0 pending>,
+#     <#Concurrent::Promises::Future:0x7fb5e1871a88 pending>]
 computer.ask(:status).value!             # => {:running_jobs=>3}
 results.map(&:value!)                    # => [:result, :result, :result]
 
@@ -900,8 +900,8 @@

Simple

Lets have two processes which will count until cancelled.

source, token = Concurrent::Cancellation.create
-# => [<#Concurrent::Cancellation:0x7fe34e850708 canceled:false>,
-#     <#Concurrent::Cancellation::Token:0x7fe350120a08 canceled:false>]
+# => [<#Concurrent::Cancellation:0x7fb5e182ea80 canceled:false>,
+#     <#Concurrent::Cancellation::Token:0x7fb5e182dbf8 canceled:false>]
 
 count_until_cancelled = -> token, count do
   if token.canceled?
@@ -914,12 +914,12 @@ 

Simple

futures = Array.new(2) do Concurrent::Promises.future(token, 0, &count_until_cancelled).run end -# => [<#Concurrent::Promises::Future:0x7fe350109c68 pending>, -# <#Concurrent::Promises::Future:0x7fe350102238 pending>] +# => [<#Concurrent::Promises::Future:0x7fb5e1826f88 pending>, +# <#Concurrent::Promises::Future:0x7fb5e18249b8 pending>] sleep 0.01 source.cancel # => true -futures.map(&:value!) # => [56, 55] +futures.map(&:value!) # => [53, 53]

Cancellation can also be used as event or future to log or plan re-execution.

@@ -936,8 +936,8 @@

Parallel background processing with cancellation

tasks share a cancellation, when one of them fails it cancels the others.

source, token = Concurrent::Cancellation.create
-# => [<#Concurrent::Cancellation:0x7fe34f75ba90 canceled:false>,
-#     <#Concurrent::Cancellation::Token:0x7fe34f75b248 canceled:false>]
+# => [<#Concurrent::Cancellation:0x7fb5e22abdf0 canceled:false>,
+#     <#Concurrent::Cancellation::Token:0x7fb5e22ab5f8 canceled:false>]
 tasks = 4.times.map do |i|
   Concurrent::Promises.future(source, token, i) do |source, token, i|
     count = 0
@@ -953,21 +953,21 @@ 

Parallel background processing with cancellation

end end end -# => [<#Concurrent::Promises::Future:0x7fe34f7580c0 pending>, -# <#Concurrent::Promises::Future:0x7fe34f7530c0 pending>, -# <#Concurrent::Promises::Future:0x7fe34f7512e8 pending>, -# <#Concurrent::Promises::Future:0x7fe34f750208 pending>] +# => [<#Concurrent::Promises::Future:0x7fb5e22a81c8 pending>, +# <#Concurrent::Promises::Future:0x7fb5e22a3218 pending>, +# <#Concurrent::Promises::Future:0x7fb5e22a1d28 pending>, +# <#Concurrent::Promises::Future:0x7fb5e22a0658 pending>] Concurrent::Promises.zip(*tasks).result # => [false, -# [:cancelled, nil, :cancelled, :cancelled], -# [nil, #<RuntimeError: random error>, nil, nil]] +# [nil, :cancelled, nil, :cancelled], +# [#<RuntimeError: random error>, nil, #<RuntimeError: random error>, nil]]

Without the randomly failing part it produces following.

source, token = Concurrent::Cancellation.create
-# => [<#Concurrent::Cancellation:0x7fe34f7334a0 canceled:false>,
-#     <#Concurrent::Cancellation::Token:0x7fe34f732ca8 canceled:false>]
+# => [<#Concurrent::Cancellation:0x7fb5e1a2cd00 canceled:false>,
+#     <#Concurrent::Cancellation::Token:0x7fb5e1a2c2d8 canceled:false>]
 tasks = 4.times.map do |i|
   Concurrent::Promises.future(source, token, i) do |source, token, i|
     count = 0
@@ -1074,7 +1074,7 @@ 

Throttling concurrency

# "*********"] max_tree = Concurrent::Throttle.new 3 -# => <#Concurrent::Throttle:0x7fe34f5f0c28 limit:3 can_run:3> +# => <#Concurrent::Throttle:0x7fb5e21d3360 limit:3 can_run:3> futures = 11.times.map do |i| max_tree. @@ -1098,10 +1098,10 @@

Long stream of tasks, applying back pressure

require 'json' 
 
 channel       = Concurrent::Promises::Channel.new 6
-# => <#Concurrent::Promises::Channel:0x7fe34e883ae0 size:6>
+# => <#Concurrent::Promises::Channel:0x7fb5e11e4e90 size:6>
 source, token = Concurrent::Cancellation.create
-# => [<#Concurrent::Cancellation:0x7fe34e880098 canceled:false>,
-#     <#Concurrent::Cancellation::Token:0x7fe34e878528 canceled:false>]
+# => [<#Concurrent::Cancellation:0x7fb5e11de9a0 canceled:false>,
+#     <#Concurrent::Cancellation::Token:0x7fb5e11ddc58 canceled:false>]
 
 def query_random_text(token, channel)
   Concurrent::Promises.future do
@@ -1128,7 +1128,7 @@ 

Long stream of tasks, applying back pressure

words = [] # => [] words_throttle = Concurrent::Throttle.new 1 -# => <#Concurrent::Throttle:0x7fe34e875508 limit:1 can_run:1> +# => <#Concurrent::Throttle:0x7fb5e1a37d90 limit:1 can_run:1> def count_words_in_random_text(token, channel, words, words_throttle) channel.pop.then do |response| @@ -1150,18 +1150,18 @@

Long stream of tasks, applying back pressure

query_processes = 3.times.map do Concurrent::Promises.future(token, channel, &method(:query_random_text)).run end -# => [<#Concurrent::Promises::Future:0x7fe350112638 pending>, -# <#Concurrent::Promises::Future:0x7fe350108098 pending>, -# <#Concurrent::Promises::Future:0x7fe350100870 pending>] +# => [<#Concurrent::Promises::Future:0x7fb5e1a2e128 pending>, +# <#Concurrent::Promises::Future:0x7fb5e1a279b8 pending>, +# <#Concurrent::Promises::Future:0x7fb5e1a25820 pending>] word_counter_processes = 2.times.map do Concurrent::Promises.future(token, channel, words, words_throttle, &method(:count_words_in_random_text)).run end -# => [<#Concurrent::Promises::Future:0x7fe3500eabd8 pending>, -# <#Concurrent::Promises::Future:0x7fe3500e0c28 pending>] +# => [<#Concurrent::Promises::Future:0x7fb5e11ccf70 pending>, +# <#Concurrent::Promises::Future:0x7fb5e11c6b48 pending>] -sleep 0.5 # => 0 +sleep 0.5 # => 1

Let it run for a while then cancel it and ensure that the runs all fulfilled @@ -1169,12 +1169,12 @@

Long stream of tasks, applying back pressure

source.cancel                            # => true
 query_processes.map(&:wait!) 
-# => [<#Concurrent::Promises::Future:0x7fe350112638 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe350108098 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe350100870 fulfilled>]
+# => [<#Concurrent::Promises::Future:0x7fb5e1a2e128 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a279b8 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e1a25820 fulfilled>]
 word_counter_processes.map(&:wait!)
-# => [<#Concurrent::Promises::Future:0x7fe3500eabd8 fulfilled>,
-#     <#Concurrent::Promises::Future:0x7fe3500e0c28 fulfilled>]
+# => [<#Concurrent::Promises::Future:0x7fb5e11ccf70 fulfilled>,
+#     <#Concurrent::Promises::Future:0x7fb5e11c6b48 fulfilled>]
 words                                    # => [7, 7, 7, 7]
 
@@ -1196,8 +1196,8 @@

Periodic task

end cancellation, token = Concurrent::Cancellation.create -# => [<#Concurrent::Cancellation:0x7fe34f21a658 canceled:false>, -# <#Concurrent::Cancellation::Token:0x7fe34f219370 canceled:false>] +# => [<#Concurrent::Cancellation:0x7fb5e222a7c8 canceled:false>, +# <#Concurrent::Cancellation::Token:0x7fb5e2228b80 canceled:false>] task = -> token do 5.times do @@ -1209,7 +1209,7 @@

Periodic task

end result = Concurrent::Promises.future(0.1, token, task, &repeating_scheduled_task).run -# => <#Concurrent::Promises::Future:0x7fe34f81bde0 pending> +# => <#Concurrent::Promises::Future:0x7fb5e1987968 pending> sleep 0.2 # => 0 cancellation.cancel # => true result.result @@ -1220,9 +1220,9 @@

Periodic task

- - - - - - - - - - - - - -

ScheduledTask is a close relative of Concurrent::Future but with one important difference. A Future is set to execute as soon as possible whereas a ScheduledTask is set to execute at a specific time. This implementation is loosely based on Java's ScheduledExecutorService.

- -

Example

- -
require 'concurrent'
-require 'thread'   # for Queue
-require 'open-uri' # for open(uri)
-
-class Ticker
-  def get_year_end_closing(symbol, year)
-    uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
-    data = open(uri) {|f| f.collect{|line| line.strip } }
-    data[1].split(',')[4].to_f
-  end
-end
-
-# Future
-price = Concurrent::Future.execute{ Ticker.new.get_year_end_closing('TWTR', 2013) }
-price.state #=> :pending
-sleep(1)    # do other stuff
-price.value #=> 63.65
-price.state #=> :fulfilled
-
-# ScheduledTask
-task = Concurrent::ScheduledTask.execute(2){ Ticker.new.get_year_end_closing('INTC', 2013) }
-task.state #=> :pending
-sleep(3)   # do other stuff
-task.value #=> 25.96
-
- -

Scheduling

- -

The intended schedule time of task execution is set on object construction with first argument. The time can be a numeric (floating point or integer) representing a number of seconds in the future or it can ba a Time object representing the approximate time of execution. Any other value, a numeric equal to or less than zero, or a time in the past will result in an exception.

- -

The actual schedule time of task execution is set when the execute method is called. If the intended schedule time was given as a number of seconds then the actual schedule time will be calculated from the current time. If the intended schedule time was given as a Time object the current time will be checked against the intended schedule time. If the intended schedule time is now in the past an exception will be raised.

- -

The constructor can also be given zero or more processing options. Currently the only supported options are those recognized by the Dereferenceable module.

- -

The final constructor argument is a block representing the task to be performed at the scheduled time. If no block is given an ArgumentError will be raised.

- -

States

- -

ScheduledTask mixes in the Obligation module thus giving it "future" behavior. This includes the expected lifecycle states. ScheduledTask has one additional state, however. While the task (block) is being executed the state of the object will be :in_progress. This additional state is necessary because it has implications for task cancellation.

- -

Cancellation

- -

A :pending task can be cancelled using the #cancel method. A task in any other state, including :in_progress, cannot be cancelled. The #cancel method returns a boolean indicating the success of the cancellation attempt. A cancelled ScheduledTask cannot be restarted. It is immutable.

- -

Obligation and Observation

- -

The result of a ScheduledTask can be obtained either synchronously or asynchronously. ScheduledTask mixes in both the Obligation module and the Observable module from the Ruby standard library. With one exception ScheduledTask behaves identically to Future with regard to these modules.

- -

Unlike Future, however, an observer added to a ScheduledTask after the task operation has completed will not receive notification. The reason for this is the subtle but important difference in intent between the two abstractions. With a Future there is no way to know when the operation will complete. Therefore the expected behavior of an observer is to be notified. With a ScheduledTask however, the approximate time of execution is known. It is often explicitly set as a constructor argument. It is always available via the #schedule_time attribute reader. Therefore it is always possible for calling code to know whether the observer is being added prior to task execution. It is also easy to add an observer long before task execution begins (since there is never a reason to create a scheduled task that starts immediately). Subsequently, the expectation is that the caller of #add_observer is making the call within an appropriate time.

- -

Examples

- -

Successful task execution using seconds for scheduling:

- -
require 'concurrent'
-
-task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }
-task.state         #=> :unscheduled
-task.schedule_time #=> nil
-task.execute
-task.state         #=> pending
-task.schedule_time #=> 2013-11-07 12:20:07 -0500
-
-# wait for it...
-sleep(3)
-
-task.unscheduled? #=> false
-task.pending?     #=> false
-task.fulfilled?   #=> true
-task.rejected?    #=> false
-task.value        #=> 'What does the fox say?'
-
- -

A ScheduledTask can be created and executed in one line:

- -
task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }.execute
-task.state         #=> pending
-task.schedule_time #=> 2013-11-07 12:20:07 -0500
-
- -

Failed task execution using a Time object for scheduling:

- -
t = Time.now + 2
-task = Concurrent::ScheduledTask.execute(t){ raise StandardError.new('Call me maybe?') }
-task.pending?      #=> true
-task.schedule_time #=> 2013-11-07 12:22:01 -0500
-
-# wait for it...
-sleep(3)
-
-task.unscheduled? #=> false
-task.pending?     #=> false
-task.fulfilled?   #=> false
-task.rejected?    #=> true
-task.value        #=> nil
-task.reason       #=> #<StandardError: Call me maybe?> 
-
- -

An exception will be thrown on creation if the schedule time is in the past:

- -
task = Concurrent::ScheduledTask.new(Time.now - 10){ nil }
-  #=> ArgumentError: schedule time must be in the future
-
-task = Concurrent::ScheduledTask.execute(-10){ nil }
-  #=> ArgumentError: seconds must be greater than zero
-
- -

An exception will also be thrown when #execute is called if the current time has -progressed past the intended schedule time:

- -
task = Concurrent::ScheduledTask.new(Time.now + 10){ nil }
-sleep(20)
-
-task.execute
-  #=> ArgumentError: schedule time must be in the future
-
- -

Task execution with observation:

- -
observer = Class.new{
-  def update(time, value, reason)
-    puts "The task completed at #{time} with value '#{value}'"
-  end
-}.new
-
-task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }
-task.add_observer(observer)
-task.execute
-task.pending?      #=> true
-task.schedule_time #=> 2013-11-07 12:20:07 -0500
-
-# wait for it...
-sleep(3)
-
-#>> The task completed at 2013-11-07 12:26:09 -0500 with value 'What does the fox say?'
-
-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/file.thread_pools.html b/docs/1.0.5/file.thread_pools.html index 8ac36ad3a..4481e6c9c 100644 --- a/docs/1.0.5/file.thread_pools.html +++ b/docs/1.0.5/file.thread_pools.html @@ -242,9 +242,9 @@

Forking

- - - - - - - - - - - - - -

TVar and atomically implement a software transactional memory. A TVar is a single -item container that always contains exactly one value. The atomically method -allows you to modify a set of TVar objects with the guarantee that all of the -updates are collectively atomic - they either all happen or none of them do - -consistent - a TVar will never enter an illegal state - and isolated - atomic -blocks never interfere with each other when they are running. You may recognise -these properties from database transactions.

- -

There are some very important and unusual semantics that you must be aware of:

- -
    -
  • Most importantly, the block that you pass to atomically may be executed more -than once. In most cases your code should be free of side-effects, except for -via TVar.

  • -
  • If an exception escapes an atomically block it will abort the transaction.

  • -
  • It is undefined behaviour to use callcc or Fiber with atomically.

  • -
  • If you create a new thread within an atomically, it will not be part of -the transaction. Creating a thread counts as a side-effect.

  • -
- -

We implement nested transactions by flattening.

- -

We only support strong isolation if you use the API correctly. In order words, -we do not support strong isolation.

- -

Our implementation uses a very simple two-phased locking with versioned locks algorithm, as per [1]. In the future we will look at more advanced algorithms, contention management and using existing Java implementations when in JRuby.

- -

See:

- -
    -
  1. T. Harris, J. Larus, and R. Rajwar. Transactional Memory. Morgan & Claypool, second edition, 2010.
  2. -
- -

Motivation

- -

Consider an application that transfers money between bank accounts. We want to -transfer money from one account to another. It is very important that we don't -lose any money! But it is also important that we can handle many account -transfers at the same time, so we run them concurrently, and probably also in -parallel.

- -

This code shows us transferring ten pounds from one account to another.

- -
a = BankAccount.new(100_000)
-b = BankAccount.new(100)
-
-a.value -= 10
-b.value += 10
-
- -

Before we even start to talk about to talk about concurrency and parallelism, is -this code safe? What happens if after removing money from account a, we get an -exception? It's a slightly contrived example, but if the account totals were -very large, adding to them could involve the stack allocation of a BigNum, and -so could cause out of memory exceptions. In that case the money would have -disappeared from account a, but not appeared in account b. Disaster!

- -

So what do we really need to do?

- -
a = BankAccount.new(100_000)
-b = BankAccount.new(100)
-
-original_a = a.value
-a.value -= 10
-
-begin
-  b.value += 10
-rescue e =>
-  a.value = original_a
-  raise e
-end
-
- -

This rescues any exceptions raised when setting b and will roll back the change -we have already made to b. We'll keep this rescue code in mind, but we'll leave -it out of future examples for simplicity.

- -

That might have made the code work when it only runs sequentially. Lets start to -consider some concurrency. It's obvious that we want to make the transfer of -money mutually exclusive with any other transfers - in order words it is a -critical section.

- -

The usual solution to this would be to use a lock.

- -
lock.synchronize do
-  a.value -= 10
-  b.value += 10
-end
-
- -

That should work. Except we said we'd like these transfer to run concurrently, -and in parallel. With a single lock like that we'll only let one transfer take -place at a time. Perhaps we need more locks? We could have one per account:

- -
a.lock.synchronize do
-  b.lock.synchronize do
-    a.value -= 10
-    b.value += 10
-  end
-end
-
- -

However this is vulnerable to deadlock. If we tried to transfer from a to b, at -the same time as from b to a, it's possible that the first transfer locks a, the -second transfer locks b, and then they both sit there waiting forever to get the -other lock. Perhaps we can solve that by applying a total ordering to the locks -and always acquire them in the same order?

- -
locks_needed = [a.lock, b.lock]
-locks_in_order = locks_needed.sort{ |x, y| x.number <=> y.number }
-
-locks_in_order[0].synchronize do
-  locks_in_order[1].synchronize do
-    a.value -= 10
-    b.value += 10
-  end
-end
-
- -

That might work. But we need to know exactly what locks we're going to need -before we start. If there were conditions in side the transfer this might be -more complicated. We also need to remember the rescue code we had above to deal -with exceptions. This is getting out of hand - and it's where TVar comes in.

- -

We'll model the accounts as TVar - transactional variable, and instead of -locks we'll use Concurrent::atomically.

- -
a = TVar.new(100_000)
-b = TVar.new(100)
-
-Concurrent::atomically do
-  a.value -= 10
-  b.value += 10
-end
-
- -

That short piece of code effectively solves all the concerns we identified -above. How it does it is described in the reference above. You just need to be -happy that any two atomically blocks (we call them transactions) that use an -overlapping set of TVar objects will appear to have happened as if there was a -big global lock on them, and that if any exception is raised in the block, it -will be as if the block never happened. But also keep in mind the important -points we detailed right at the start of the article about side effects and -repeated execution.

- -

Evaluation

- -

We evaluated the performance of our TVar implementation using a bank account simulation with a range of synchronisation implementations. The simulation maintains a set of bank account totals, and runs transactions that either get a summary statement of multiple accounts (a read-only operation) or transfers a sum from one account to another (a read-write operation).

- -

We implemented a bank that does not use any synchronisation (and so creates inconsistent totals in accounts), one that uses a single global (or 'coarse') lock (and so won't scale at all), one that uses one lock per account (and so has a complicated system for locking in the correct order) and one using our TVar and atomically.

- -

We ran 1 million transactions divided equally between a varying number of threads on a system that has at least that many physical cores. The transactions are made up of a varying mixture of read-only and read-write transactions. We ran each set of transactions thirty times, discarding the first ten and then taking an algebraic mean. These graphs show only the simple mean. Our tvars-experiments branch includes the benchmark used, full details of the test system, and all the raw data.

- -

Using JRuby using 75% read-write transactions, we can compare how the different implementations of bank accounts scales to more cores. That is, how much faster it runs if you use more cores.

- -

- -

We see that the coarse lock implementation does not scale at all, and in fact with more cores only wastes more time in contention for the single global lock. We see that the unsynchronised implementation doesn't seem to scale well - which is strange as there should be no overhead, but we'll explain that in a second. We see that the fine lock implementation seems to scale better, and that the TVar implementation scales the best.

- -

So the TVar implementation scales very well, but how absolutely fast is it?

- -

- -

Well, that's the downside. The unsynchronised implementation doesn't scale well because it's so fast in the first place, and probably because we're bound on access to the memory - the threads don't have much work to do, so no matter how many threads we have the system is almost always reaching out to the L3 cache or main memory. However remember that the unsynchronised implementation isn't correct - the totals are wrong at the end. The coarse lock implementation has an overhead of locking and unlocking. The fine lock implementation has a greater overhead as as the locking scheme is complicated to avoid deadlock. It scales better, however, actually allowing transactions to be processed in parallel. The TVar implementation has a greater overhead still - and it's pretty huge. That overhead is the cost for the simple programming model of an atomic block.

- -

So that's what TVar gives you at the moment - great scalability, but it has a high overhead. That's pretty much the state of software transactional memory in general. Perhaps hardware transactional memory will help us, or perhaps we're happy anyway with the simpler and safer programming model that the TVar gives us.

- -

We can also use this experiment to compare different implementations of Ruby. We looked at just the TVar implementation and compared MRI 2.1.1, Rubinius 2.2.6, and JRuby 1.7.11, again at 75% write transactions.

- -

- -

We see that MRI provides no scalability, due to the global interpreter lock (GIL). JRuby seems to scale better than Rubinius for this workload (there are of course other workloads).

- -

As before we should also look at the absolute performance, not just the scalability.

- -

- -

Again, JRuby seems to be faster than Rubinius for this experiment. Interestingly, Rubinius looks slower than MRI for 1 core, but we can get around that by using more cores.

- -

We've used 75% read-write transactions throughout. We'll just take a quick look at how the scalability varies for different workloads, for scaling between 1 and 2 threads. We'll admit that we used 75% read-write just because it emphasised the differences.

- -

- -

Finally, we can also run on a larger machine. We repeated the experiment using a machine with 64 physical cores and JRuby.

- -

- -

- -

Here you can see that TVar does become absolutely faster than using a global lock, at the slightly ridiculously thread-count of 50. It's probably not statistically significant anyway.

-
- - - - - - - \ No newline at end of file diff --git a/docs/1.0.5/index.html b/docs/1.0.5/index.html index 267a5a88b..6ba5dde16 100644 --- a/docs/1.0.5/index.html +++ b/docs/1.0.5/index.html @@ -5,9 +5,9 @@ File: README - + — Concurrent - + @@ -30,31 +30,31 @@ @@ -82,7 +82,7 @@ Java, and classic concurrency patterns.

-

+

The design goals of this gem are:

@@ -113,22 +113,22 @@

Thread Safety

Features & Documentation

-

The primary site for documentation is the automatically generated API documentation

+

The primary site for documentation is the automatically generated API documentation

We also have a mailing list and IRC (gitter).

General-purpose Concurrency Abstractions

    -
  • Async: A mixin module that provides simple asynchronous behavior to a class. Loosely based on Erlang's gen_server.
  • -
  • Future: An asynchronous operation that produces a value. +
  • Async.
  • +
  • Future: An asynchronous operation that produces a value.
      -
    • Dataflow: Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
    • +
    • .dataflow: Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
  • -
  • Promise: Similar to Futures, with more features.
  • -
  • ScheduledTask: Like a Future scheduled for a specific future time.
  • -
  • TimerTask: A Thread that periodically wakes up to perform work at regular intervals.
  • +
  • Promise: Similar to Futures, with more features.
  • +
  • ScheduledTask: Like a Future scheduled for a specific future time.
  • +
  • TimerTask: A Thread that periodically wakes up to perform work at regular intervals.

Thread-safe Value Objects, Structures, and Collections

@@ -136,58 +136,58 @@

Thread-safe Value Objects, Structures, and Collections

Collection classes that were originally part of the (deprecated) thread_safe gem:

    -
  • Array A thread-safe subclass of Ruby's standard Array.
  • -
  • Hash A thread-safe subclass of Ruby's standard Hash.
  • -
  • Map A hash-like object that should have much better performance characteristics, especially under high concurrency, than Concurrent::Hash.
  • -
  • Tuple A fixed size array with volatile (synchronized, thread safe) getters/setters.
  • +
  • Array.
  • +
  • Hash.
  • +
  • Map A hash-like object that should have much better performance characteristics, especially under high concurrency, than Concurrent::Hash.
  • +
  • Tuple getters/setters.

Value objects inspired by other languages:

    -
  • Maybe A thread-safe, immutable object representing an optional value, based on +
  • Maybe A thread-safe, immutable object representing an optional value, based on Haskell Data.Maybe.
  • -
  • Delay Lazy evaluation of a block yielding an immutable result. Based on Clojure's delay.
  • +
  • Delay.

Structure classes derived from Ruby's Struct:

    -
  • ImmutableStruct Immutable struct where values are set at construction and cannot be changed later.
  • -
  • MutableStruct Synchronized, mutable struct where values can be safely changed at any time.
  • -
  • SettableStruct Synchronized, write-once struct where values can be set at most once, either at construction or any time thereafter.
  • +
  • ImmutableStruct Immutable struct where values are set at construction and cannot be changed later.
  • +
  • MutableStruct Synchronized, mutable struct where values can be safely changed at any time.
  • +
  • SettableStruct Synchronized, write-once struct where values can be set at most once, either at construction or any time thereafter.

Thread-safe variables:

    -
  • Agent: A way to manage shared, mutable, asynchronous, independent state. Based on Clojure's Agent.
  • -
  • Atom: A way to manage shared, mutable, synchronous, independent state. Based on Clojure's Atom.
  • -
  • AtomicBoolean A boolean value that can be updated atomically.
  • -
  • AtomicFixnum A numeric value that can be updated atomically.
  • -
  • AtomicReference An object reference that may be updated atomically.
  • -
  • Exchanger A synchronization point at which threads can pair and swap elements within pairs. Based on Java's Exchanger.
  • -
  • MVar A synchronized single element container. Based on Haskell's MVar and Scala's MVar.
  • -
  • ThreadLocalVar A variable where the value is different for each thread.
  • -
  • TVar A transactional variable implementing software transactional memory (STM). Based on Clojure's Ref.
  • +
  • Agent.
  • +
  • Atom.
  • +
  • AtomicBoolean A boolean value that can be updated atomically.
  • +
  • AtomicFixnum A numeric value that can be updated atomically.
  • +
  • AtomicReference An object reference that may be updated atomically.
  • +
  • Exchanger.
  • +
  • MVar.
  • +
  • ThreadLocalVar A variable where the value is different for each thread.
  • +
  • TVar.

Java-inspired ThreadPools and Other Executors

    -
  • See the thread pool overview, which also contains a list of other Executors available.
  • +
  • See the thread pool overview, which also contains a list of other Executors available.

Thread Synchronization Classes and Algorithms

    -
  • CountDownLatch A synchronization object that allows one thread to wait on multiple other threads.
  • -
  • CyclicBarrier A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
  • -
  • Event Old school kernel-style event.
  • -
  • IVar Similar to a "future" but can be manually assigned once, after which it becomes immutable.
  • -
  • ReadWriteLock A lock that supports multiple readers but only one writer.
  • -
  • ReentrantReadWriteLock A read/write lock with reentrant and upgrade features.
  • -
  • Semaphore A counting-based locking mechanism that uses permits.
  • +
  • CountDownLatch A synchronization object that allows one thread to wait on multiple other threads.
  • +
  • CyclicBarrier A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
  • +
  • Event Old school kernel-style event.
  • +
  • IVar Similar to a "future" but can be manually assigned once, after which it becomes immutable.
  • +
  • ReadWriteLock A lock that supports multiple readers but only one writer.
  • +
  • ReentrantReadWriteLock A read/write lock with reentrant and upgrade features.
  • +
  • Semaphore A counting-based locking mechanism that uses permits.

Edge Features

@@ -199,21 +199,21 @@

Edge Features

be obeyed though. Features developed in concurrent-ruby-edge are expected to move to concurrent-ruby when final.

Statuses:

@@ -221,7 +221,7 @@

Statuses:

Why are these not in core?

    -
  • Promises Framework - They are being finalized to be able to be moved to core. They'll deprecate old +
  • Promises - They are being finalized to be able to be moved to core. They'll deprecate old implementation.
  • Actor - Partial documentation and tests; depends on new future/promise framework; stability is good.
  • Channel - Brand new implementation; partial documentation and tests; stability is good.
  • @@ -328,9 +328,9 @@

    License and Copyright

    - + \ No newline at end of file diff --git a/docs/1.0.5/root/Concurrent.html b/docs/1.0.5/root/Concurrent.html index 3468d8a6f..8672ed1ed 100644 --- a/docs/1.0.5/root/Concurrent.html +++ b/docs/1.0.5/root/Concurrent.html @@ -3897,9 +3897,9 @@

    - - - - - - - - - - - -
    - - -

    Class: ProcessingActor - - - -

    -
    - -
    -
    Inherits:
    -
    - Synchronization::Object - -
      -
    • Object
    • - - - - - -
    - show all - -
    -
    - - - - - - - - - - - -
    -
    Defined in:
    -
    lib/concurrent/edge/processing_actor.rb
    -
    - -
    - - - - - - - - - -

    - Class Method Summary - collapse -

    - - - -

    - Instance Method Summary - collapse -

    - - - - - -
    -

    Constructor Details

    - -
    -

    - - #initialize(channel = Promises::Channel.new) ⇒ (ProcessingActor) - - - - - -

    -
    -

    Returns a new instance of ProcessingActor

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -8
    -9
    -10
    -11
    -12
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 8
    -
    -def initialize(channel = Promises::Channel.new)
    -  @Mailbox              = channel
    -  @Terminated           = Promises.resolvable_future
    -  super()
    -end
    -
    -
    - -
    - - -
    -

    Class Method Details

    - - -
    -

    - - .act(*args, &process) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -22
    -23
    -24
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 22
    -
    -def self.act(*args, &process)
    -  act_on Promises::Channel.new, *args, &process
    -end
    -
    -
    - -
    -

    - - .act_on(channel, *args, &process) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -26
    -27
    -28
    -29
    -30
    -31
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 26
    -
    -def self.act_on(channel, *args, &process)
    -  actor  = ProcessingActor.new channel
    -  future = Promises.future(actor, *args, &process)
    -  future.run.chain_resolvable(actor.instance_variable_get(:@Terminated))
    -  actor
    -end
    -
    -
    - -
    - -
    -

    Instance Method Details

    - - -
    -

    - - #ask(*message, probe: Promises.resolvable_future) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 47
    -
    -def ask(*message, probe: Promises.resolvable_future)
    -  tell *message, probe
    -  (probe | @Terminated).chain do |fulfilled, value, reason|
    -    if @Terminated.resolved?
    -      raise @Terminated.fulfilled? ? 'actor terminated before answering' : @Terminated
    -    else
    -      fulfilled ? value : raise(reason)
    -    end
    -  end
    -end
    -
    -
    - -
    -

    - - #inspect ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -58
    -59
    -60
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 58
    -
    -def inspect
    -  format '<#%s:0x%x termination:%s>', self.class, object_id << 1, termination.state
    -end
    -
    -
    - -
    -

    - - #mailbox ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -14
    -15
    -16
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 14
    -
    -def mailbox
    -  @Mailbox
    -end
    -
    -
    - -
    -

    - - #push(*message) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -43
    -44
    -45
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 43
    -
    -def push(*message)
    -  @Mailbox.push message
    -end
    -
    -
    - -
    -

    - - #receive(probe = Promises.resolvable_future) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -33
    -34
    -35
    -36
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 33
    -
    -def receive(probe = Promises.resolvable_future)
    -  # TODO (pitr-ch 27-Dec-2016): patterns
    -  @Mailbox.pop probe
    -end
    -
    -
    - -
    -

    - - #tell(*message) ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -38
    -39
    -40
    -41
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 38
    -
    -def tell(*message)
    -  @Mailbox.push message
    -  self
    -end
    -
    -
    - -
    -

    - - #termination ⇒ (undocumented) - - - - - -

    - - - - -
    -
    -
    -
    -18
    -19
    -20
    -
    -
    # File 'lib/concurrent/edge/processing_actor.rb', line 18
    -
    -def termination
    -  @Terminated.with_hidden_resolvable
    -end
    -
    -
    - -
    - -
    - - - - - -
    - - \ No newline at end of file diff --git a/docs/1.0.5/top-level-namespace.html b/docs/1.0.5/top-level-namespace.html index df6492f1e..7cf033b9a 100644 --- a/docs/1.0.5/top-level-namespace.html +++ b/docs/1.0.5/top-level-namespace.html @@ -575,9 +575,9 @@

    + + + + + + + + + + + +
    + + +

    Module: Concurrent + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/concurrent.rb,
    + lib/concurrent/map.rb,
    lib/concurrent/set.rb,
    lib/concurrent/atom.rb,
    lib/concurrent/hash.rb,
    lib/concurrent/ivar.rb,
    lib/concurrent/mvar.rb,
    lib/concurrent/tvar.rb,
    lib/concurrent/agent.rb,
    lib/concurrent/array.rb,
    lib/concurrent/async.rb,
    lib/concurrent/delay.rb,
    lib/concurrent/maybe.rb,
    lib/concurrent/tuple.rb,
    lib/concurrent/errors.rb,
    lib/concurrent/future.rb,
    lib/concurrent/options.rb,
    lib/concurrent/promise.rb,
    lib/concurrent/version.rb,
    lib/concurrent/dataflow.rb,
    lib/concurrent/promises.rb,
    lib/concurrent/constants.rb,
    lib/concurrent/exchanger.rb,
    lib/concurrent/re_include.rb,
    lib/concurrent/timer_task.rb,
    lib/concurrent/atomic/event.rb,
    lib/concurrent/configuration.rb,
    lib/concurrent/mutable_struct.rb,
    lib/concurrent/scheduled_task.rb,
    lib/concurrent/utility/engine.rb,
    lib/concurrent/concern/logging.rb,
    lib/concurrent/settable_struct.rb,
    lib/concurrent/synchronization.rb,
    lib/concurrent/utility/at_exit.rb,
    lib/concurrent/atomic/semaphore.rb,
    lib/concurrent/immutable_struct.rb,
    lib/concurrent/thread_safe/util.rb,
    lib/concurrent/concern/obligation.rb,
    lib/concurrent/concern/observable.rb,
    lib/concurrent/executor/timer_set.rb,
    lib/concurrent/concern/deprecation.rb,
    lib/concurrent/atomic/atomic_fixnum.rb,
    lib/concurrent/synchronization/lock.rb,
    lib/concurrent/atomic/atomic_boolean.rb,
    lib/concurrent/atomic/cyclic_barrier.rb,
    lib/concurrent/atomic/mutex_semaphore.rb,
    lib/concurrent/atomic/read_write_lock.rb,
    lib/concurrent/synchronization/object.rb,
    lib/concurrent/thread_safe/util/adder.rb,
    lib/concurrent/utility/monotonic_time.rb,
    lib/concurrent/utility/native_integer.rb,
    lib/concurrent/atomic/atomic_reference.rb,
    lib/concurrent/atomic/count_down_latch.rb,
    lib/concurrent/atomic/thread_local_var.rb,
    lib/concurrent/concern/dereferenceable.rb,
    lib/concurrent/synchronization/volatile.rb,
    lib/concurrent/executor/executor_service.rb,
    lib/concurrent/synchronization/condition.rb,
    lib/concurrent/thread_safe/util/volatile.rb,
    lib/concurrent/utility/processor_counter.rb,
    lib/concurrent/atomic/mutex_atomic_fixnum.rb,
    lib/concurrent/collection/lock_free_stack.rb,
    lib/concurrent/executor/fixed_thread_pool.rb,
    lib/concurrent/synchronization/mri_object.rb,
    lib/concurrent/synchronization/rbx_object.rb,
    lib/concurrent/thread_safe/util/striped64.rb,
    lib/concurrent/atomic/mutex_atomic_boolean.rb,
    lib/concurrent/executor/cached_thread_pool.rb,
    lib/concurrent/executor/immediate_executor.rb,
    lib/concurrent/executor/safe_task_executor.rb,
    lib/concurrent/atomic/java_count_down_latch.rb,
    lib/concurrent/atomic/java_thread_local_var.rb,
    lib/concurrent/atomic/ruby_thread_local_var.rb,
    lib/concurrent/synchronization/jruby_object.rb,
    lib/concurrent/atomic/mutex_count_down_latch.rb,
    lib/concurrent/atomic_reference/mutex_atomic.rb,
    lib/concurrent/executor/serialized_execution.rb,
    lib/concurrent/executor/thread_pool_executor.rb,
    lib/concurrent/collection/map/mri_map_backend.rb,
    lib/concurrent/executor/java_executor_service.rb,
    lib/concurrent/executor/ruby_executor_service.rb,
    lib/concurrent/executor/single_thread_executor.rb,
    lib/concurrent/synchronization/abstract_object.rb,
    lib/concurrent/synchronization/abstract_struct.rb,
    lib/concurrent/synchronization/lockable_object.rb,
    lib/concurrent/thread_safe/util/cheap_lockable.rb,
    lib/concurrent/utility/native_extension_loader.rb,
    lib/concurrent/atomic/abstract_thread_local_var.rb,
    lib/concurrent/atomic/atomic_markable_reference.rb,
    lib/concurrent/atomic/reentrant_read_write_lock.rb,
    lib/concurrent/executor/serial_executor_service.rb,
    lib/concurrent/executor/simple_executor_service.rb,
    lib/concurrent/thread_safe/util/data_structures.rb,
    lib/concurrent/thread_safe/util/xor_shift_random.rb,
    lib/concurrent/executor/abstract_executor_service.rb,
    lib/concurrent/executor/java_thread_pool_executor.rb,
    lib/concurrent/executor/ruby_thread_pool_executor.rb,
    lib/concurrent/synchronization/truffleruby_object.rb,
    lib/concurrent/thread_safe/synchronized_delegator.rb,
    lib/concurrent/synchronization/rbx_lockable_object.rb,
    lib/concurrent/thread_safe/util/power_of_two_tuple.rb,
    lib/concurrent/atomic_reference/numeric_cas_wrapper.rb,
    lib/concurrent/executor/indirect_immediate_executor.rb,
    lib/concurrent/executor/java_single_thread_executor.rb,
    lib/concurrent/executor/ruby_single_thread_executor.rb,
    lib/concurrent/collection/copy_on_write_observer_set.rb,
    lib/concurrent/synchronization/jruby_lockable_object.rb,
    lib/concurrent/synchronization/mutex_lockable_object.rb,
    lib/concurrent/collection/copy_on_notify_observer_set.rb,
    lib/concurrent/collection/map/synchronized_map_backend.rb,
    lib/concurrent/executor/serialized_execution_delegator.rb,
    lib/concurrent/collection/non_concurrent_priority_queue.rb,
    lib/concurrent/synchronization/abstract_lockable_object.rb,
    lib/concurrent/collection/map/non_concurrent_map_backend.rb,
    lib/concurrent/collection/map/atomic_reference_map_backend.rb,
    lib/concurrent/collection/java_non_concurrent_priority_queue.rb,
    lib/concurrent/collection/ruby_non_concurrent_priority_queue.rb,
    lib-edge/concurrent/edge.rb,
    lib-edge/concurrent/actor.rb,
    lib-edge/concurrent/channel.rb,
    lib-edge/concurrent/actor/core.rb,
    lib-edge/concurrent/actor/root.rb,
    lib-edge/concurrent/actor/utils.rb,
    lib-edge/concurrent/actor/errors.rb,
    lib-edge/concurrent/channel/tick.rb,
    lib-edge/concurrent/actor/context.rb,
    lib-edge/concurrent/edge/promises.rb,
    lib-edge/concurrent/edge/throttle.rb,
    lib-edge/concurrent/lazy_register.rb,
    lib-edge/concurrent/actor/envelope.rb,
    lib-edge/concurrent/actor/behaviour.rb,
    lib-edge/concurrent/actor/reference.rb,
    lib-edge/concurrent/actor/type_check.rb,
    lib-edge/concurrent/actor/utils/pool.rb,
    lib-edge/concurrent/channel/selector.rb,
    lib-edge/concurrent/edge/cancellation.rb,
    lib-edge/concurrent/actor/utils/ad_hoc.rb,
    lib-edge/concurrent/channel/buffer/base.rb,
    lib-edge/concurrent/actor/utils/balancer.rb,
    lib-edge/concurrent/channel/buffer/timer.rb,
    lib-edge/concurrent/edge/lock_free_queue.rb,
    lib-edge/concurrent/actor/utils/broadcast.rb,
    lib-edge/concurrent/channel/buffer/ticker.rb,
    lib-edge/concurrent/edge/processing_actor.rb,
    lib-edge/concurrent/actor/behaviour/awaits.rb,
    lib-edge/concurrent/actor/behaviour/buffer.rb,
    lib-edge/concurrent/channel/buffer/sliding.rb,
    lib-edge/concurrent/actor/behaviour/linking.rb,
    lib-edge/concurrent/actor/behaviour/pausing.rb,
    lib-edge/concurrent/channel/buffer/buffered.rb,
    lib-edge/concurrent/channel/buffer/dropping.rb,
    lib-edge/concurrent/actor/behaviour/abstract.rb,
    lib-edge/concurrent/actor/public_delegations.rb,
    lib-edge/concurrent/channel/buffer/unbuffered.rb,
    lib-edge/concurrent/edge/lock_free_linked_set.rb,
    lib-edge/concurrent/actor/internal_delegations.rb,
    lib-edge/concurrent/actor/behaviour/supervising.rb,
    lib-edge/concurrent/actor/behaviour/termination.rb,
    lib-edge/concurrent/channel/selector/put_clause.rb,
    lib-edge/concurrent/actor/behaviour/sets_results.rb,
    lib-edge/concurrent/channel/selector/take_clause.rb,
    lib-edge/concurrent/edge/old_channel_integration.rb,
    lib-edge/concurrent/actor/behaviour/removes_child.rb,
    lib-edge/concurrent/channel/selector/after_clause.rb,
    lib-edge/concurrent/channel/selector/error_clause.rb,
    lib-edge/concurrent/edge/lock_free_linked_set/node.rb,
    lib-edge/concurrent/channel/selector/default_clause.rb,
    lib-edge/concurrent/actor/behaviour/executes_context.rb,
    lib-edge/concurrent/edge/lock_free_linked_set/window.rb,
    lib-edge/concurrent/actor/default_dead_letter_handler.rb,
    lib-edge/concurrent/actor/behaviour/errors_on_unknown_message.rb
    +
    +
    + +
    + +

    Overview

    +
    +

    Concurrent Ruby

    + +

    Gem Version +Build Status +Build status +License +Gitter chat

    + +

    Modern concurrency tools for Ruby. Inspired by +Erlang, +Clojure, +Scala, +Haskell, +F#, +C#, +Java, +and classic concurrency patterns.

    + +

    + +

    The design goals of this gem are:

    + +
      +
    • Be an 'unopinionated' toolbox that provides useful utilities without debating which is better +or why
    • +
    • Remain free of external gem dependencies
    • +
    • Stay true to the spirit of the languages providing inspiration
    • +
    • But implement in a way that makes sense for Ruby
    • +
    • Keep the semantics as idiomatic Ruby as possible
    • +
    • Support features that make sense in Ruby
    • +
    • Exclude features that don't make sense in Ruby
    • +
    • Be small, lean, and loosely coupled
    • +
    • Thread-safety
    • +
    • Backward compatibility
    • +
    + +

    Contributing

    + +

    This gem depends on +contributions and we +appreciate your help. Would you like to contribute? Great! Have a look at +issues with looking-for-contributor label. And if you pick something up let us know on the issue.

    + +

    Thread Safety

    + +

    Concurrent Ruby makes one of the strongest thread safety guarantees of any Ruby concurrency +library, providing consistent behavior and guarantees on all three of the main Ruby interpreters +(MRI/CRuby, JRuby, and Rubinius).

    + +

    Every abstraction in this library is thread safe. Specific thread safety guarantees are documented +with each abstraction.

    + +

    It is critical to remember, however, that Ruby is a language of mutable references. No +concurrency library for Ruby can ever prevent the user from making thread safety mistakes (such as +sharing a mutable object between threads and modifying it on both threads) or from creating +deadlocks through incorrect use of locks. All the library can do is provide safe abstractions which +encourage safe practices. Concurrent Ruby provides more safe concurrency abstractions than any +other Ruby library, many of which support the mantra of +"Do not communicate by sharing memory; instead, share memory by communicating". +Concurrent Ruby is also the only Ruby library which provides a full suite of thread safe and +immutable variable types and data structures.

    + +

    We've also initiated discussion to document memory model of Ruby which +would provide consistent behaviour and guarantees on all three of the main Ruby interpreters +(MRI/CRuby, JRuby, Rubinius, TruffleRuby).

    + +

    Features & Documentation

    + +

    The primary site for documentation is the automatically generated +API documentation which is up to +date with latest release. This readme matches the master so may contain new stuff not yet +released.

    + +

    We also have a IRC (gitter).

    + +

    Versioning

    + +
      +
    • concurrent-ruby uses Semantic Versioning
    • +
    • concurrent-ruby-ext has always same version as concurrent-ruby
    • +
    • concurrent-ruby-edge will always be 0.y.z therefore following +point 4 applies "Major version zero +(0.y.z) is for initial development. Anything may change at any time. The +public API should not be considered stable." However we additionally use +following rules: + +
        +
      • Minor version increment means incompatible changes were made
      • +
      • Patch version increment means only compatible changes were made
      • +
    • +
    + +

    General-purpose Concurrency Abstractions

    + +
      +
    • Async: +A mixin module that provides simple asynchronous behavior to a class. Loosely based on Erlang's +gen_server.
    • +
    • ScheduledTask: +Like a Future scheduled for a specific future time.
    • +
    • TimerTask: +A Thread that periodically wakes up to perform work at regular intervals.
    • +
    • Promises: +Unified implementation of futures and promises which combines features of previous Future, +Promise, IVar, Event, dataflow, Delay, and (partially) TimerTask into a single +framework. It extensively uses the new synchronization layer to make all the features +non-blocking and lock-free, with the exception of obviously blocking operations like +#wait, #value. It also offers better performance.
    • +
    + +

    Thread-safe Value Objects, Structures, and Collections

    + +

    Collection classes that were originally part of the (deprecated) thread_safe gem:

    + +
      +
    • Array A thread-safe +subclass of Ruby's standard Array.
    • +
    • Hash A thread-safe +subclass of Ruby's standard Hash.
    • +
    • Set A thread-safe +subclass of Ruby's standard Set.
    • +
    • Map A hash-like object +that should have much better performance characteristics, especially under high concurrency, +than Concurrent::Hash.
    • +
    • Tuple A fixed size +array with volatile (synchronized, thread safe) getters/setters.
    • +
    + +

    Value objects inspired by other languages:

    + + + +

    Structure classes derived from Ruby's Struct:

    + +
      +
    • ImmutableStruct +Immutable struct where values are set at construction and cannot be changed later.
    • +
    • MutableStruct +Synchronized, mutable struct where values can be safely changed at any time.
    • +
    • SettableStruct +Synchronized, write-once struct where values can be set at most once, either at construction +or any time thereafter.
    • +
    + +

    Thread-safe variables:

    + +
      +
    • Agent: A way to +manage shared, mutable, asynchronous, independent state. Based on Clojure's +Agent.
    • +
    • Atom: A way to manage +shared, mutable, synchronous, independent state. Based on Clojure's +Atom.
    • +
    • AtomicBoolean +A boolean value that can be updated atomically.
    • +
    • AtomicFixnum +A numeric value that can be updated atomically.
    • +
    • AtomicReference +An object reference that may be updated atomically.
    • +
    • Exchanger +A synchronization point at which threads can pair and swap elements within pairs. Based on +Java's Exchanger.
    • +
    • MVar A synchronized +single element container. Based on Haskell's +MVar and +Scala's MVar.
    • +
    • ThreadLocalVar +A variable where the value is different for each thread.
    • +
    • TVar A transactional +variable implementing software transactional memory (STM). Based on Clojure's +Ref.
    • +
    + +

    Java-inspired ThreadPools and Other Executors

    + +
      +
    • See the thread pool +overview, which also contains a list of other Executors available.
    • +
    + +

    Thread Synchronization Classes and Algorithms

    + +
      +
    • CountDownLatch +A synchronization object that allows one thread to wait on multiple other threads.
    • +
    • CyclicBarrier +A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
    • +
    • Event Old school +kernel-style event.
    • +
    • ReadWriteLock +A lock that supports multiple readers but only one writer.
    • +
    • ReentrantReadWriteLock +A read/write lock with reentrant and upgrade features.
    • +
    • Semaphore +A counting-based locking mechanism that uses permits.
    • +
    • AtomicMarkableReference
    • +
    + +

    Deprecated

    + +

    Deprecated features are still available and bugs are being fixed, but new features will not be added.

    + +
      +
    • Future: +An asynchronous operation that produces a value. Replaced by +Promises. + +
        +
      • .dataflow: +Built on Futures, Dataflow allows you to create a task that will be scheduled when all of +its data dependencies are available. Replaced by +Promises.
      • +
    • +
    • Promise: Similar +to Futures, with more features. Replaced by +Promises.
    • +
    • Delay Lazy evaluation +of a block yielding an immutable result. Based on Clojure's +delay. Replaced by +Promises.
    • +
    • IVar Similar to a +"future" but can be manually assigned once, after which it becomes immutable. Replaced by +Promises.
    • +
    + +

    Edge Features

    + +

    These are available in the concurrent-ruby-edge companion gem.

    + +

    These features are under active development and may change frequently. They are expected not to +keep backward compatibility (there may also lack tests and documentation). Semantic versions will +be obeyed though. Features developed in concurrent-ruby-edge are expected to move to +concurrent-ruby when final.

    + +
      +
    • Actor: Implements +the Actor Model, where concurrent actors exchange messages. +Status: Partial documentation and tests; depends on new future/promise framework; stability is good.
    • +
    • Channel: +Communicating Sequential Processes (CSP). +Functionally equivalent to Go channels with additional +inspiration from Clojure core.async. +Status: Partial documentation and tests.
    • +
    • LazyRegister
    • +
    • LockFreeLinkedSet +Status: will be moved to core soon.
    • +
    • LockFreeStack +Status: missing documentation and tests.
    • +
    + +

    Supported Ruby versions

    + +

    MRI 2.0 and above, JRuby 9000, TruffleRuby are supported. +This gem should be fully compatible with any interpreter that is compliant with Ruby 2.0 or newer. +Java 8 is preferred for JRuby but every Java version on which JRuby 9000 runs is supported.

    + +

    The legacy support for Rubinius is kept but it is no longer maintained, if you would like to help +please respond to #739.

    + +

    Usage

    + +

    Everything within this gem can be loaded simply by requiring it:

    + +
    require 'concurrent'
    +
    + +

    Requiring only specific abstractions from Concurrent Ruby is not yet supported.

    + +

    To use the tools in the Edge gem it must be required separately:

    + +
    require 'concurrent-edge'
    +
    + +

    If the library does not behave as expected, Concurrent.use_stdlib_logger(Logger::DEBUG) could +help to reveal the problem.

    + +

    Installation

    + +
    gem install concurrent-ruby
    +
    + +

    or add the following line to Gemfile:

    + +
    gem 'concurrent-ruby', require: 'concurrent'
    +
    + +

    and run bundle install from your shell.

    + +

    Edge Gem Installation

    + +

    The Edge gem must be installed separately from the core gem:

    + +
    gem install concurrent-ruby-edge
    +
    + +

    or add the following line to Gemfile:

    + +
    gem 'concurrent-ruby-edge', require: 'concurrent-edge'
    +
    + +

    and run bundle install from your shell.

    + +

    C Extensions for MRI

    + +

    Potential performance improvements may be achieved under MRI by installing optional C extensions. +To minimise installation errors the C extensions are available in the concurrent-ruby-ext +extension gem. concurrent-ruby and concurrent-ruby-ext are always released together with same +version. Simply install the extension gem too:

    + +
    gem install concurrent-ruby-ext
    +
    + +

    or add the following line to Gemfile:

    + +
    gem 'concurrent-ruby-ext'
    +
    + +

    and run bundle install from your shell.

    + +

    In code it is only necessary to

    + +
    require 'concurrent'
    +
    + +

    The concurrent-ruby gem will automatically detect the presence of the concurrent-ruby-ext gem +and load the appropriate C extensions.

    + +

    Note For gem developers

    + +

    No gems should depend on concurrent-ruby-ext. Doing so will force C extensions on your users. The +best practice is to depend on concurrent-ruby and let users to decide if they want C extensions.

    + +

    Maintainers

    + + + +

    Special Thanks to

    + + + +

    and to the past maintainers

    + + + +

    License and Copyright

    + +

    Concurrent Ruby is free software released under the +MIT License.

    + +

    The Concurrent Ruby logo was +designed by David Jones. It is Copyright © 2014 +Jerry D'Antonio. All Rights Reserved.

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + Modules: Actor, Async, Concern, Edge, ImmutableStruct, MutableStruct, Promises, ReInclude, SettableStruct, Synchronization, Utility + + + + Classes: Agent, Array, Atom, AtomicBoolean, AtomicFixnum, AtomicMarkableReference, AtomicReference, CachedThreadPool, Cancellation, Channel, ConcurrentUpdateError, CountDownLatch, CyclicBarrier, Delay, Event, Exchanger, FixedThreadPool, Future, Hash, IVar, ImmediateExecutor, IndirectImmediateExecutor, LazyRegister, MVar, Map, Maybe, MultipleAssignmentError, MultipleErrors, ProcessingActor, Promise, ReadWriteLock, ReentrantReadWriteLock, SafeTaskExecutor, ScheduledTask, Semaphore, SerializedExecution, SerializedExecutionDelegator, Set, SimpleExecutorService, SingleThreadExecutor, TVar, ThreadLocalVar, ThreadPoolExecutor, Throttle, TimerSet, TimerTask, Transaction, Tuple + + +

    + + +

    + Constant Summary + collapse +

    + +
    + +
    Error = + +
    +
    Class.new(StandardError)
    + +
    ConfigurationError = +
    +
    +

    Raised when errors occur during configuration.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    CancelledOperationError = +
    +
    +

    Raised when an asynchronous operation is cancelled before execution.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    LifecycleError = +
    +
    +

    Raised when a lifecycle method (such as stop) is called in an improper +sequence or when the object is in an inappropriate state.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    ImmutabilityError = +
    +
    +

    Raised when an attempt is made to violate an immutability guarantee.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    IllegalOperationError = +
    +
    +

    Raised when an operation is attempted which is not legal given the +receiver's current state

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    InitializationError = +
    +
    +

    Raised when an object's methods are called when it has not been +properly initialized.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    MaxRestartFrequencyError = +
    +
    +

    Raised when an object with a start/stop lifecycle has been started an +excessive number of times. Often used in conjunction with a restart +policy or strategy.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    RejectedExecutionError = +
    +
    +

    Raised by an Executor when it is unable to process a given task, +possibly because of a reject policy or other internal error.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    ResourceLimitError = +
    +
    +

    Raised when any finite resource, such as a lock counter, exceeds its +maximum limit/threshold.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    TimeoutError = +
    +
    +

    Raised when an operation times out.

    + + +
    +
    +
    + + +
    +
    +
    Class.new(Error)
    + +
    PromiseExecutionError = + +
    +
    Class.new(StandardError)
    + +
    VERSION = + +
    +
    '1.1.0.pre1'
    + +
    EDGE_VERSION = + +
    +
    '0.4.0.pre1'
    + +
    NULL_LOGGER = +
    +
    +

    Suppresses all output when used for logging.

    + + +
    +
    +
    + + +
    +
    +
    lambda { |level, progname, message = nil, &block| }
    + +
    + + + + + + + + + +

    + Class Method Summary + collapse +

    + + + + + + + + + + + + + +
    +

    Class Method Details

    + + +
    +

    + + .abort_transactionundocumented + + + + + +

    +
    +

    Abort a currently running transaction - see Concurrent::atomically.

    + + +
    +
    +
    + +

    Raises:

    + + +
    + + + + +
    +
    +
    +
    +150
    +151
    +152
    +
    +
    # File 'lib/concurrent/tvar.rb', line 150
    +
    +def abort_transaction
    +  raise Transaction::AbortError.new
    +end
    +
    +
    + +
    +

    + + .atomicallyundocumented + + + + + +

    +
    +

    Run a block that reads and writes TVars as a single atomic transaction. +With respect to the value of TVar objects, the transaction is atomic, in +that it either happens or it does not, consistent, in that the TVar +objects involved will never enter an illegal state, and isolated, in that +transactions never interfere with each other. You may recognise these +properties from database transactions.

    + +

    There are some very important and unusual semantics that you must be aware of:

    + +
      +
    • Most importantly, the block that you pass to atomically may be executed +more than once. In most cases your code should be free of +side-effects, except for via TVar.

    • +
    • If an exception escapes an atomically block it will abort the transaction.

    • +
    • It is undefined behaviour to use callcc or Fiber with atomically.

    • +
    • If you create a new thread within an atomically, it will not be part of +the transaction. Creating a thread counts as a side-effect.

    • +
    + +

    Transactions within transactions are flattened to a single transaction.

    + + +
    +
    +
    + +
    +

    Examples:

    + + +
    a = new TVar(100_000)
    +b = new TVar(100)
    +
    +Concurrent::atomically do
    +  a.value -= 10
    +  b.value += 10
    +end
    + +
    + +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/concurrent/tvar.rb', line 93
    +
    +def atomically
    +  raise ArgumentError.new('no block given') unless block_given?
    +
    +  # Get the current transaction
    +
    +  transaction = Transaction::current
    +
    +  # Are we not already in a transaction (not nested)?
    +
    +  if transaction.nil?
    +    # New transaction
    +
    +    begin
    +      # Retry loop
    +
    +      loop do
    +
    +        # Create a new transaction
    +
    +        transaction = Transaction.new
    +        Transaction::current = transaction
    +
    +        # Run the block, aborting on exceptions
    +
    +        begin
    +          result = yield
    +        rescue Transaction::AbortError => e
    +          transaction.abort
    +          result = Transaction::ABORTED
    +        rescue Transaction::LeaveError => e
    +          transaction.abort
    +          break result
    +        rescue => e
    +          transaction.abort
    +          raise e
    +        end
    +        # If we can commit, break out of the loop
    +
    +        if result != Transaction::ABORTED
    +          if transaction.commit
    +            break result
    +          end
    +        end
    +      end
    +    ensure
    +      # Clear the current transaction
    +
    +      Transaction::current = nil
    +    end
    +  else
    +    # Nested transaction - flatten it and just run the block
    +
    +    yield
    +  end
    +end
    +
    +
    + +
    +

    + + .call_dataflow(method, executor, *inputs, &block) ⇒ undocumented + + + + + +

    +
    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +
    +
    # File 'lib/concurrent/dataflow.rb', line 56
    +
    +def call_dataflow(method, executor, *inputs, &block)
    +  raise ArgumentError.new('an executor must be provided') if executor.nil?
    +  raise ArgumentError.new('no block given') unless block_given?
    +  unless inputs.all? { |input| input.is_a? IVar }
    +    raise ArgumentError.new("Not all dependencies are IVars.\nDependencies: #{ inputs.inspect }")
    +  end
    +
    +  result = Future.new(executor: executor) do
    +    values = inputs.map { |input| input.send(method) }
    +    block.call(*values)
    +  end
    +
    +  if inputs.empty?
    +    result.execute
    +  else
    +    counter = DependencyCounter.new(inputs.size) { result.execute }
    +
    +    inputs.each do |input|
    +      input.add_observer counter
    +    end
    +  end
    +
    +  result
    +end
    +
    +
    + +
    +

    + + .create_simple_logger(level = Logger::FATAL, output = $stderr) ⇒ Logger + + + + + +

    +
    +

    Returns Logger with provided level and output.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Logger) + + + + — +

      Logger with provided level and output.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +40
    +41
    +
    +
    # File 'lib/concurrent/configuration.rb', line 18
    +
    +def self.create_simple_logger(level = Logger::FATAL, output = $stderr)
    +  # TODO (pitr-ch 24-Dec-2016): figure out why it had to be replaced, stdlogger was deadlocking
    +  lambda do |severity, progname, message = nil, &block|
    +    return false if severity < level
    +
    +    message           = block ? block.call : message
    +    formatted_message = case message
    +                        when String
    +                          message
    +                        when Exception
    +                          format "%s (%s)\n%s",
    +                                 message.message, message.class, (message.backtrace || []).join("\n")
    +                        else
    +                          message.inspect
    +                        end
    +
    +    output.print format "[%s] %5s -- %s: %s\n",
    +                        Time.now.strftime('%Y-%m-%d %H:%M:%S.%L'),
    +                        Logger::SEV_LABEL[severity],
    +                        progname,
    +                        formatted_message
    +    true
    +  end
    +end
    +
    +
    + +
    +

    + + .create_stdlib_logger(level = Logger::FATAL, output = $stderr) ⇒ Logger + + + + + +

    +
    +
    Deprecated.
    +

    Returns Logger with provided level and output.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Logger) + + + + — +

      Logger with provided level and output.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +
    +
    # File 'lib/concurrent/configuration.rb', line 50
    +
    +def self.create_stdlib_logger(level = Logger::FATAL, output = $stderr)
    +  logger           = Logger.new(output)
    +  logger.level     = level
    +  logger.formatter = lambda do |severity, datetime, progname, msg|
    +    formatted_message = case msg
    +                        when String
    +                          msg
    +                        when Exception
    +                          format "%s (%s)\n%s",
    +                                 msg.message, msg.class, (msg.backtrace || []).join("\n")
    +                        else
    +                          msg.inspect
    +                        end
    +    format "[%s] %5s -- %s: %s\n",
    +           datetime.strftime('%Y-%m-%d %H:%M:%S.%L'),
    +           severity,
    +           progname,
    +           formatted_message
    +  end
    +
    +  lambda do |loglevel, progname, message = nil, &block|
    +    logger.add loglevel, message, progname, &block
    +  end
    +end
    +
    +
    + +
    +

    + + .dataflow(*inputs) {|inputs| ... } ⇒ Object + + + + + +

    +
    +

    Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available. +Data dependencies are Future values. The dataflow task itself is also a Future value, so you can build up a graph of these tasks, each of which is run when all the data and other tasks it depends on are available or completed.

    + +

    Our syntax is somewhat related to that of Akka's flow and Habanero Java's DataDrivenFuture. However unlike Akka we don't schedule a task at all until it is ready to run, and unlike Habanero Java we pass the data values into the task instead of dereferencing them again in the task.

    + +

    The theory of dataflow goes back to the 70s. In the terminology of the literature, our implementation is coarse-grained, in that each task can be many instructions, and dynamic in that you can create more tasks within other tasks.

    + +

    Example

    + +

    A dataflow task is created with the dataflow method, passing in a block.

    + +
    task = Concurrent::dataflow { 14 }
    +
    + +

    This produces a simple Future value. The task will run immediately, as it has no dependencies. We can also specify Future values that must be available before a task will run. When we do this we get the value of those futures passed to our block.

    + +
    a = Concurrent::dataflow { 1 }
    +b = Concurrent::dataflow { 2 }
    +c = Concurrent::dataflow(a, b) { |av, bv| av + bv }
    +
    + +

    Using the dataflow method you can build up a directed acyclic graph (DAG) of tasks that depend on each other, and have the tasks run as soon as their dependencies are ready and there is CPU capacity to schedule them. This can help you create a program that uses more of the CPU resources available to you.

    + +

    Derivation

    + +

    This section describes how we could derive dataflow from other primitives in this library.

    + +

    Consider a naive fibonacci calculator.

    + +
    def fib(n)
    +  if n < 2
    +    n
    +  else
    +    fib(n - 1) + fib(n - 2)
    +  end
    +end
    +
    +puts fib(14) #=> 377
    +
    + +

    We could modify this to use futures.

    + +
    def fib(n)
    +  if n < 2
    +    Concurrent::Future.new { n }
    +  else
    +    n1 = fib(n - 1).execute
    +    n2 = fib(n - 2).execute
    +    Concurrent::Future.new { n1.value + n2.value }
    +  end
    +end
    +
    +f = fib(14) #=> #<Concurrent::Future:0x000001019ef5a0 ...
    +f.execute   #=> #<Concurrent::Future:0x000001019ef5a0 ...
    +
    +sleep(0.5)
    +
    +puts f.value #=> 377
    +
    + +

    One of the drawbacks of this approach is that all the futures start, and then most of them immediately block on their dependencies. We know that there's no point executing those futures until their dependencies are ready, so let's not execute each future until all their dependencies are ready.

    + +

    To do this we'll create an object that counts the number of times it observes a future finishing before it does something - and for us that something will be to execute the next future.

    + +
    class CountingObserver
    +
    +  def initialize(count, &block)
    +    @count = count
    +    @block = block
    +  end
    +
    +  def update(time, value, reason)
    +    @count -= 1
    +
    +    if @count <= 0
    +      @block.call()
    +    end
    +  end
    +
    +end
    +
    +def fib(n)
    +  if n < 2
    +    Concurrent::Future.new { n }.execute
    +  else
    +    n1 = fib(n - 1)
    +    n2 = fib(n - 2)
    +
    +    result = Concurrent::Future.new { n1.value + n2.value }
    +
    +    barrier = CountingObserver.new(2) { result.execute }
    +    n1.add_observer barrier
    +    n2.add_observer barrier
    +
    +    n1.execute
    +    n2.execute
    +
    +    result
    +  end
    +end
    +
    + +

    We can wrap this up in a dataflow utility.

    + +
    f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
    +sleep(0.5)
    +
    +puts f.value #=> 377
    +
    +def dataflow(*inputs, &block)
    +  result = Concurrent::Future.new(&block)
    +
    +  if inputs.empty?
    +    result.execute
    +  else
    +    barrier = CountingObserver.new(inputs.size) { result.execute }
    +
    +    inputs.each do |input|
    +      input.add_observer barrier
    +    end
    +  end
    +
    +  result
    +end
    +
    +def fib(n)
    +  if n < 2
    +    dataflow { n }
    +  else
    +    n1 = fib(n - 1)
    +    n2 = fib(n - 2)
    +    dataflow(n1, n2) { n1.value + n2.value }
    +  end
    +end
    +
    +f = fib(14) #=> #<Concurrent::Future:0x00000101fca308 ...
    +sleep(0.5)
    +
    +puts f.value #=> 377
    +
    + +

    Since we know that the futures the dataflow computation depends on are already going to be available when the future is executed, we might as well pass the values into the block so we don't have to reference the futures inside the block. This allows us to write the dataflow block as straight non-concurrent code without reference to futures.

    + +
    def dataflow(*inputs, &block)
    +  result = Concurrent::Future.new do
    +    values = inputs.map { |input| input.value }
    +    block.call(*values)
    +  end
    +
    +  if inputs.empty?
    +    result.execute
    +  else
    +    barrier = CountingObserver.new(inputs.size) { result.execute }
    +
    +    inputs.each do |input|
    +      input.add_observer barrier
    +    end
    +  end
    +
    +  result
    +end
    +
    +def fib(n)
    +  if n < 2
    +    Concurrent::dataflow { n }
    +  else
    +    n1 = fib(n - 1)
    +    n2 = fib(n - 2)
    +    Concurrent::dataflow(n1, n2) { |v1, v2| v1 + v2 }
    +  end
    +end
    +
    +f = fib(14) #=> #<Concurrent::Future:0x000001019a26d8 ...
    +sleep(0.5)
    +
    +puts f.value #=> 377
    +
    +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + inputs + + + (Future) + + + + — +

      zero or more Future operations that this dataflow depends upon

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + + + + + +

      The operation to perform once all the dependencies are met

      +
      + +
    • + +
    +

    Yield Parameters:

    +
      + +
    • + + inputs + + + (Future) + + + + — +

      each of the Future inputs to the dataflow

      +
      + +
    • + +
    +

    Yield Returns:

    +
      + +
    • + + + (Object) + + + + — +

      the result of the block operation

      +
      + +
    • + +
    +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +

      the result of all the operations

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + + — +

      if any of the inputs are not IVars

      +
      + +
    • + +
    • + + + (ArgumentError) + + + + — +

      if no block is given

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib/concurrent/dataflow.rb', line 34
    +
    +def dataflow(*inputs, &block)
    +  dataflow_with(Concurrent.global_io_executor, *inputs, &block)
    +end
    +
    +
    + +
    +

    + + .dataflow!(*inputs, &block) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib/concurrent/dataflow.rb', line 44
    +
    +def dataflow!(*inputs, &block)
    +  dataflow_with!(Concurrent.global_io_executor, *inputs, &block)
    +end
    +
    +
    + +
    +

    + + .dataflow_with(executor, *inputs, &block) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +
    +
    # File 'lib/concurrent/dataflow.rb', line 39
    +
    +def dataflow_with(executor, *inputs, &block)
    +  call_dataflow(:value, executor, *inputs, &block)
    +end
    +
    +
    + +
    +

    + + .dataflow_with!(executor, *inputs, &block) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +49
    +50
    +51
    +
    +
    # File 'lib/concurrent/dataflow.rb', line 49
    +
    +def dataflow_with!(executor, *inputs, &block)
    +  call_dataflow(:value!, executor, *inputs, &block)
    +end
    +
    +
    + +
    +

    + + .disable_at_exit_handlers!undocumented + + + + + +

    +
    + +
    + Note: +

    this option should be needed only because of at_exit ordering +issues which may arise when running some of the testing frameworks. +E.g. Minitest's test-suite runs itself in at_exit callback which +executes after the pools are already terminated. Then auto termination +needs to be disabled and called manually after test-suite ends.

    +
    +
    + +
    + Note: +

    This method should never be called +from within a gem. It should only be used from within the main +application and even then it should be used only when necessary.

    +
    +
    + +

    Disables AtExit handlers including pool auto-termination handlers. +When disabled it will be the application programmer's responsibility +to ensure that the handlers are shutdown properly prior to application +exit by calling AtExitImplementation.new.install.run method.

    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • AtExit
    • + +
    + +
    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +
    +
    # File 'lib/concurrent/configuration.rb', line 128
    +
    +def self.disable_at_exit_handlers!
    +  AtExit.enabled = false
    +end
    +
    +
    + +
    +

    + + .executor(executor_identifier) ⇒ Executor + + + + + +

    +
    +

    General access point to global executors.

    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    +
      + +
    • + + + (Executor) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +163
    +164
    +165
    +
    +
    # File 'lib/concurrent/configuration.rb', line 163
    +
    +def self.executor(executor_identifier)
    +  Options.executor(executor_identifier)
    +end
    +
    +
    + +
    +

    + + .global_fast_executorThreadPoolExecutor + + + + + +

    +
    +

    Global thread pool optimized for short, fast operations.

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +135
    +136
    +137
    +
    +
    # File 'lib/concurrent/configuration.rb', line 135
    +
    +def self.global_fast_executor
    +  GLOBAL_FAST_EXECUTOR.value
    +end
    +
    +
    + +
    +

    + + .global_immediate_executorundocumented + + + + + +

    + + + + +
    +
    +
    +
    +146
    +147
    +148
    +
    +
    # File 'lib/concurrent/configuration.rb', line 146
    +
    +def self.global_immediate_executor
    +  GLOBAL_IMMEDIATE_EXECUTOR
    +end
    +
    +
    + +
    +

    + + .global_io_executorThreadPoolExecutor + + + + + +

    +
    +

    Global thread pool optimized for long, blocking (IO) tasks.

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +142
    +143
    +144
    +
    +
    # File 'lib/concurrent/configuration.rb', line 142
    +
    +def self.global_io_executor
    +  GLOBAL_IO_EXECUTOR.value
    +end
    +
    +
    + +
    +

    + + .global_loggerundocumented + + + + + +

    + + + + +
    +
    +
    +
    +90
    +91
    +92
    +
    +
    # File 'lib/concurrent/configuration.rb', line 90
    +
    +def self.global_logger
    +  GLOBAL_LOGGER.value
    +end
    +
    +
    + +
    +

    + + .global_logger=(value) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +94
    +95
    +96
    +
    +
    # File 'lib/concurrent/configuration.rb', line 94
    +
    +def self.global_logger=(value)
    +  GLOBAL_LOGGER.value = value
    +end
    +
    +
    + +
    +

    + + .global_timer_setConcurrent::TimerSet + + + + + +

    +
    +

    Global thread pool user for global timers.

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +153
    +154
    +155
    +
    +
    # File 'lib/concurrent/configuration.rb', line 153
    +
    +def self.global_timer_set
    +  GLOBAL_TIMER_SET.value
    +end
    +
    +
    + +
    +

    + + .leave_transactionundocumented + + + + + +

    +
    +

    Leave a transaction without committing or aborting - see Concurrent::atomically.

    + + +
    +
    +
    + +

    Raises:

    + + +
    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +
    +
    # File 'lib/concurrent/tvar.rb', line 155
    +
    +def leave_transaction
    +  raise Transaction::LeaveError.new
    +end
    +
    +
    + +
    +

    + + .monotonic_timeFloat + + + + + +

    +
    + +
    + Note: +

    Time calculations on all platforms and languages are sensitive to +changes to the system clock. To alleviate the potential problems +associated with changing the system clock while an application is running, +most modern operating systems provide a monotonic clock that operates +independently of the system clock. A monotonic clock cannot be used to +determine human-friendly clock times. A monotonic clock is used exclusively +for calculating time intervals. Not all Ruby platforms provide access to an +operating system monotonic clock. On these platforms a pure-Ruby monotonic +clock will be used as a fallback. An operating system monotonic clock is both +faster and more reliable than the pure-Ruby implementation. The pure-Ruby +implementation should be fast and reliable enough for most non-realtime +operations. At this time the common Ruby platforms that provide access to an +operating system monotonic clock are MRI 2.1 and above and JRuby (all versions).

    +
    +
    + +

    Returns the current time a tracked by the application monotonic clock.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Float) + + + + — +

      The current monotonic time since some unspecified +starting point

      +
      + +
    • + +
    + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +53
    +54
    +55
    +
    +
    # File 'lib/concurrent/utility/monotonic_time.rb', line 53
    +
    +def monotonic_time
    +  GLOBAL_MONOTONIC_CLOCK.get_time
    +end
    +
    +
    + +
    +

    + + .new_fast_executor(opts = {}) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +
    +
    # File 'lib/concurrent/configuration.rb', line 167
    +
    +def self.new_fast_executor(opts = {})
    +  FixedThreadPool.new(
    +      [2, Concurrent.processor_count].max,
    +      auto_terminate:  opts.fetch(:auto_terminate, true),
    +      idletime:        60, # 1 minute
    +      max_queue:       0, # unlimited
    +      fallback_policy: :abort # shouldn't matter -- 0 max queue
    +  )
    +end
    +
    +
    + +
    +

    + + .new_io_executor(opts = {}) ⇒ undocumented + + + + + +

    + + + + +
    +
    +
    +
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/concurrent/configuration.rb', line 177
    +
    +def self.new_io_executor(opts = {})
    +  CachedThreadPool.new(
    +      auto_terminate:  opts.fetch(:auto_terminate, true),
    +      fallback_policy: :abort # shouldn't matter -- 0 max queue
    +  )
    +end
    +
    +
    + +
    +

    + + .physical_processor_countundocumented + + + + + +

    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +
    +
    # File 'lib/concurrent/utility/processor_counter.rb', line 155
    +
    +def self.physical_processor_count
    +  processor_counter.physical_processor_count
    +end
    +
    +
    + +
    +

    + + .processor_countundocumented + + + + + +

    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +
    +
    # File 'lib/concurrent/utility/processor_counter.rb', line 151
    +
    +def self.processor_count
    +  processor_counter.processor_count
    +end
    +
    +
    + +
    +

    + + .use_simple_logger(level = Logger::FATAL, output = $stderr) ⇒ undocumented + + + + + +

    +
    +

    Use logger created by #create_simple_logger to log concurrent-ruby messages.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib/concurrent/configuration.rb', line 44
    +
    +def self.use_simple_logger(level = Logger::FATAL, output = $stderr)
    +  Concurrent.global_logger = create_simple_logger level, output
    +end
    +
    +
    + +
    +

    + + .use_stdlib_logger(level = Logger::FATAL, output = $stderr) ⇒ undocumented + + + + + +

    +
    +
    Deprecated.
    +

    Use logger created by #create_stdlib_logger to log concurrent-ruby messages.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +77
    +78
    +79
    +
    +
    # File 'lib/concurrent/configuration.rb', line 77
    +
    +def self.use_stdlib_logger(level = Logger::FATAL, output = $stderr)
    +  Concurrent.global_logger = create_stdlib_logger level, output
    +end
    +
    +
    + +
    + +
    + + + + + +
    + + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor.html b/docs/1.1.0/Concurrent/Actor.html new file mode 100644 index 000000000..e0eced2c7 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor.html @@ -0,0 +1,1302 @@ + + + + + + + Module: Concurrent::Actor + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Concurrent::Actor + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib-edge/concurrent/actor.rb,
    + lib-edge/concurrent/actor/core.rb,
    lib-edge/concurrent/actor/root.rb,
    lib-edge/concurrent/actor/utils.rb,
    lib-edge/concurrent/actor/errors.rb,
    lib-edge/concurrent/actor/context.rb,
    lib-edge/concurrent/actor/envelope.rb,
    lib-edge/concurrent/actor/behaviour.rb,
    lib-edge/concurrent/actor/reference.rb,
    lib-edge/concurrent/actor/type_check.rb,
    lib-edge/concurrent/actor/utils/pool.rb,
    lib-edge/concurrent/actor/utils/ad_hoc.rb,
    lib-edge/concurrent/actor/utils/balancer.rb,
    lib-edge/concurrent/actor/utils/broadcast.rb,
    lib-edge/concurrent/actor/behaviour/awaits.rb,
    lib-edge/concurrent/actor/behaviour/buffer.rb,
    lib-edge/concurrent/actor/behaviour/linking.rb,
    lib-edge/concurrent/actor/behaviour/pausing.rb,
    lib-edge/concurrent/actor/behaviour/abstract.rb,
    lib-edge/concurrent/actor/public_delegations.rb,
    lib-edge/concurrent/actor/internal_delegations.rb,
    lib-edge/concurrent/actor/behaviour/supervising.rb,
    lib-edge/concurrent/actor/behaviour/termination.rb,
    lib-edge/concurrent/actor/behaviour/sets_results.rb,
    lib-edge/concurrent/actor/behaviour/removes_child.rb,
    lib-edge/concurrent/actor/behaviour/executes_context.rb,
    lib-edge/concurrent/actor/default_dead_letter_handler.rb,
    lib-edge/concurrent/actor/behaviour/errors_on_unknown_message.rb
    +
    +
    + +
    + +

    Overview

    +
    + +
    + Note: +

    Edge Features are under active development and may change frequently.

    + +
      +
    • Deprecations are not added before incompatible changes.
    • +
    • Edge version: major is always 0, minor bump means incompatible change, +patch bump means compatible change.
    • +
    • Edge features may also lack tests and documentation.
    • +
    • Features developed in concurrent-ruby-edge are expected to move +to concurrent-ruby when finalised.
    • +
    +
    +
    + +

    Actor model

    + +
      +
    • Light-weighted running on thread-pool.
    • +
    • Inspired by Akka and Erlang.
    • +
    • Modular.
    • +
    + +

    This Actor model implementation makes actors very cheap to create and discard. +Thousands of actors can be created, allowing you to break the program into smaller +maintainable pieces, without violating the single responsibility principle.

    + +

    What is an actor model?

    + +

    Actor-based concurrency is all the rage in some circles. Originally described in 1973, the actor model is a paradigm +for creating asynchronous, concurrent objects that is becoming increasingly popular. Much has changed since actors +were first written about four decades ago, which has led to a serious fragmentation within the actor community. +There is no universally accepted, strict definition of "actor" and actor implementations differ widely between +languages and libraries.

    + +

    Wiki definition is pretty good: +The actor model in computer science is a mathematical model of concurrent computation +that treats actors as the universal primitives of concurrent digital computation: +in response to a message that it receives, an actor can make local decisions, +create more actors, send more messages, and determine how to respond to the next +message received.

    + +

    Why?

    + +

    Concurrency is hard to get right, actors are one of many ways how to simplify the problem.

    + +

    Quick example

    + +

    An example:

    + +
    class Counter < Concurrent::Actor::Context
    +  # Include context of an actor which gives this class access to reference
    +  # and other information about the actor
    +
    +  # use initialize as you wish
    +  def initialize(initial_value)
    +    @count = initial_value
    +  end
    +
    +  # override on_message to define actor's behaviour
    +  def on_message(message)
    +    if Integer === message
    +      @count += message
    +    end
    +  end
    +end #
    +
    +# Create new actor naming the instance 'first'.
    +# Return value is a reference to the actor, the actual actor is never returned.
    +counter = Counter.spawn(:first, 5)
    +
    +# Tell a message and forget returning self.
    +counter.tell(1)
    +counter << 1
    +# (First counter now contains 7.)
    +
    +# Send a messages asking for a result.
    +counter.ask(0).class
    +counter.ask(0).value
    +
    + +

    class Adder < Concurrent::Actor::RestartingContext
    +  def initialize(init)
    +    @count = init
    +  end
    +
    +  def on_message(message)
    +    case message
    +    when :add
    +      @count += 1
    +    else
    +      # pass to ErrorsOnUnknownMessage behaviour, which will just fail
    +      pass
    +    end
    +  end
    +end 
    +
    +# `link: true` makes the actor linked to root actor and supervised
    +# which is default behavior
    +adder = Adder.spawn(name: :adder, link: true, args: [1])
    +    # => #<Concurrent::Actor::Reference:0x7fbedd8e3d40 /adder (Adder)>
    +adder.parent
    +    # => #<Concurrent::Actor::Reference:0x7fbedbaa1e90 / (Concurrent::Actor::Root)>
    +
    +# tell and forget
    +adder.tell(:add).tell(:add)
    +    # => #<Concurrent::Actor::Reference:0x7fbedd8e3d40 /adder (Adder)>
    +# ask to get result
    +adder.ask!(:add)                                   # => 4
    +# fail the actor
    +adder.ask!(:bad) rescue $!
    +    # => #<Concurrent::Actor::UnknownMessage: :bad from #<Thread:0x007fbedb8809b8>>
    +# actor is restarted with initial values
    +adder.ask!(:add)                                   # => 2
    +adder.ask!(:terminate!)                            # => true

    + +

    Spawning actors

    + + + +

    Sending messages

    + +
      +
    • Reference#tell +Sends the message asynchronously to the actor and immediately returns +self (the reference) allowing to chain message telling.
    • +
    • Reference#ask +testing and when it returns very shortly. It can lead to deadlock if all threads in +global_io_executor will block on while asking. It's fine to use it form outside of actors and +global_io_executor.
    • +
    • Reference#ask! +Sends the message synchronously and blocks until the message +is processed. Raises on error.
    • +
    + +

    Messages are processed in same order as they are sent by a sender. It may interleaved with +messages from other senders though.

    + +

    Immutability

    + +

    Messages sent between actors should be immutable. Gems like

    + +
      +
    • Algebrick - Typed struct on steroids based on +algebraic types and pattern matching
    • +
    • Hamster - Efficient, Immutable, Thread-Safe +Collection classes for Ruby
    • +
    + +

    are very helpful.

    + +

    require 'algebrick'                                # => true
    +
    +# Actor message protocol definition with Algebrick
    +Protocol = Algebrick.type do
    +  variants Add      = type { fields! a: Numeric, b: Numeric },
    +           Subtract = type { fields! a: Numeric, b: Numeric }
    +end                                                # => Protocol(Add | Subtract)
    +
    +class Calculator < Concurrent::Actor::RestartingContext
    +  include Algebrick::Matching
    +
    +  def on_message(message)
    +    # pattern matching on the message with deconstruction
    +    # ~ marks values which are passed to the block
    +    match message,
    +          (on Add.(~any, ~any) do |a, b|
    +            a + b
    +          end),
    +          # or using multi-assignment
    +          (on ~Subtract do |(a, b)|
    +            a - b
    +          end)
    +  end
    +end 
    +
    +calculator = Calculator.spawn('calculator')
    +    # => #<Concurrent::Actor::Reference:0x7fbedba52d90 /calculator (Calculator)>
    +addition = calculator.ask Add[1, 2]
    +    # => <#Concurrent::Promises::Future:0x7fbedc05f7b0 pending>
    +subtraction = calculator.ask Subtract[1, 0.5]
    +    # => <#Concurrent::Promises::Future:0x7fbedd891388 pending>
    +results = (addition & subtraction)
    +    # => <#Concurrent::Promises::Future:0x7fbedc04eeb0 pending>
    +results.value!                                     # => [3, 0.5]
    +
    +calculator.ask! :terminate!                        # => true

    + +

    Actor definition

    + +

    New actor is defined by subclassing RestartingContext, Context and defining its abstract methods. +AbstractContext can be subclassed directly to implement more specific behaviour see Root implementation.

    + + + +

    Example of ac actor definition:

    + +

    Message = Struct.new :action, :value 
    +
    +class AnActor < Concurrent::Actor::RestartingContext
    +  def initialize(init)
    +    @counter = init
    +  end
    +
    +  # override #on_message to define actor's behaviour on message received
    +  def on_message(message)
    +    case message.action
    +    when :add
    +      @counter = @counter + message.value
    +    when :subtract
    +      @counter = @counter - message.value
    +    when :value
    +      @counter
    +    else
    +      pass
    +    end
    +  end
    +
    +  # set counter to zero when there is an error
    +  def on_event(event)
    +    if event == :reset
    +      @counter = 0 # ignore initial value
    +    end
    +  end
    +end 
    +
    +an_actor = AnActor.spawn name: 'an_actor', args: 10 
    +an_actor << Message.new(:add, 1) << Message.new(:subtract, 2) 
    +an_actor.ask!(Message.new(:value, nil))            # => 9
    +an_actor << :boo << Message.new(:add, 1) 
    +an_actor.ask!(Message.new(:value, nil))            # => 1
    +an_actor << :terminate!
    +    # => #<Concurrent::Actor::Reference:0x7fbedc137688 /an_actor (AnActor)>

    + +

    See methods of AbstractContext what else can be tweaked, e.g AbstractContext#default_reference_class

    + +

    Reference

    + +

    Reference is public interface of Actor instances. It is used for sending messages and can +be freely passed around the application. It also provides some basic information about the actor, +see PublicDelegations.

    + +
    AdHoc.spawn('printer') { -> message { puts message } }
    +# => #<Concurrent::Actor::Reference:0x7fd0d2883218 /printer (Concurrent::Actor::Utils::AdHoc)>
    +#                                   ^object_id     ^path     ^context class
    +
    +

    + +

    Garbage collection

    + +

    Spawned actor cannot be garbage-collected until it's terminated. There is a reference held in the parent actor.

    + +

    Parent-child relationship, name, and path

    + +
      +
    • Core#name +The name of actor instance, it should be uniq (not enforced). Allows easier orientation +between actor instances.
    • +
    • Core#path +Path of this actor. It is used for easier orientation and logging. +Path is constructed recursively with: parent.path + self.name up to a Actor.root, +e.g. /an_actor/its_child.
    • +
    • Core#parent +A parent Actor. When actor is spawned the Actor.current becomes its parent. +When actor is spawned from a thread outside of an actor (Actor.current is nil) Actor.root is assigned.
    • +
    + +

    Behaviour

    + +

    Actors have modular architecture, which is achieved by combining a light core with chain of +behaviours. Each message or internal event propagates through the chain allowing the +behaviours react based on their responsibility.

    + +
      +
    • Behaviour::Linking:

      + +
      +

      Links the actor to other actors and sends actor's events to them, +like: :terminated, :paused, :resumed, errors, etc. +Linked actor needs to handle those messages.

      + +
      listener = AdHoc.spawn name: :listener do
      +  lambda do |message|
      +    case message
      +    when Reference
      +      if message.ask!(:linked?)
      +        message << :unlink
      +      else
      +        message << :link
      +      end
      +    else
      +      puts "got event #{message.inspect} from #{envelope.sender}"
      +    end
      +  end
      +end
      +
      +an_actor = AdHoc.spawn name: :an_actor, supervise: true, behaviour_definition: Behaviour.restarting_behaviour_definition do
      +  lambda { |message| raise 'failed'}
      +end
      +
      +# link the actor
      +listener.ask(an_actor).wait
      +an_actor.ask(:fail).wait
      +# unlink the actor
      +listener.ask(an_actor).wait
      +an_actor.ask(:fail).wait
      +an_actor << :terminate!
      +
      + +

      produces only two events, other events happened after unlinking

      + +
      got event #<RuntimeError: failed> from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
      +got event :reset from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
      +
      +

      +
    • +
    • Behaviour::Awaits:

      + +
      +

      Accepts :await messages. Which allows to wait on Actor to process all previously send +messages.

      + +
      actor << :a << :b
      +actor.ask(:await).wait # blocks until :a and :b are processed
      +
      +

      +
    • +
    • Behaviour::Pausing:

      + +
      +

      Allows to pause actors on errors. +When paused all arriving messages are collected and processed after the actor +is resumed or reset. Resume will simply continue with next message. +Reset also reinitialized context.

      +
    • +
    • Behaviour::Supervising:

      + +
      +

      Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, +or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

      +
    • +
    • Behaviour::Supervising:

      + +
      +

      Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, +or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

      +
    • +
    • Behaviour::ExecutesContext:

      + +
      +

      Delegates messages and events to AbstractContext instance.

      +
    • +
    • Behaviour::ErrorsOnUnknownMessage:

      + +
      +

      Simply fails when message arrives here. It's usually the last behaviour.

      +
    • +
    • Behaviour::Termination:

      + +
      +

      Handles actor termination. Waits until all its children are terminated, +can be configured on behaviour initialization.

      +
    • +
    • Behaviour::RemovesChild:

      + +
      +

      Removes terminated children.

      +
    • +
    + +

    If needed new behaviours can be added, or old one removed to get required behaviour.

    + + +

    + +

    IO cooperation

    + +

    Actors are running on shared thread poll which allows user to create many actors cheaply. +Downside is that these actors cannot be directly used to do IO or other blocking operations. +Blocking operations could starve the default_task_pool. However there are two options:

    + +
      +
    • Create an regular actor which will schedule blocking operations in global_operation_pool +(which is intended for blocking operations) sending results back to self in messages.
    • +
    • Create an actor using global_operation_pool instead of global_task_pool, e.g. +AnIOActor.spawn name: :blocking, executor: Concurrent.configuration.global_operation_pool.
    • +
    + +

    Example

    + +

    require 'concurrent'                               # => false
    +
    +# logger = Logger.new(STDOUT)
    +# Concurrent.configuration.logger = logger.method(:add)
    +
    +# First option is to use operation pool
    +
    +class ActorDoingIO < Concurrent::Actor::RestartingContext
    +  def on_message(message)
    +    # do IO operation
    +  end
    +
    +  def default_executor
    +    Concurrent.global_io_executor
    +  end
    +end 
    +
    +actor_doing_io = ActorDoingIO.spawn :actor_doing_io
    +    # => #<Concurrent::Actor::Reference:0x7fbedc146e80 /actor_doing_io (ActorDoingIO)>
    +actor_doing_io.executor == Concurrent.global_io_executor
    +    # => true
    +
    +# It can be also built into a pool so there is not too many IO operations
    +
    +class IOWorker < Concurrent::Actor::Context
    +  def on_message(io_job)
    +    # do IO work
    +    sleep 0.1
    +    puts "#{path} second:#{(Time.now.to_f*100).floor} message:#{io_job}"
    +  end
    +
    +  def default_executor
    +    Concurrent.global_io_executor
    +  end
    +end 
    +
    +pool = Concurrent::Actor::Utils::Pool.spawn('pool', 2) do |index|
    +  IOWorker.spawn(name: "worker-#{index}")
    +end
    +    # => #<Concurrent::Actor::Reference:0x7fbedba83378 /pool (Concurrent::Actor::Utils::Pool)>
    +
    +pool << 1 << 2 << 3 << 4 << 5 << 6
    +    # => #<Concurrent::Actor::Reference:0x7fbedba83378 /pool (Concurrent::Actor::Utils::Pool)>
    +
    +# prints two lines each second
    +# /pool/worker-0 second:1414677666 message:1
    +# /pool/worker-1 second:1414677666 message:2
    +# /pool/worker-0 second:1414677667 message:3
    +# /pool/worker-1 second:1414677667 message:4
    +# /pool/worker-0 second:1414677668 message:5
    +# /pool/worker-1 second:1414677668 message:6
    +
    +sleep 1                                            # => 1

    + +

    Dead letter routing

    + +

    see AbstractContext#dead_letter_routing description:

    + +
    +

    Defines an actor responsible for dead letters. Any rejected message send +with Reference#tell is sent there, a message with future is considered +already monitored for failures. Default behaviour is to use +AbstractContext#dead_letter_routing of the parent, so if no +AbstractContext#dead_letter_routing method is overridden in +parent-chain the message ends up in Actor.root.dead_letter_routing +agent which will log warning.

    +
    + +

    FAQ

    + +

    What happens if I try to supervise using a normal Context?

    + +

    Alleged supervisor will receive errors from its supervised actors. They'll have to be handled manually.

    + +

    How to change supervision strategy?

    + +

    Use option behaviour_definition: Behaviour.restarting_behaviour_definition(:resume!) or +behaviour_definition: Behaviour.restarting_behaviour_definition(:reset!, :one_for_all)

    + +

    How to change behaviors?

    + +

    Any existing behavior can be subclassed

    + +

    How to implement custom restarting?

    + +

    By subclassing Behaviour::Pausing and overriding Behaviour::Pausing#restart!. Implementing +AbstractContext#on_event could be also considered.

    + +

    We'll be happy to answer any other questions, +just open an Issue or find us on +https://gitter.im/ruby-concurrency/concurrent-ruby.

    + +

    Speed

    + +

    Simple benchmark Actor vs Celluloid, the numbers are looking good +but you know how it is with benchmarks. Source code is in +examples/actor/celluloid_benchmark.rb. It sends numbers between x actors +and adding 1 until certain limit is reached.

    + +

    Benchmark legend:

    + +
      +
    • mes. - number of messages send between the actors
    • +
    • act. - number of actors exchanging the messages
    • +
    • impl. - which gem is used
    • +
    + +

    JRUBY

    + +
    Rehearsal ---------------------------------------------------------
    +50000    2 concurrent  26.140000   0.610000  26.750000 (  7.761000)
    +50000    2 celluloid   41.440000   5.270000  46.710000 ( 17.535000)
    +50000  500 concurrent  11.340000   0.180000  11.520000 (  3.498000)
    +50000  500 celluloid   19.310000  10.680000  29.990000 ( 14.619000)
    +50000 1000 concurrent  10.640000   0.180000  10.820000 (  3.563000)
    +50000 1000 celluloid   17.840000  19.850000  37.690000 ( 18.892000)
    +50000 1500 concurrent  14.120000   0.290000  14.410000 (  4.618000)
    +50000 1500 celluloid   19.060000  28.920000  47.980000 ( 25.185000)
    +---------------------------------------------- total: 225.870000sec
    +
    + mes. act.      impl.       user     system      total        real
    +50000    2 concurrent   7.320000   0.530000   7.850000 (  3.637000)
    +50000    2 celluloid   13.780000   4.730000  18.510000 ( 10.756000)
    +50000  500 concurrent   9.270000   0.140000   9.410000 (  3.020000)
    +50000  500 celluloid   16.540000  10.920000  27.460000 ( 14.308000)
    +50000 1000 concurrent   9.970000   0.160000  10.130000 (  3.445000)
    +50000 1000 celluloid   15.930000  20.840000  36.770000 ( 18.272000)
    +50000 1500 concurrent  11.580000   0.240000  11.820000 (  3.723000)
    +50000 1500 celluloid   19.440000  29.060000  48.500000 ( 25.227000) (1)
    +
    + +

    MRI 2.1.0

    + +
    Rehearsal ---------------------------------------------------------
    +50000    2 concurrent   4.180000   0.080000   4.260000 (  4.269435)
    +50000    2 celluloid    7.740000   3.100000  10.840000 ( 10.043875)
    +50000  500 concurrent   5.900000   1.310000   7.210000 (  6.565067)
    +50000  500 celluloid   12.820000   5.810000  18.630000 ( 17.320765)
    +50000 1000 concurrent   6.080000   1.640000   7.720000 (  6.931294)
    +50000 1000 celluloid   17.130000   8.320000  25.450000 ( 23.786146)
    +50000 1500 concurrent   6.940000   2.030000   8.970000 (  7.927330)
    +50000 1500 celluloid   20.980000  12.040000  33.020000 ( 30.849578)
    +---------------------------------------------- total: 116.100000sec
    +
    + mes. act.      impl.       user     system      total        real
    +50000    2 concurrent   3.730000   0.100000   3.830000 (  3.822688)
    +50000    2 celluloid    7.900000   2.910000  10.810000 (  9.924014)
    +50000  500 concurrent   5.420000   1.230000   6.650000 (  6.025579)
    +50000  500 celluloid   12.720000   5.540000  18.260000 ( 16.889517)
    +50000 1000 concurrent   5.420000   0.910000   6.330000 (  5.896689)
    +50000 1000 celluloid   16.090000   8.040000  24.130000 ( 22.347102)
    +50000 1500 concurrent   5.580000   0.760000   6.340000 (  6.038535)
    +50000 1500 celluloid   20.000000  11.680000  31.680000 ( 29.590774) (1)
    +
    + +

    Note (1): Celluloid is using thread per actor so this bench is creating about 1500 +native threads. Actor is using constant number of threads.

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + Modules: Behaviour, InternalDelegations, PublicDelegations, TypeCheck, Utils + + + + Classes: AbstractContext, ActorTerminated, Context, Core, DefaultDeadLetterHandler, Envelope, Reference, RestartingContext, Root, UnknownMessage + + +

    + + +

    + Constant Summary + collapse +

    + +
    + +
    Error = +
    +
    + + +
    +
    +
    + + +
    +
    +
    Class.new(StandardError)
    + +
    + + + + + + + + + +

    + Class Method Summary + collapse +

    + + + + + + +
    +

    Class Method Details

    + + +
    +

    + + .currentReference? + + + + + +

    +
    +

    Returns current executing actor if any

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Reference, nil) + + + + — +

      current executing actor if any

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib-edge/concurrent/actor.rb', line 33
    +
    +def self.current
    +  Thread.current[:__current_actor__]
    +end
    +
    +
    + +
    +

    + + .rootundocumented + + + + + +

    +
    +

    A root actor, a default parent of all actors spawned outside an actor

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +
    +
    # File 'lib-edge/concurrent/actor.rb', line 48
    +
    +def self.root
    +  @root.value!
    +end
    +
    +
    + +
    +

    + + .spawn(*args, &block) ⇒ Reference + + + + + +

    +
    +

    Spawns a new actor. Concurrent::Actor::AbstractContext.spawn allows to omit class parameter. +To see the list of available options see Concurrent::Actor::Core#initialize

    + + +
    +
    +
    + +
    +

    Examples:

    + + +

    by class and name

    +

    + +
    Actor.spawn(AdHoc, :ping1) { -> message { message } }
    + + +

    by option hash

    +

    + +
    inc2 = Actor.spawn(class:    AdHoc,
    +                   name:     'increment by 2',
    +                   args:     [2],
    +                   executor: Concurrent.global_io_executor) do |increment_by|
    +  lambda { |number| number + increment_by }
    +end
    +inc2.ask!(2) # => 4
    + +
    +

    Parameters:

    +
      + +
    • + + block + + + + + + + — +

      for context_class instantiation

      +
      + +
    • + +
    • + + args + + + + + + + — + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Reference) + + + + — +

      never the actual actor

      +
      + +
    • + +
    + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +
    +
    # File 'lib-edge/concurrent/actor.rb', line 71
    +
    +def self.spawn(*args, &block)
    +  options = to_spawn_options(*args)
    +  if options[:executor] && options[:executor].is_a?(ImmediateExecutor)
    +    raise ArgumentError, 'ImmediateExecutor is not supported'
    +  end
    +  if Actor.current
    +    Core.new(options.merge(parent: Actor.current), &block).reference
    +  else
    +    root.ask([:spawn, options, block]).value!
    +  end
    +end
    +
    +
    + +
    +

    + + .spawn!(*args, &block) ⇒ undocumented + + + + + +

    +
    +

    as spawn but it'll block until actor is initialized or it'll raise exception on error

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +84
    +85
    +86
    +
    +
    # File 'lib-edge/concurrent/actor.rb', line 84
    +
    +def self.spawn!(*args, &block)
    +  spawn(to_spawn_options(*args).merge(initialized: future = Concurrent::Promises.resolvable_future), &block).tap { future.wait! }
    +end
    +
    +
    + +
    +

    + + + .to_spawn_options(context_class, name, *args) ⇒ undocumented + + .to_spawn_options(opts) ⇒ undocumented + + + + + + +

    +
    + + +
    +
    +
    + +

    Overloads:

    +
      + + +
    • + .to_spawn_options(context_class, name, *args) ⇒ undocumented +
      +
      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + context_class + + + (AbstractContext) + + + + — +

        to be spawned

        +
        + +
      • + +
      • + + name + + + (String, Symbol) + + + + — +

        of the instance, it's used to generate the +Concurrent::Actor::Core#path of the actor

        +
        + +
      • + +
      • + + args + + + + + + + — +

        for context_class instantiation

        +
        + +
      • + +
      + + +
      +
    • + + +
    • + .to_spawn_options(opts) ⇒ undocumented + +
      + + +
      +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +102
    +103
    +
    +
    # File 'lib-edge/concurrent/actor.rb', line 95
    +
    +def self.to_spawn_options(*args)
    +  if args.size == 1 && args.first.is_a?(::Hash)
    +    args.first
    +  else
    +    { class: args[0],
    +      name:  args[1],
    +      args:  args[2..-1] }
    +  end
    +end
    +
    +
    + +
    + +
    + + + + + +
    + + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/AbstractContext.html b/docs/1.1.0/Concurrent/Actor/AbstractContext.html new file mode 100644 index 000000000..342ff025f --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/AbstractContext.html @@ -0,0 +1,2554 @@ + + + + + + + Class: Concurrent::Actor::AbstractContext + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Concurrent::Actor::AbstractContext + Abstract + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    InternalDelegations, TypeCheck
    +
    + + + + + + +
    +
    Defined in:
    +
    lib-edge/concurrent/actor/context.rb
    +
    + +
    + +

    Overview

    +
    +
    + This class is abstract. + +
    +

    New actor is defined by subclassing RestartingContext, Context and defining its abstract methods. +AbstractContext can be subclassed directly to implement more specific behaviour see Root implementation.

    + + + +

    Example of ac actor definition:

    + +

    Message = Struct.new :action, :value 
    +
    +class AnActor < Concurrent::Actor::RestartingContext
    +  def initialize(init)
    +    @counter = init
    +  end
    +
    +  # override #on_message to define actor's behaviour on message received
    +  def on_message(message)
    +    case message.action
    +    when :add
    +      @counter = @counter + message.value
    +    when :subtract
    +      @counter = @counter - message.value
    +    when :value
    +      @counter
    +    else
    +      pass
    +    end
    +  end
    +
    +  # set counter to zero when there is an error
    +  def on_event(event)
    +    if event == :reset
    +      @counter = 0 # ignore initial value
    +    end
    +  end
    +end 
    +
    +an_actor = AnActor.spawn name: 'an_actor', args: 10 
    +an_actor << Message.new(:add, 1) << Message.new(:subtract, 2) 
    +an_actor.ask!(Message.new(:value, nil))            # => 9
    +an_actor << :boo << Message.new(:add, 1) 
    +an_actor.ask!(Message.new(:value, nil))            # => 1
    +an_actor << :terminate!
    +    # => #<Concurrent::Actor::Reference:0x7fbedc137688 /an_actor (AnActor)>

    + +

    See methods of AbstractContext what else can be tweaked, e.g #default_reference_class

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    Context, RestartingContext, Root

    +
    + + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #coreundocumented (readonly) + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 28
    +
    +def core
    +  @core
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .spawn(name_or_opts, *args, &block) ⇒ undocumented + + + + + +

    +
    +

    Behaves as Concurrent::Actor.spawn but :class is auto-inserted based on receiver so it can be omitted.

    + + +
    +
    +
    + +
    +

    Examples:

    + + +

    by class and name

    +

    + +
    AdHoc.spawn(:ping1) { -> message { message } }
    + + +

    by option hash

    +

    + +
    inc2 = AdHoc.spawn(name:     'increment by 2',
    +                   args:     [2],
    +                   executor: Concurrent.configuration.global_task_pool) do |increment_by|
    +  lambda { |number| number + increment_by }
    +end
    +inc2.ask!(2) # => 4
    + +
    + + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +115
    +116
    +117
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 115
    +
    +def self.spawn(name_or_opts, *args, &block)
    +  Actor.spawn to_spawn_options(name_or_opts, *args), &block
    +end
    +
    +
    + +
    +

    + + .spawn!(name_or_opts, *args, &block) ⇒ undocumented + + + + + +

    +
    +

    behaves as Concurrent::Actor.spawn! but :class is auto-inserted based on receiver so it can be omitted.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +120
    +121
    +122
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 120
    +
    +def self.spawn!(name_or_opts, *args, &block)
    +  Actor.spawn! to_spawn_options(name_or_opts, *args), &block
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #ask(message) ⇒ undocumented + + + + Also known as: + ask! + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +96
    +97
    +98
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 96
    +
    +def ask(message)
    +  raise 'actor cannot ask itself'
    +end
    +
    +
    + +
    +

    + + #behaviour(behaviour_class) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    +

    see Core#behaviour

    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #behaviour!(behaviour_class) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    +

    see Core#behaviour!

    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #behaviour_definitionArray<Array(Behavior::Abstract, Array<Object>)> + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    + +

    Raises:

    +
      + +
    • + + + (NotImplementedError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +70
    +71
    +72
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 70
    +
    +def behaviour_definition
    +  raise NotImplementedError
    +end
    +
    +
    + +
    +

    + + #Child!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #Child?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    +
    + +
    +

    + + #childrenundocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #contextAbstractContext + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    + + +
    +
    +
    + +

    Returns:

    + + +
    +
    + +
    +

    + + #context_classundocumented + + + + Also known as: + actor_class + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #dead_letter_routingReference + + + + + +

    +
    +

    Defines an actor responsible for dead letters. Any rejected message send +with Reference#tell is sent there, a message with future is considered +already monitored for failures. Default behaviour is to use +#dead_letter_routing of the parent, so if no +#dead_letter_routing method is overridden in +parent-chain the message ends up in Actor.root.dead_letter_routing +agent which will log warning.

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +65
    +66
    +67
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 65
    +
    +def dead_letter_routing
    +  parent.dead_letter_routing
    +end
    +
    +
    + +
    +

    + + #default_executorExecutor + + + + + +

    +
    +

    override to se different default executor, e.g. to change it to global_operation_pool

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Executor) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +87
    +88
    +89
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 87
    +
    +def default_executor
    +  Concurrent.global_io_executor
    +end
    +
    +
    + +
    +

    + + #default_reference_classCLass + + + + + +

    +
    +

    override if different class for reference is needed

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (CLass) + + + + — +

      descendant of Reference

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +81
    +82
    +83
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 81
    +
    +def default_reference_class
    +  Reference
    +end
    +
    +
    + +
    +

    + + #envelopeEnvelope + + + + + +

    +
    +

    Returns current envelope, accessible inside #on_message processing

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Envelope) + + + + — +

      current envelope, accessible inside #on_message processing

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +75
    +76
    +77
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 75
    +
    +def envelope
    +  @envelope or raise 'envelope not set'
    +end
    +
    +
    + +
    +

    + + #executorundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #log(level, message = nil, &block) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    +

    delegates to core.log

    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • Logging#log
    • + +
    + +
    +
    + +
    +

    + + #Match!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #Match?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    +
    + +
    +

    + + #nameundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #on_envelope(envelope) ⇒ undocumented + + + + + +

    +
    +

    + This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +47
    +48
    +49
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 44
    +
    +def on_envelope(envelope)
    +  @envelope = envelope
    +  on_message envelope.message
    +ensure
    +  @envelope = nil
    +end
    +
    +
    + +
    +

    + + #on_event(event) ⇒ undocumented + + + + + +

    +
    +

    override to add custom code invocation on internal events like :terminated, :resumed, anError.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +40
    +41
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 40
    +
    +def on_event(event)
    +end
    +
    +
    + +
    +

    + + #on_message(message) ⇒ Object + + + + + +

    +
    +
    + This method is abstract. +

    override to define Actor's behaviour

    +
    +
    + +
    + Note: +

    self should not be returned (or sent to other actors), PublicDelegations#reference should be used +instead

    +
    +
    + +

    Returns a result which will be used to set the Future supplied to Reference#ask

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message + + + (Object) + + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +

      a result which will be used to set the Future supplied to Reference#ask

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (NotImplementedError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 35
    +
    +def on_message(message)
    +  raise NotImplementedError
    +end
    +
    +
    + +
    +

    + + #parentundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #passundocumented + + + + + +

    +
    +

    if you want to pass the message to next behaviour, usually +Behaviour::ErrorsOnUnknownMessage

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +53
    +54
    +55
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 53
    +
    +def pass
    +  core.behaviour!(Behaviour::ExecutesContext).pass envelope
    +end
    +
    +
    + +
    +

    + + #pathundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #redirect(reference, envelope = self.envelope) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #referenceundocumented + + + + Also known as: + ref + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #tell(message) ⇒ undocumented + + + + Also known as: + << + + + + +

    +
    +

    tell self a message

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +92
    +93
    +94
    +
    +
    # File 'lib-edge/concurrent/actor/context.rb', line 92
    +
    +def tell(message)
    +  reference.tell message
    +end
    +
    +
    + +
    +

    + + #terminate!(reason = nil) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • Termination#terminate!
    • + +
    + +
    +
    + +
    +

    + + #terminated?Boolean + + + + + + + Originally defined in module + InternalDelegations + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • Termination#terminated?
    • + +
    + +
    +
    + +
    +

    + + #Type!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + + +
    +
    + +
    +

    + + #Type?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    +
    + +
    + +
    + + + + + +
    + + \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/ActressTerminated.html b/docs/1.1.0/Concurrent/Actor/ActorTerminated.html similarity index 50% rename from docs/1.0.5/Concurrent/Actress/ActressTerminated.html rename to docs/1.1.0/Concurrent/Actor/ActorTerminated.html index 91b607208..aa41d9bdc 100644 --- a/docs/1.0.5/Concurrent/Actress/ActressTerminated.html +++ b/docs/1.1.0/Concurrent/Actor/ActorTerminated.html @@ -1,12 +1,12 @@ - - + + - + + - Class: Concurrent::Actress::ActressTerminated + Class: Concurrent::Actor::ActorTerminated - — Concurrent + — Concurrent Ruby @@ -15,9 +15,8 @@ @@ -28,84 +27,127 @@ -

-
# File 'lib/concurrent/actress/errors.rb', line 8
+      
# File 'lib-edge/concurrent/actor/errors.rb', line 10
 
 def initialize(reference)
-  Type! reference, Reference
+  @reference = Type! reference, Reference
   super reference.path
 end
@@ -357,6 +399,52 @@

+
+

Instance Attribute Details

+ + + +
+

+ + #referenceundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib-edge/concurrent/actor/errors.rb', line 8
+
+def reference
+  @reference
+end
+
+
+ +
+

Instance Method Details

@@ -365,7 +453,7 @@

Instance Method Details

- - (Object) Child!(value, *types) + #Child!(value, *types) ⇒ undocumented @@ -373,16 +461,25 @@

Originally defined in module - TypeCheck + TypeCheck -

+

+
+ + +
+
+
+ + +

- - (Boolean) Child?(value, *types) + #Child?(value, *types) ⇒ Boolean @@ -390,7 +487,7 @@

Originally defined in module - TypeCheck + TypeCheck

@@ -421,7 +518,7 @@

- - (Object) Match!(value, *types) + #Match!(value, *types) ⇒ undocumented @@ -429,16 +526,25 @@

Originally defined in module - TypeCheck + TypeCheck -

+

+
+ + +
+
+
+ + +

- - (Boolean) Match?(value, *types) + #Match?(value, *types) ⇒ Boolean @@ -446,7 +552,7 @@

Originally defined in module - TypeCheck + TypeCheck

@@ -477,7 +583,7 @@

- - (Object) Type!(value, *types) + #Type!(value, *types) ⇒ undocumented @@ -485,16 +591,25 @@

Originally defined in module - TypeCheck + TypeCheck -

+

+
+ + +
+
+
+ + +

- - (Boolean) Type?(value, *types) + #Type?(value, *types) ⇒ Boolean @@ -502,7 +617,7 @@

Originally defined in module - TypeCheck + TypeCheck

@@ -534,21 +649,21 @@

- \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour.html b/docs/1.1.0/Concurrent/Actor/Behaviour.html new file mode 100644 index 000000000..a30491e8d --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour.html @@ -0,0 +1,830 @@ + + + + + + + Module: Concurrent::Actor::Behaviour + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Concurrent::Actor::Behaviour + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour.rb,
+ lib-edge/concurrent/actor/behaviour/awaits.rb,
lib-edge/concurrent/actor/behaviour/buffer.rb,
lib-edge/concurrent/actor/behaviour/linking.rb,
lib-edge/concurrent/actor/behaviour/pausing.rb,
lib-edge/concurrent/actor/behaviour/abstract.rb,
lib-edge/concurrent/actor/behaviour/supervising.rb,
lib-edge/concurrent/actor/behaviour/termination.rb,
lib-edge/concurrent/actor/behaviour/sets_results.rb,
lib-edge/concurrent/actor/behaviour/removes_child.rb,
lib-edge/concurrent/actor/behaviour/executes_context.rb,
lib-edge/concurrent/actor/behaviour/errors_on_unknown_message.rb
+
+
+ +
+ +

Overview

+
+

Actors have modular architecture, which is achieved by combining a light core with chain of +behaviours. Each message or internal event propagates through the chain allowing the +behaviours react based on their responsibility.

+ +
    +
  • Linking:

    + +
    +

    Links the actor to other actors and sends actor's events to them, +like: :terminated, :paused, :resumed, errors, etc. +Linked actor needs to handle those messages.

    + +
    listener = AdHoc.spawn name: :listener do
    +  lambda do |message|
    +    case message
    +    when Reference
    +      if message.ask!(:linked?)
    +        message << :unlink
    +      else
    +        message << :link
    +      end
    +    else
    +      puts "got event #{message.inspect} from #{envelope.sender}"
    +    end
    +  end
    +end
    +
    +an_actor = AdHoc.spawn name: :an_actor, supervise: true, behaviour_definition: Behaviour.restarting_behaviour_definition do
    +  lambda { |message| raise 'failed'}
    +end
    +
    +# link the actor
    +listener.ask(an_actor).wait
    +an_actor.ask(:fail).wait
    +# unlink the actor
    +listener.ask(an_actor).wait
    +an_actor.ask(:fail).wait
    +an_actor << :terminate!
    +
    + +

    produces only two events, other events happened after unlinking

    + +
    got event #<RuntimeError: failed> from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
    +got event :reset from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
    +
    +

    +
  • +
  • Awaits:

    + +
    +

    Accepts :await messages. Which allows to wait on Actor to process all previously send +messages.

    + +
    actor << :a << :b
    +actor.ask(:await).wait # blocks until :a and :b are processed
    +
    +

    +
  • +
  • Pausing:

    + +
    +

    Allows to pause actors on errors. +When paused all arriving messages are collected and processed after the actor +is resumed or reset. Resume will simply continue with next message. +Reset also reinitialized context.

    +
  • +
  • Supervising:

    + +
    +

    Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, +or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

    +
  • +
  • Supervising:

    + +
    +

    Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, +or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

    +
  • +
  • ExecutesContext:

    + +
    +

    Delegates messages and events to AbstractContext instance.

    +
  • +
  • ErrorsOnUnknownMessage:

    + +
    +

    Simply fails when message arrives here. It's usually the last behaviour.

    +
  • +
  • Termination:

    + +
    +

    Handles actor termination. Waits until all its children are terminated, +can be configured on behaviour initialization.

    +
  • +
  • RemovesChild:

    + +
    +

    Removes terminated children.

    +
  • +
+ +

If needed new behaviours can be added, or old one removed to get required behaviour.

+ + + + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: Abstract, Awaits, Buffer, ErrorsOnUnknownMessage, ExecutesContext, Linking, Pausing, RemovesChild, SetResults, Supervising, Termination + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
MESSAGE_PROCESSED = +
+
+ + +
+
+
+ + +
+
+
::Object.new
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .base(on_error) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+105
+106
+107
+108
+109
+110
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 105
+
+def self.base(on_error)
+  [[SetResults, on_error],
+   # has to be before Termination to be able to remove children from terminated actor
+   RemovesChild,
+   Termination]
+end
+
+
+ +
+

+ + .basic_behaviour_definitionundocumented + + + + + +

+
+

Array of behaviours and their construction parameters.

+ +
[[Behaviour::SetResults, :terminate!],
+ [Behaviour::RemovesChild],
+ [Behaviour::Termination],
+ [Behaviour::Linking],
+ [Behaviour::Awaits],
+ [Behaviour::ExecutesContext],
+ [Behaviour::ErrorsOnUnknownMessage]]
+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+77
+78
+79
+80
+81
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 77
+
+def self.basic_behaviour_definition
+  [*base(:terminate!),
+   *linking,
+   *user_messages]
+end
+
+
+ +
+

+ + .linkingundocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+113
+114
+115
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 113
+
+def self.linking
+  [Linking]
+end
+
+
+ +
+

+ + .restarting_behaviour_definition(handle = :reset!, strategy = :one_for_one) ⇒ undocumented + + + + + +

+
+

Array of behaviours and their construction parameters.

+ +
[[Behaviour::SetResults, :pause!],
+ [Behaviour::RemovesChild],
+ [Behaviour::Termination],
+ [Behaviour::Linking],
+ [Behaviour::Pausing],
+ [Behaviour::Supervising, :reset!, :one_for_one],
+ [Behaviour::Awaits],
+ [Behaviour::ExecutesContext],
+ [Behaviour::ErrorsOnUnknownMessage]]
+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+96
+97
+98
+99
+100
+101
+102
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 96
+
+def self.restarting_behaviour_definition(handle = :reset!, strategy = :one_for_one)
+  [*base(:pause!),
+   *linking,
+   *supervised,
+   *supervising(handle, strategy),
+   *user_messages]
+end
+
+
+ +
+

+ + .supervisedundocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 118
+
+def self.supervised
+  [Pausing]
+end
+
+
+ +
+

+ + .supervising(handle = :reset!, strategy = :one_for_one) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+123
+124
+125
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 123
+
+def self.supervising(handle = :reset!, strategy = :one_for_one)
+  [[Behaviour::Supervising, handle, strategy]]
+end
+
+
+ +
+

+ + .user_messagesundocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • its source code
  • + +
+ +
+ + + + +
+
+
+
+128
+129
+130
+131
+132
+
+
# File 'lib-edge/concurrent/actor/behaviour.rb', line 128
+
+def self.user_messages
+  [Awaits,
+   ExecutesContext,
+   ErrorsOnUnknownMessage]
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Abstract.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Abstract.html new file mode 100644 index 000000000..4bd64501c --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Abstract.html @@ -0,0 +1,2019 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Abstract + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Abstract + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
InternalDelegations, TypeCheck
+
+ + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/abstract.rb
+
+ +
+ +
+
+ + +
+
+
+ + +
+ + + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options) ⇒ Abstract + + + + + +

+
+

Returns a new instance of Abstract

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 12
+
+def initialize(core, subsequent, core_options)
+  @core       = Type! core, Core
+  @subsequent = Type! subsequent, Abstract, NilClass
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #coreundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 10
+
+def core
+  @core
+end
+
+
+ + + +
+

+ + #subsequentundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 10
+
+def subsequent
+  @subsequent
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #behaviour(behaviour_class) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+

see Core#behaviour

+ + +
+
+
+ + +
+
+ +
+

+ + #behaviour!(behaviour_class) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+

see Core#behaviour!

+ + +
+
+
+ + +
+
+ +
+

+ + #broadcast(public, event) ⇒ undocumented + + + + + +

+
+

broadcasts event to all behaviours and context

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 37
+
+def broadcast(public, event)
+  core.broadcast(public, event)
+end
+
+
+ +
+

+ + #Child!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Child?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+

+ + #childrenundocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #contextAbstractContext + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ +

Returns:

+ + +
+
+ +
+

+ + #context_classundocumented + + + + Also known as: + actor_class + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #dead_letter_routingundocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #executorundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #log(level, message = nil, &block) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+

delegates to core.log

+ + +
+
+
+ + +

See Also:

+
    + +
  • Logging#log
  • + +
+ +
+
+ +
+

+ + #Match!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Match?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+

+ + #nameundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ +
+ Note: +

super needs to be called not to break the chain

+
+
+ +

override to add extra behaviour

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 19
+
+def on_envelope(envelope)
+  pass envelope
+end
+
+
+ +
+

+ + #on_event(public, event) ⇒ undocumented + + + + + +

+
+ +
+ Note: +

super needs to be called not to break the chain

+
+
+ +

override to add extra behaviour

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 30
+
+def on_event(public, event)
+  subsequent.on_event public, event if subsequent
+end
+
+
+ +
+

+ + #parentundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #pass(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+

Parameters:

+ + + +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 24
+
+def pass(envelope)
+  subsequent.on_envelope envelope
+end
+
+
+ +
+

+ + #pathundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #redirect(reference, envelope = self.envelope) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #referenceundocumented + + + + Also known as: + ref + + + + + + Originally defined in module + PublicDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+
+ +
+

+ + #reject_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+41
+42
+43
+44
+45
+
+
# File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 41
+
+def reject_envelope(envelope)
+  envelope.reject! ActorTerminated.new(reference)
+  dead_letter_routing << envelope unless envelope.future
+  log(DEBUG) { "rejected #{envelope.message} from #{envelope.sender_path}"}
+end
+
+
+ +
+

+ + #terminate!(reason = nil) ⇒ undocumented + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ + +

See Also:

+
    + +
  • Termination#terminate!
  • + +
+ +
+
+ +
+

+ + #terminated?Boolean + + + + + + + Originally defined in module + InternalDelegations + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +

See Also:

+
    + +
  • Termination#terminated?
  • + +
+ +
+
+ +
+

+ + #Type!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Type?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Awaits.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Awaits.html new file mode 100644 index 000000000..eecd58e13 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Awaits.html @@ -0,0 +1,248 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Awaits + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Awaits + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/awaits.rb
+
+ +
+ +

Overview

+
+

Accepts :await messages. Which allows to wait on Actor to process all previously send +messages.

+ +
actor << :a << :b
+actor.ask(:await).wait # blocks until :a and :b are processed
+
+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lib-edge/concurrent/actor/behaviour/awaits.rb', line 11
+
+def on_envelope(envelope)
+  if envelope.message == :await
+    true
+  else
+    pass envelope
+  end
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Buffer.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Buffer.html new file mode 100644 index 000000000..1d8f5a834 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Buffer.html @@ -0,0 +1,540 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Buffer + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Buffer + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/buffer.rb
+
+ +
+ +

Overview

+
+

Any message reaching this behaviour is buffered. Only one message is is +scheduled at any given time. Others are kept in buffer until another one +can be scheduled. This effectively means that messages handled by +behaviours before buffer have higher priority and they can be processed +before messages arriving into buffer. This allows for the processing of +internal actor messages like (:link, :supervise) first.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options) ⇒ Buffer + + + + + +

+
+

Returns a new instance of Buffer

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+16
+
+
# File 'lib-edge/concurrent/actor/behaviour/buffer.rb', line 12
+
+def initialize(core, subsequent, core_options)
+  super core, subsequent, core_options
+  @buffer                     = []
+  @receive_envelope_scheduled = false
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+
+
# File 'lib-edge/concurrent/actor/behaviour/buffer.rb', line 18
+
+def on_envelope(envelope)
+  @buffer.push envelope
+  process_envelopes?
+  MESSAGE_PROCESSED
+end
+
+
+ +
+

+ + #on_event(public, event) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+47
+48
+49
+50
+51
+52
+
+
# File 'lib-edge/concurrent/actor/behaviour/buffer.rb', line 44
+
+def on_event(public, event)
+  event_name, _ = event
+  case event_name
+  when :terminated, :restarted
+    @buffer.each { |envelope| reject_envelope envelope }
+    @buffer.clear
+  end
+  super public, event_name
+end
+
+
+ +
+

+ + #process_envelopeundocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+41
+42
+
+
# File 'lib-edge/concurrent/actor/behaviour/buffer.rb', line 35
+
+def process_envelope
+  envelope = @buffer.shift
+  return nil unless envelope
+  pass envelope
+ensure
+  @receive_envelope_scheduled = false
+  core.schedule_execution { process_envelopes? }
+end
+
+
+ +
+

+ + #process_envelopes?Boolean + + + + + +

+
+

Ensures that only one envelope processing is scheduled with #schedule_execution, +this allows other scheduled blocks to be executed before next envelope processing. +Simply put this ensures that Core is still responsive to internal calls (like add_child) +even though the Actor is flooded with messages.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+31
+32
+33
+
+
# File 'lib-edge/concurrent/actor/behaviour/buffer.rb', line 28
+
+def process_envelopes?
+  unless @buffer.empty? || @receive_envelope_scheduled
+    @receive_envelope_scheduled = true
+    process_envelope
+  end
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html b/docs/1.1.0/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html new file mode 100644 index 000000000..96df538a9 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/ErrorsOnUnknownMessage.html @@ -0,0 +1,248 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::ErrorsOnUnknownMessage + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::ErrorsOnUnknownMessage + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/errors_on_unknown_message.rb
+
+ +
+ +

Overview

+
+

Simply fails when message arrives here. It's usually the last behaviour.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib-edge/concurrent/actor/behaviour/errors_on_unknown_message.rb', line 6
+
+def on_envelope(envelope)
+  raise UnknownMessage, envelope
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/ExecutesContext.html b/docs/1.1.0/Concurrent/Actor/Behaviour/ExecutesContext.html new file mode 100644 index 000000000..2ba6b3eac --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/ExecutesContext.html @@ -0,0 +1,298 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::ExecutesContext + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::ExecutesContext + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/executes_context.rb
+
+ +
+ +

Overview

+
+

Delegates messages and events to AbstractContext instance.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib-edge/concurrent/actor/behaviour/executes_context.rb', line 6
+
+def on_envelope(envelope)
+  context.on_envelope envelope
+end
+
+
+ +
+

+ + #on_event(public, event) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib-edge/concurrent/actor/behaviour/executes_context.rb', line 10
+
+def on_event(public, event)
+  context.on_event(event)
+  super public, event
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Linking.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Linking.html new file mode 100644 index 000000000..c39bd8cfc --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Linking.html @@ -0,0 +1,553 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Linking + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Linking + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/linking.rb
+
+ +
+ +

Overview

+
+

Links the actor to other actors and sends actor's events to them, +like: :terminated, :paused, :resumed, errors, etc. +Linked actor needs to handle those messages.

+ +
listener = AdHoc.spawn name: :listener do
+  lambda do |message|
+    case message
+    when Reference
+      if message.ask!(:linked?)
+        message << :unlink
+      else
+        message << :link
+      end
+    else
+      puts "got event #{message.inspect} from #{envelope.sender}"
+    end
+  end
+end
+
+an_actor = AdHoc.spawn name: :an_actor, supervise: true, behaviour_definition: Behaviour.restarting_behaviour_definition do
+  lambda { |message| raise 'failed'}
+end
+
+# link the actor
+listener.ask(an_actor).wait
+an_actor.ask(:fail).wait
+# unlink the actor
+listener.ask(an_actor).wait
+an_actor.ask(:fail).wait
+an_actor << :terminate!
+
+ +

produces only two events, other events happened after unlinking

+ +
got event #<RuntimeError: failed> from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
+got event :reset from #<Concurrent::Actor::Reference /an_actor (Concurrent::Actor::Utils::AdHoc)>
+
+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options) ⇒ Linking + + + + + +

+
+

Returns a new instance of Linking

+ + +
+
+
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+47
+
+
# File 'lib-edge/concurrent/actor/behaviour/linking.rb', line 43
+
+def initialize(core, subsequent, core_options)
+  super core, subsequent, core_options
+  @linked = Set.new
+  @linked.add Actor.current if core_options[:link] != false
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+
+
# File 'lib-edge/concurrent/actor/behaviour/linking.rb', line 64
+
+def link(ref)
+  @linked.add(ref)
+  true
+end
+
+
+ +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib-edge/concurrent/actor/behaviour/linking.rb', line 49
+
+def on_envelope(envelope)
+  case envelope.message
+  when :link
+    link envelope.sender
+  when :unlink
+    unlink envelope.sender
+  when :linked?
+    @linked.include? envelope.sender
+  when :linked
+    @linked.to_a
+  else
+    pass envelope
+  end
+end
+
+
+ +
+

+ + #on_event(public, event) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+74
+75
+76
+77
+78
+79
+
+
# File 'lib-edge/concurrent/actor/behaviour/linking.rb', line 74
+
+def on_event(public, event)
+  event_name, _ = event
+  @linked.each { |a| a << event } if public
+  @linked.clear if event_name == :terminated
+  super public, event
+end
+
+
+ +
+
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+69
+70
+71
+72
+
+
# File 'lib-edge/concurrent/actor/behaviour/linking.rb', line 69
+
+def unlink(ref)
+  @linked.delete(ref)
+  true
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Pausing.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Pausing.html new file mode 100644 index 000000000..9c114c535 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Pausing.html @@ -0,0 +1,757 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Pausing + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Pausing + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/pausing.rb
+
+ +
+ +

Overview

+
+ +
+ Note: +

TODO missing example

+
+
+ +

Allows to pause actors on errors. +When paused all arriving messages are collected and processed after the actor +is resumed or reset. Resume will simply continue with next message. +Reset also reinitialized context.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options) ⇒ Pausing + + + + + +

+
+

Returns a new instance of Pausing

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 11
+
+def initialize(core, subsequent, core_options)
+  super core, subsequent, core_options
+  @paused   = false
+  @deferred = []
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 21
+
+def on_envelope(envelope)
+  case envelope.message
+  when :pause!
+    pause!
+  when :paused?
+    paused?
+  when :resume!
+    resume!
+  when :reset!
+    reset!
+  when :restart!
+    restart!
+  else
+    if paused?
+      @deferred << envelope
+      MESSAGE_PROCESSED
+    else
+      pass envelope
+    end
+  end
+end
+
+
+ +
+

+ + #on_event(public, event) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+72
+73
+74
+75
+76
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 72
+
+def on_event(public, event)
+  event_name, _ = event
+  reject_deferred if event_name == :terminated
+  super public, event
+end
+
+
+ +
+

+ + #pause!(error = nil) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+47
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 43
+
+def pause!(error = nil)
+  do_pause
+  broadcast true, error || :paused
+  true
+end
+
+
+ +
+

+ + #paused?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 17
+
+def paused?
+  @paused
+end
+
+
+ +
+

+ + #reset!undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 56
+
+def reset!
+  return false unless paused?
+  broadcast(false, :resetting)
+  do_reset
+  broadcast(true, :reset)
+  true
+end
+
+
+ +
+

+ + #restart!undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+68
+69
+70
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 64
+
+def restart!
+  return false unless paused?
+  broadcast(false, :restarting)
+  do_restart
+  broadcast(true, :restarted)
+  true
+end
+
+
+ +
+

+ + #resume!undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+
+
# File 'lib-edge/concurrent/actor/behaviour/pausing.rb', line 49
+
+def resume!
+  return false unless paused?
+  do_resume
+  broadcast(true, :resumed)
+  true
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/RemovesChild.html b/docs/1.1.0/Concurrent/Actor/Behaviour/RemovesChild.html new file mode 100644 index 000000000..bd3394a27 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/RemovesChild.html @@ -0,0 +1,243 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::RemovesChild + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::RemovesChild + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/removes_child.rb
+
+ +
+ +

Overview

+
+

Removes terminated children.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Concurrent::Actor::Behaviour::Abstract

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+12
+
+
# File 'lib-edge/concurrent/actor/behaviour/removes_child.rb', line 6
+
+def on_envelope(envelope)
+  if envelope.message == :remove_child
+    core.remove_child envelope.sender
+  else
+    pass envelope
+  end
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/SetResults.html b/docs/1.1.0/Concurrent/Actor/Behaviour/SetResults.html new file mode 100644 index 000000000..70c13185d --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/SetResults.html @@ -0,0 +1,414 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::SetResults + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::SetResults + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/sets_results.rb
+
+ +
+ +

Overview

+
+

Collects returning value and sets the ResolvableFuture in the Envelope or error on failure.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options, error_strategy) ⇒ SetResults + + + + + +

+
+

Returns a new instance of SetResults

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+
+
# File 'lib-edge/concurrent/actor/behaviour/sets_results.rb', line 8
+
+def initialize(core, subsequent, core_options, error_strategy)
+  super core, subsequent, core_options
+  @error_strategy = Match! error_strategy, :just_log, :terminate!, :pause!
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #error_strategyundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib-edge/concurrent/actor/behaviour/sets_results.rb', line 6
+
+def error_strategy
+  @error_strategy
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+
+
# File 'lib-edge/concurrent/actor/behaviour/sets_results.rb', line 13
+
+def on_envelope(envelope)
+  result = pass envelope
+  if result != MESSAGE_PROCESSED && !envelope.future.nil?
+    envelope.future.fulfill result
+    log(DEBUG) { "finished processing of #{envelope.message.inspect}"}
+  end
+  nil
+rescue => error
+  log ERROR, error
+  case error_strategy
+  when :terminate!
+    terminate!
+  when :pause!
+    behaviour!(Pausing).pause!(error)
+  when :just_log
+    # nothing
+  else
+    raise
+  end
+  envelope.future.reject error unless envelope.future.nil?
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Supervising.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Supervising.html new file mode 100644 index 000000000..22c879bb6 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Supervising.html @@ -0,0 +1,350 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Supervising + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Supervising + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/supervising.rb
+
+ +
+ +

Overview

+
+ +
+ Note: +

TODO missing example

+
+
+ +
+ Note: +

this will change in next version to support supervision trees better

+
+
+ +

Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, +or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options, handle, strategy) ⇒ Supervising + + + + + +

+
+

Returns a new instance of Supervising

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib-edge/concurrent/actor/behaviour/supervising.rb', line 10
+
+def initialize(core, subsequent, core_options, handle, strategy)
+  super core, subsequent, core_options
+  @handle   = Match! handle, :terminate!, :resume!, :reset!, :restart!
+  @strategy = case @handle
+              when :terminate!
+                Match! strategy, nil
+              when :resume!
+                Match! strategy, :one_for_one
+              when :reset!, :restart!
+                Match! strategy, :one_for_one, :one_for_all
+              end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+
+
# File 'lib-edge/concurrent/actor/behaviour/supervising.rb', line 23
+
+def on_envelope(envelope)
+  case envelope.message
+  when Exception, :paused
+    receivers = if @strategy == :one_for_all
+                  children
+                else
+                  [envelope.sender]
+                end
+    receivers.each { |ch| ch << @handle }
+  else
+    pass envelope
+  end
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Behaviour/Termination.html b/docs/1.1.0/Concurrent/Actor/Behaviour/Termination.html new file mode 100644 index 000000000..47f51cc7d --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Behaviour/Termination.html @@ -0,0 +1,756 @@ + + + + + + + Class: Concurrent::Actor::Behaviour::Termination + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Behaviour::Termination + + + +

+
+ +
+
Inherits:
+
+ Abstract + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/behaviour/termination.rb
+
+ +
+ +

Overview

+
+ +
+ Note: +

Actor rejects envelopes when terminated.

+
+
+ +
+ Note: +

TODO missing example

+
+
+ +

Handles actor termination. Waits until all its children are terminated, +can be configured on behaviour initialization.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(core, subsequent, core_options, trapping = false, terminate_children = true) ⇒ Termination + + + + + +

+
+

Returns a new instance of Termination

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 15
+
+def initialize(core, subsequent, core_options, trapping = false, terminate_children = true)
+  super core, subsequent, core_options
+  @terminated         = Concurrent::Promises.resolvable_future
+  @public_terminated  = @terminated.with_hidden_resolvable
+  @trapping           = trapping
+  @terminate_children = terminate_children
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #terminatedundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 13
+
+def terminated
+  @terminated
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 37
+
+def on_envelope(envelope)
+  command, reason = envelope.message
+  case command
+  when :terminated?
+    terminated?
+  when :terminate!
+    if trapping? && reason != :kill
+      pass envelope
+    else
+      terminate! reason, envelope
+    end
+  when :termination_event
+    @public_terminated
+  else
+    if terminated?
+      reject_envelope envelope
+      MESSAGE_PROCESSED
+    else
+      pass envelope
+    end
+  end
+end
+
+
+ +
+

+ + #terminate!(reason = nil, envelope = nil) ⇒ undocumented + + + + + +

+
+

Terminates the actor. Any Envelope received after termination is rejected. +Terminates all its children, does not wait until they are terminated.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 62
+
+def terminate!(reason = nil, envelope = nil)
+  return true if terminated?
+
+  self_termination = Concurrent::Promises.resolved_future(reason.nil?, reason.nil? || nil, reason)
+  all_terminations = if @terminate_children
+                       Concurrent::Promises.zip(*children.map { |ch| ch.ask(:terminate!) }, self_termination)
+                     else
+                       self_termination
+                     end
+
+  all_terminations.chain_resolvable(@terminated)
+  if envelope && envelope.future
+    all_terminations.chain { |fulfilled, _, t_reason| envelope.future.resolve fulfilled, true, t_reason }
+  end
+
+  broadcast(true, [:terminated, reason]) # TODO do not end up in Dead Letter Router
+  parent << :remove_child if parent
+
+  MESSAGE_PROCESSED
+end
+
+
+ +
+

+ + #terminated?true, false + + + + + +

+
+ +
+ Note: +

Actor rejects envelopes when terminated.

+
+
+ +

Returns if actor is terminated

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (true, false) + + + + — +

    if actor is terminated

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 25
+
+def terminated?
+  @terminated.resolved?
+end
+
+
+ +
+

+ + #trapping=(val) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 33
+
+def trapping=(val)
+  @trapping = !!val
+end
+
+
+ +
+

+ + #trapping?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib-edge/concurrent/actor/behaviour/termination.rb', line 29
+
+def trapping?
+  @trapping
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Context.html b/docs/1.1.0/Concurrent/Actor/Context.html new file mode 100644 index 000000000..5de6ba043 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Context.html @@ -0,0 +1,239 @@ + + + + + + + Class: Concurrent::Actor::Context + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Context + Abstract + + +

+
+ +
+
Inherits:
+
+ AbstractContext + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/context.rb
+
+ +
+ +

Overview

+
+
+ This class is abstract. + +
+

Basic Context of an Actor. It supports only linking and it simply terminates on error. +Uses Behaviour.basic_behaviour_definition:

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

Utils::AdHoc

+
+ + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + +
+

Instance Method Details

+ + +
+

+ + #behaviour_definitionundocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib-edge/concurrent/actor/context.rb', line 151
+
+def behaviour_definition
+  Behaviour.basic_behaviour_definition
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/Core.html b/docs/1.1.0/Concurrent/Actor/Core.html new file mode 100644 index 000000000..cb11d5eb7 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/Core.html @@ -0,0 +1,2538 @@ + + + + + + + Class: Concurrent::Actor::Core + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::Core + + + +

+
+ +
+
Inherits:
+
+ Synchronization::LockableObject + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
TypeCheck
+
+ + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/core.rb
+
+ +
+ +

Overview

+
+ +
+ Note: +

Whole class should be considered private. An user should use Contexts and References only.

+
+
+ +
+ Note: +

devel: core should not block on anything, e.g. it cannot wait on children to terminate +that would eat up all threads in task pool and deadlock

+
+
+ +

Core of the actor.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(opts = {}, &block) ⇒ Core + + + + + +

+
+

Returns a new instance of Core

+ + +
+
+
+

Parameters:

+
    + +
  • + + block + + + (Proc) + + + + — +

    for class instantiation

    +
    + +
  • + +
  • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +

    a customizable set of options

    +
    + +
  • + +
+ + + + +

Options Hash (opts):

+
    + +
  • + name + (String) + + + + +
  • + +
  • + actor_class + (Context) + + + + + —

    a class to be instantiated defining Actor's behaviour

    +
    + +
  • + +
  • + args + (Array<Object>) + + + + + —

    arguments for actor_class instantiation

    +
    + +
  • + +
  • + executor, + (Executor) + + + + + —

    default is global_io_executor

    +
    + +
  • + +
  • + link, + (true, false) + + + + + —

    atomically link the actor to its parent (default: true)

    +
    + +
  • + +
  • + reference + (Class) + + + + + —

    a custom descendant of Reference to use

    +
    + +
  • + +
  • + behaviour_definition, + (Array<Array(Behavior::Abstract, Array<Object>)>) + + + + + —

    array of pairs +where each pair is behaviour class and its args, see Behaviour.basic_behaviour_definition

    +
    + +
  • + +
  • + initialized, + (ResolvableFuture, nil) + + + + + —

    if present it'll be set or failed after Concurrent::Actor::Context initialization

    +
    + +
  • + +
  • + parent + (Reference, nil) + + + + + —

    private api parent of the actor (the one spawning )

    +
    + +
  • + +
  • + logger + (Proc, nil) + + + + + —

    a proc accepting (level, progname, message = nil, &block) params, +can be used to hook actor instance to any logging system, see Concern::Logging

    +
    + +
  • + +
+ + + + + +
+ + + + +
+
+
+
+50
+51
+52
+53
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 50
+
+def initialize(opts = {}, &block)
+  super(&nil)
+  synchronize { ns_initialize(opts, &block) }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #actor_classContext (readonly) + + + + + +

+
+

A subclass of AbstractContext representing Actor's behaviour.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+35
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition
+
+
+ + + +
+

+ + #behaviour_definitionundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+def behaviour_definition
+  @behaviour_definition
+end
+
+
+ + + +
+

+ + #contextundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+def context
+  @context
+end
+
+
+ + + +
+

+ + #context_classundocumented (readonly) + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+def context_class
+  @context_class
+end
+
+
+ + + +
+

+ + #executorExecutor (readonly) + + + + + +

+
+

Executor which is used to process messages.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Executor) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition
+
+
+ + + +
+

+ + #nameString (readonly) + + + + + +

+
+

The name of actor instance, it should be uniq (not enforced). Allows easier orientation +between actor instances.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition
+
+
+ + + +
+

+ + #pathString (readonly) + + + + + +

+
+

Path of this actor. It is used for easier orientation and logging. +Path is constructed recursively with: parent.path + self.name up to a Concurrent::Actor.root, +e.g. /an_actor/its_child.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition
+
+
+ + + +
+

+ + #referenceReference (readonly) + + + + + +

+
+

Reference to this actor which can be safely passed around.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 35
+
+def reference
+  @reference
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ undocumented + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ + +
+ + + + +
+
+
+
+74
+75
+76
+77
+78
+79
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 74
+
+def add_child(child)
+  guard!
+  Type! child, Reference
+  @children.add child
+  nil
+end
+
+
+ +
+

+ + #allocate_contextundocumented + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ + +
+ + + + +
+
+
+
+150
+151
+152
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 150
+
+def allocate_context
+  @context = @context_class.allocate
+end
+
+
+ +
+

+ + #behaviour(behaviour_class) ⇒ Behaviour::Abstract? + + + + + +

+
+

Returns based on behaviour_class

+ + +
+
+
+

Parameters:

+
    + +
  • + + behaviour_class + + + (Class) + + + +
  • + +
+ +

Returns:

+ + +
+ + + + +
+
+
+
+138
+139
+140
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 138
+
+def behaviour(behaviour_class)
+  @behaviours[behaviour_class]
+end
+
+
+ +
+

+ + #behaviour!(behaviour_class) ⇒ Behaviour::Abstract + + + + + +

+
+

Returns based on behaviour_class

+ + +
+
+
+

Parameters:

+
    + +
  • + + behaviour_class + + + (Class) + + + +
  • + +
+ +

Returns:

+ +

Raises:

+
    + +
  • + + + (KeyError) + + + + — +

    when no behaviour

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+145
+146
+147
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 145
+
+def behaviour!(behaviour_class)
+  @behaviours.fetch behaviour_class
+end
+
+
+ +
+

+ + #broadcast(public, event) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+131
+132
+133
+134
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 131
+
+def broadcast(public, event)
+  log(DEBUG) { "event: #{event.inspect} (#{public ? 'public' : 'private'})" }
+  @first_behaviour.on_event(public, event)
+end
+
+
+ +
+

+ + #build_contextundocumented + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ + +
+ + + + +
+
+
+
+155
+156
+157
+158
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 155
+
+def build_context
+  @context.send :initialize_core, self
+  @context.send :initialize, *@args, &@block
+end
+
+
+ +
+

+ + #Child!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Child?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+

+ + #childrenArray<Reference> + + + + + +

+
+

Returns of children actors

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array<Reference>) + + + + — +

    of children actors

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+68
+69
+70
+71
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 68
+
+def children
+  guard!
+  @children.to_a
+end
+
+
+ +
+

+ + #dead_letter_routingundocumented + + + + + +

+
+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 63
+
+def dead_letter_routing
+  @context.dead_letter_routing
+end
+
+
+ +
+

+ + #guard!undocumented + + + + + +

+
+

ensures that we are inside of the executor

+ + +
+
+
+ + +
+ + + + +
+
+
+
+102
+103
+104
+105
+106
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 102
+
+def guard!
+  unless Actor.current == reference
+    raise "can be called only inside actor #{reference} but was #{Actor.current}"
+  end
+end
+
+
+ +
+

+ + #log(level, message = nil, &block) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+108
+109
+110
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 108
+
+def log(level, message = nil, &block)
+  super level, @path, message, &block
+end
+
+
+ +
+

+ + #Match!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Match?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+

+ + #on_envelope(envelope) ⇒ undocumented + + + + + +

+
+

is executed by Reference scheduling processing of new messages +can be called from other alternative Reference implementations

+ + +
+
+
+

Parameters:

+
    + +
  • + + envelope + + + (Envelope) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+92
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 92
+
+def on_envelope(envelope)
+  log(DEBUG) { "is  #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}" }
+  schedule_execution do
+    log(DEBUG) { "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender} - processing" }
+    process_envelope envelope
+  end
+  nil
+end
+
+
+ +
+

+ + #parentReference? + + + + + +

+
+

A parent Actor. When actor is spawned the Concurrent::Actor.current becomes its parent. +When actor is spawned from a thread outside of an actor (Concurrent::Actor.current is nil) Concurrent::Actor.root is assigned.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+58
+59
+60
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 58
+
+def parent
+  @parent_core && @parent_core.reference
+end
+
+
+ +
+

+ + #process_envelope(envelope) ⇒ undocumented + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ + +
+ + + + +
+
+
+
+161
+162
+163
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 161
+
+def process_envelope(envelope)
+  @first_behaviour.on_envelope envelope
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ undocumented + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+85
+86
+87
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 82
+
+def remove_child(child)
+  guard!
+  Type! child, Reference
+  @children.delete child
+  nil
+end
+
+
+ +
+

+ + #schedule_executionundocumented + + + + + +

+
+

Schedules blocks to be executed on executor sequentially, +sets Actress.current

+ + +
+
+
+ + +
+ + + + +
+
+
+
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+
+
# File 'lib-edge/concurrent/actor/core.rb', line 114
+
+def schedule_execution
+  @serialized_execution.post(@executor) do
+    synchronize do
+      begin
+        Thread.current[:__current_actor__] = reference
+        yield
+      rescue => e
+        log FATAL, e
+      ensure
+        Thread.current[:__current_actor__] = nil
+      end
+    end
+  end
+
+  nil
+end
+
+
+ +
+

+ + #Type!(value, *types) ⇒ undocumented + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ + +
+
+ +
+

+ + #Type?(value, *types) ⇒ Boolean + + + + + + + Originally defined in module + TypeCheck + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/DefaultDeadLetterHandler.html b/docs/1.1.0/Concurrent/Actor/DefaultDeadLetterHandler.html new file mode 100644 index 000000000..9f81e5fd9 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/DefaultDeadLetterHandler.html @@ -0,0 +1,232 @@ + + + + + + + Class: Concurrent::Actor::DefaultDeadLetterHandler + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Concurrent::Actor::DefaultDeadLetterHandler + + + +

+
+ +
+
Inherits:
+
+ RestartingContext + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib-edge/concurrent/actor/default_dead_letter_handler.rb
+
+ +
+ +
+
+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + +
+

Instance Method Details

+ + +
+

+ + #on_message(dead_letter) ⇒ undocumented + + + + + +

+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+4
+5
+6
+
+
# File 'lib-edge/concurrent/actor/default_dead_letter_handler.rb', line 4
+
+def on_message(dead_letter)
+  log(INFO) { "got dead letter #{dead_letter.inspect}"}
+end
+
+
+ +
+ +
+ + + + + +
+ + \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actress/Envelope.html b/docs/1.1.0/Concurrent/Actor/Envelope.html similarity index 57% rename from docs/1.0.5/Concurrent/Actress/Envelope.html rename to docs/1.1.0/Concurrent/Actor/Envelope.html index 02d916738..b2013fb4a 100644 --- a/docs/1.0.5/Concurrent/Actress/Envelope.html +++ b/docs/1.1.0/Concurrent/Actor/Envelope.html @@ -1,12 +1,12 @@ - - + + - + + - Class: Concurrent::Actress::Envelope + Class: Concurrent::Actor::Envelope - — Concurrent + — Concurrent Ruby @@ -15,9 +15,8 @@ @@ -28,92 +27,103 @@ -
-
# File 'lib/concurrent/actress/envelope.rb', line 17
+      
# File 'lib-edge/concurrent/actor/envelope.rb', line 17
 
-def initialize(message, ivar, sender, address)
+def initialize(message, future, sender, address)
   @message = message
-  @ivar    = Type! ivar, IVar, NilClass
-  @sender  = Type! sender, Reference, Thread
-  @address = Type! address, Reference
+  @future  = Type! future, Promises::ResolvableFuture, NilClass
+  @sender  = Type! sender, Reference, Thread
+  @address = Type! address, Reference
 end
@@ -552,7 +561,7 @@

Instance Attribute Details

- - (Object) address (readonly) + #addressundocumented (readonly) @@ -560,8 +569,7 @@

-

Returns the value of attribute address

- +
@@ -577,9 +585,9 @@

15

-
# File 'lib/concurrent/actress/envelope.rb', line 15
+      
# File 'lib-edge/concurrent/actor/envelope.rb', line 15
 
-attr_reader :message, :ivar, :sender, :address
+attr_reader :message, :future, :sender, :address
@@ -588,9 +596,9 @@

-

+

- - (IVar) ivar (readonly) + #futureEdge::Future (readonly) @@ -598,7 +606,7 @@

-

Returns an ivar which becomes resolved after message is processed

+

Returns a future which becomes resolved after message is processed

@@ -611,12 +619,12 @@

  • - (IVar) + (Edge::Future) — -

    an ivar which becomes resolved after message is processed

    +

    a future which becomes resolved after message is processed

  • @@ -632,9 +640,9 @@

    15 -
    # File 'lib/concurrent/actress/envelope.rb', line 15
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 15
     
    -attr_reader :message, :ivar, :sender, :address
    +attr_reader :message, :future, :sender, :address
    @@ -645,7 +653,7 @@

    - - (Object) message (readonly) + #messageObject (readonly) @@ -689,7 +697,7 @@

    17 -
    # File 'lib/concurrent/actress/envelope.rb', line 15
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 15
     
     def message
       @message
    @@ -704,7 +712,7 @@ 

    - - (Reference, Thread) sender (readonly) + #senderReference, Thread (readonly) @@ -725,7 +733,7 @@

  • - (Reference, Thread) + (Reference, Thread) @@ -746,9 +754,9 @@

    15

  • -
    # File 'lib/concurrent/actress/envelope.rb', line 15
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 15
     
    -attr_reader :message, :ivar, :sender, :address
    +attr_reader :message, :future, :sender, :address
    @@ -764,13 +772,22 @@

    Instance Method Details

    - - (Object) address_path + #address_pathundocumented + + +

    +
    + +
    +
    +
    -

    + +
    @@ -781,7 +798,7 @@ 

    34

    -
    # File 'lib/concurrent/actress/envelope.rb', line 32
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 32
     
     def address_path
       address.path
    @@ -794,7 +811,7 @@ 

    - - (Object) Child!(value, *types) + #Child!(value, *types) ⇒ undocumented @@ -802,16 +819,25 @@

    Originally defined in module - TypeCheck + TypeCheck -

    +

    +
    + + +
    +
    +
    + + +

    - - (Boolean) Child?(value, *types) + #Child?(value, *types) ⇒ Boolean @@ -819,7 +845,7 @@

    Originally defined in module - TypeCheck + TypeCheck

    @@ -850,7 +876,7 @@

    - - (Object) Match!(value, *types) + #Match!(value, *types) ⇒ undocumented @@ -858,16 +884,25 @@

    Originally defined in module - TypeCheck + TypeCheck -

    +

    +
    + + +
    +
    +
    + + +

    - - (Boolean) Match?(value, *types) + #Match?(value, *types) ⇒ Boolean @@ -875,7 +910,7 @@

    Originally defined in module - TypeCheck + TypeCheck

    @@ -906,13 +941,22 @@

    - - (Object) reject!(error) + #reject!(error) ⇒ undocumented -

    +
    +
    + + +
    +
    +
    + + +
    @@ -936,13 +980,22 @@

    - - (Object) sender_path + #sender_pathundocumented + + +

    +
    + +
    +
    +
    -

    @@ -923,10 +967,10 @@ 

    38

    -
    # File 'lib/concurrent/actress/envelope.rb', line 36
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 36
     
     def reject!(error)
    -  ivar.fail error unless ivar.nil?
    +  future.reject error unless future.nil?
     end
    + +
    @@ -957,10 +1010,10 @@ 

    30

    -
    # File 'lib/concurrent/actress/envelope.rb', line 24
    +      
    # File 'lib-edge/concurrent/actor/envelope.rb', line 24
     
     def sender_path
    -  if sender.is_a? Reference
    +  if sender.is_a? Reference
         sender.path
       else
         sender.to_s
    @@ -974,7 +1027,7 @@ 

    - - (Object) Type!(value, *types) + #Type!(value, *types) ⇒ undocumented @@ -982,16 +1035,25 @@

    Originally defined in module - TypeCheck + TypeCheck -

    +

    +
    + + +
    +
    +
    + + +

    - - (Boolean) Type?(value, *types) + #Type?(value, *types) ⇒ Boolean @@ -999,7 +1061,7 @@

    Originally defined in module - TypeCheck + TypeCheck

    @@ -1031,21 +1093,21 @@

    - \ No newline at end of file diff --git a/docs/1.1.0/Concurrent/Actor/InternalDelegations.html b/docs/1.1.0/Concurrent/Actor/InternalDelegations.html new file mode 100644 index 000000000..92c984bb1 --- /dev/null +++ b/docs/1.1.0/Concurrent/Actor/InternalDelegations.html @@ -0,0 +1,1143 @@ + + + + + + + Module: Concurrent::Actor::InternalDelegations + + — Concurrent Ruby + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Concurrent::Actor::InternalDelegations + + + +

    +
    + + + + + + +
    +
    Includes:
    +
    PublicDelegations, Logger::Severity
    +
    + + + + +
    +
    Included in:
    +
    AbstractContext, Behaviour::Abstract
    +
    + + + +
    +
    Defined in:
    +
    lib-edge/concurrent/actor/internal_delegations.rb
    +
    + +
    + +
    +
    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #behaviour(behaviour_class) ⇒ undocumented + + + + + +

    +
    +

    see Core#behaviour

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +49
    +50
    +51
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 49
    +
    +def behaviour(behaviour_class)
    +  core.behaviour(behaviour_class)
    +end
    +
    +
    + +
    +

    + + #behaviour!(behaviour_class) ⇒ undocumented + + + + + +

    +
    +

    see Core#behaviour!

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +54
    +55
    +56
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 54
    +
    +def behaviour!(behaviour_class)
    +  core.behaviour!(behaviour_class)
    +end
    +
    +
    + +
    +

    + + #childrenundocumented + + + + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +8
    +9
    +10
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 8
    +
    +def children
    +  core.children
    +end
    +
    +
    + +
    +

    + + #contextAbstractContext + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 44
    +
    +def context
    +  core.context
    +end
    +
    +
    + +
    +

    + + #context_classundocumented + + + + Also known as: + actor_class + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #dead_letter_routingundocumented + + + + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 34
    +
    +def dead_letter_routing
    +  context.dead_letter_routing
    +end
    +
    +
    + +
    +

    + + #executorundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #log(level, message = nil, &block) ⇒ undocumented + + + + + +

    +
    +

    delegates to core.log

    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • Logging#log
    • + +
    + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 29
    +
    +def log(level, message = nil, &block)
    +  core.log(level, message, &block)
    +end
    +
    +
    + +
    +

    + + #nameundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #parentundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #pathundocumented + + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #redirect(reference, envelope = self.envelope) ⇒ undocumented + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +38
    +39
    +40
    +41
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 38
    +
    +def redirect(reference, envelope = self.envelope)
    +  reference.message(envelope.message, envelope.future)
    +  Behaviour::MESSAGE_PROCESSED
    +end
    +
    +
    + +
    +

    + + #referenceundocumented + + + + Also known as: + ref + + + + + + Originally defined in module + PublicDelegations + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    + + +
    +
    + +
    +

    + + #terminate!(reason = nil) ⇒ undocumented + + + + + +

    +
    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • Termination#terminate!
    • + +
    + +
    + + + + +
    +
    +
    +
    +13
    +14
    +15
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 13
    +
    +def terminate!(reason = nil)
    +  behaviour!(Behaviour::Termination).terminate!(reason)
    +end
    +
    +
    + +
    +

    + + #terminated?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • Termination#terminated?
    • + +
    + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +
    +
    # File 'lib-edge/concurrent/actor/internal_delegations.rb', line 18
    +
    +def terminated?
    +  behaviour!(Behaviour::Termination).terminated?
    +end
    +
    +
    + +
    + +
    + + + + + +
    + + \ No newline at end of file diff --git a/docs/1.0.5/Concurrent/Actor/CoreDelegations.html b/docs/1.1.0/Concurrent/Actor/PublicDelegations.html similarity index 52% rename from docs/1.0.5/Concurrent/Actor/CoreDelegations.html rename to docs/1.1.0/Concurrent/Actor/PublicDelegations.html index 11ca97342..e2e54c6b0 100644 --- a/docs/1.0.5/Concurrent/Actor/CoreDelegations.html +++ b/docs/1.1.0/Concurrent/Actor/PublicDelegations.html @@ -1,12 +1,12 @@ - - + + - + + - Module: Concurrent::Actor::CoreDelegations + Module: Concurrent::Actor::PublicDelegations - — Concurrent + — Concurrent Ruby @@ -15,9 +15,8 @@ @@ -28,65 +27,66 @@ -