Sync actor

Rocket.syncFunction
sync(actor::A) where A
sync(factory::F) where { F <: AbstractActorFactory }

Creation operator for the SyncActor actor.

Examples

using Rocket

actor  = LoggerActor{Int}()
synced = sync(actor)
synced isa SyncActor{Int, LoggerActor{Int}}

# output
true

Can also be used with an <: AbstractActorFactory as an argument. In this case sync function will return a special actor factory object, which will store all created actors in array and wrap them with a sync function. wait(sync_factory) method will wait for all of the created actors to be completed in the order of creation (but only once for each of them).

using Rocket

values = Int[]

factory  = lambda(on_next = (d) -> push!(values, d))
synced   = sync(factory)

subscribe!(interval(10) |> take(5), synced)

wait(synced)

println(values)

# output
[0, 1, 2, 3, 4]

See also: SyncActor, AbstractActor

source
Rocket.SyncActorType
SyncActor{D, A}(actor::A) where D where A

Sync actor provides a synchronized interface to wait for an actor to be notified with a complete event.

Examples

using Rocket

source = timer(1, 1) |> take(3)
actor  = LoggerActor{Int}()
synced = SyncActor{Int, LoggerActor{Int}}(actor)

subscrption = subscribe!(source, synced)

wait(synced)
;

# output

[LogActor] Data: 0
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Completed

See also: Actor, sync

source