本文整理汇总了C#中Akka.Actor.ActorRef类的典型用法代码示例。如果您正苦于以下问题:C# ActorRef类的具体用法?C# ActorRef怎么用?C# ActorRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActorRef类属于Akka.Actor命名空间,在下文中一共展示了ActorRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPersistentView
public TestPersistentView(string name, ActorRef probe, TimeSpan interval, string failAt = null)
{
_name = name;
_probe = probe;
_interval = interval;
_failAt = failAt;
}
示例2: ClusterMetricsCollector
public ClusterMetricsCollector(ActorRef publisher)
{
_publisher = publisher;
_cluster = Cluster.Get(Context.System);
Collector = MetricsCollector.Get(Context.System.AsInstanceOf<ExtendedActorSystem>(), _cluster.Settings);
LatestGossip = MetricsGossip.Empty;
Nodes = ImmutableHashSet.Create<Address>();
_metricsTask = new CancellationTokenSource();
Context.System.Scheduler.Schedule(_cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.MetricsInterval),
_cluster.Settings.MetricsInterval, Self, InternalClusterAction.MetricsTick.Instance, _metricsTask.Token);
_gossipTask = new CancellationTokenSource();
Context.System.Scheduler.Schedule(_cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.GossipInterval),
_cluster.Settings.GossipInterval, Self, InternalClusterAction.GossipTick.Instance, _gossipTask.Token);
Receive<InternalClusterAction.GossipTick>(tick => Gossip());
Receive<InternalClusterAction.MetricsTick>(tick => Collect());
Receive<MetricsGossipEnvelope>(envelope => ReceiveGossip(envelope));
Receive<ClusterEvent.CurrentClusterState>(state => ReceiveState(state));
Receive<ClusterEvent.MemberUp>(up => AddMember(up.Member));
Receive<ClusterEvent.MemberRemoved>(removed => RemoveMember(removed.Member));
Receive<ClusterEvent.MemberExited>(exited => RemoveMember(exited.Member));
Receive<ClusterEvent.UnreachableMember>(member => RemoveMember(member.Member));
Receive<ClusterEvent.ReachableMember>(member =>
{
if (member.Member.Status == MemberStatus.Up) AddMember(member.Member);
});
Receive<ClusterEvent.IMemberEvent>(@event => { }); //not interested in other types of member event
}
示例3: Remoting
public Remoting(ExtendedActorSystem system, RemoteActorRefProvider provider)
: base(system, provider)
{
log = Logging.GetLogger(system, "remoting");
_eventPublisher = new EventPublisher(system, log, Logging.LogLevelFor(provider.RemoteSettings.RemoteLifecycleEventsLogLevel));
_transportSupervisor = system.SystemActorOf(Props.Create<TransportSupervisor>(), "transports");
}
示例4: Dispatcher
public Dispatcher(ActorRef journalWriter, ActorRef executor)
{
_executor = executor;
_journalWriter = journalWriter;
Receive<Command>(command => _journalWriter.Tell(new RequestContext(command, Sender)));
Receive<Query>(query => _executor.Tell(new RequestContext(query, Sender)));
}
示例5: FutureActorRef
public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
{
_result = result;
_sender = sender ?? ActorRef.NoSender;
_unregister = unregister;
Path = path;
}
示例6: FutureActorRef
public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
{
this.result = result;
this.sender = sender;
this.unregister = unregister;
Path = path;
}
示例7: OnReceive
/// <summary>
/// Processor for user defined messages.
/// </summary>
/// <param name="message">The message.</param>
protected override void OnReceive(object message)
{
if (message is SetRespondTo)
{
result = ((SetRespondTo) message).Result;
respondTo = Sender;
}
else
{
if (respondTo != ActorRef.NoSender)
{
Self.Stop();
respondTo.Tell(new CompleteFuture(() => result.SetResult(message)));
Become(_ => { });
}
else
{
//if there is no listening actor asking,
//just eval the result directly
Self.Stop();
Become(_ => { });
result.SetResult(message);
}
}
}
示例8: Receive
/// <summary>
/// Directly inject messages into actor receive behavior. Any exceptions
/// thrown will be available to you, while still being able to use
/// become/unbecome.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="sender">The sender.</param>
public void Receive(object message, ActorRef sender = null)
{
var cell = Cell;
sender = sender.IsNobody() ? cell.System.DeadLetters : sender;
var envelope = new Envelope { Message = message, Sender = sender };
cell.UseThreadContext(() => cell.ReceiveMessageForTest(envelope));
}
示例9: ClientReceiveActor
public ClientReceiveActor(ActorRef actor, long repeat, TaskCompletionSource<bool> latch)
{
var received=0L;
var sent=0L;
Receive<Messages.Msg>(m =>
{
received++;
if(sent < repeat)
{
actor.Tell(m);
sent++;
}
else if(received >= repeat)
{
latch.SetResult(true);
}
});
Receive<Messages.Run>(r =>
{
var msg = new Messages.Msg();
for(int i = 0; i < Math.Min(1000, repeat); i++)
{
actor.Tell(msg);
sent++;
}
});
Receive<Messages.Started>(s => Sender.Tell(s));
}
示例10: LifeCycleTest2Actor
public LifeCycleTest2Actor(ActorRef testActor, string id, AtomicCounter generationProvider)
{
this.testActor = testActor;
this.id = id;
this.generationProvider = generationProvider;
this.CurrentGeneration = generationProvider.Next();
}
示例11: ActorSelection
/// <summary>
/// Construct an <see cref="Akka.Actor.ActorSelection"/> from the given path, which is
/// parsed for wildcards (these are replaced by regular expressions
/// internally). No attempt is made to verify the existence of any part of
/// the supplied path, it is recommended to send a message and gather the
/// replies in order to resolve the matching set of actors.
/// </summary>
public static ActorSelection ActorSelection(string path, ActorSystem system, ActorRef lookupRoot)
{
var provider = ((ActorSystemImpl)system).Provider;
if(Uri.IsWellFormedUriString(path, UriKind.Absolute))
{
ActorPath actorPath;
if(!ActorPath.TryParse(path, out actorPath))
return new ActorSelection(provider.DeadLetters, "");
var actorRef = provider.RootGuardianAt(actorPath.Address);
return new ActorSelection(actorRef, actorPath.Elements);
}
//no path given
if(string.IsNullOrEmpty(path))
{
return new ActorSelection(system.DeadLetters, "");
}
//absolute path
var elements = path.Split('/');
if(elements[0] == "")
{
return new ActorSelection(provider.RootGuardian, elements.Skip(1));
}
return new ActorSelection(lookupRoot, path);
}
示例12: DaemonMsgCreate
/// <summary>
/// Initializes a new instance of the <see cref="DaemonMsgCreate" /> class.
/// </summary>
/// <param name="props">The props.</param>
/// <param name="deploy">The deploy.</param>
/// <param name="path">The path.</param>
/// <param name="supervisor">The supervisor.</param>
public DaemonMsgCreate(Props props, Deploy deploy, string path, ActorRef supervisor)
{
Props = props;
Deploy = deploy;
Path = path;
Supervisor = supervisor;
}
示例13: Send
public override void Send(object message, ActorRef sender)
{
foreach (Routee routee in routees)
{
routee.Send(message, sender);
}
}
示例14: PickUpFork
private void PickUpFork(ActorRef fork)
{
if (this.LeftFork == fork)
{
Console.WriteLine("{0} has {1} in his left hand", this.Self.Name(), fork.Name());
this.OwnsLeftFork = true;
}
else if(this.RightFork == fork)
{
Console.WriteLine("{0} has {1} in his right hand", this.Self.Name(), fork.Name());
this.OwnsRightFork = true;
}
if ((!this.OwnsLeftFork || !this.OwnsRightFork) &&
(this.random.Next(1) == 1))
{
this.DropFork(this.LeftFork);
this.DropFork(this.RightFork);
this.StartWaiting();
return;
}
this.StartEating();
}
示例15: LifeCycleTest2Actor
public LifeCycleTest2Actor(ActorRef testActor, string id, AtomicInteger generationProvider)
{
this.testActor = testActor;
this.id = id;
this.generationProvider = generationProvider;
this.CurrentGeneration = generationProvider.GetAndIncrement();
}