本文整理汇总了C#中Akka.Actor.ActorRef类的典型用法代码示例。如果您正苦于以下问题:C# ActorRef类的具体用法?C# ActorRef怎么用?C# ActorRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActorRef类属于Akka.Actor命名空间,在下文中一共展示了ActorRef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestPersistentView
public TestPersistentView(string name, ActorRef probe, TimeSpan interval, string failAt = null)
{
_name = name;
_probe = probe;
_interval = interval;
_failAt = failAt;
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:7,代码来源:PersistentViewSpec.Actors.cs
示例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
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:30,代码来源:ClusterMetricsCollector.cs
示例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");
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:7,代码来源:Remoting.cs
示例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)));
}
开发者ID:Koulio,项目名称:AsyncOrigoDbSpike,代码行数:7,代码来源:Dispatcher.cs
示例5: FutureActorRef
public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
{
_result = result;
_sender = sender ?? ActorRef.NoSender;
_unregister = unregister;
Path = path;
}
开发者ID:pdoh00,项目名称:akka.net,代码行数:7,代码来源:ActorRef.cs
示例6: FutureActorRef
public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
{
this.result = result;
this.sender = sender;
this.unregister = unregister;
Path = path;
}
开发者ID:Badmoonz,项目名称:akka.net,代码行数:7,代码来源:ActorRef.cs
示例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);
}
}
}
开发者ID:Badmoonz,项目名称:akka.net,代码行数:30,代码来源:FutureActor.cs
示例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));
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:14,代码来源:InternalTestActorRef.cs
示例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));
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:28,代码来源:ClientReceiveActor.cs
示例10: LifeCycleTest2Actor
public LifeCycleTest2Actor(ActorRef testActor, string id, AtomicCounter generationProvider)
{
this.testActor = testActor;
this.id = id;
this.generationProvider = generationProvider;
this.CurrentGeneration = generationProvider.Next();
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:7,代码来源:ActorLifeCycleSpec.cs
示例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);
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:34,代码来源:ActorRefFactoryShared.cs
示例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;
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:14,代码来源:RemoteDaemon.cs
示例13: Send
public override void Send(object message, ActorRef sender)
{
foreach (Routee routee in routees)
{
routee.Send(message, sender);
}
}
开发者ID:Badmoonz,项目名称:akka.net,代码行数:7,代码来源:Router.cs
示例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();
}
开发者ID:chosenbreed37,项目名称:S37.IS,代码行数:25,代码来源:Philosopher.cs
示例15: LifeCycleTest2Actor
public LifeCycleTest2Actor(ActorRef testActor, string id, AtomicInteger generationProvider)
{
this.testActor = testActor;
this.id = id;
this.generationProvider = generationProvider;
this.CurrentGeneration = generationProvider.GetAndIncrement();
}
开发者ID:jweimann,项目名称:akka.net,代码行数:7,代码来源:ActorLifeCycleSpec.cs
示例16: KillableActor
public KillableActor(ActorRef testActor)
{
TestActor = testActor;
Receive<string>(s => s == "go away", s =>
{
throw new ArgumentException("Goodbye then!");
});
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:8,代码来源:ClusterRouterSupervisorSpec.cs
示例17: Message
public Message(InternalActorRef recipient, Address recipientAddress, SerializedMessage serializedMessage, ActorRef senderOptional = null, SeqNo seq = null)
{
Seq = seq;
SenderOptional = senderOptional;
SerializedMessage = serializedMessage;
RecipientAddress = recipientAddress;
Recipient = recipient;
}
开发者ID:pdoh00,项目名称:akka.net,代码行数:8,代码来源:AkkaPduCodec.cs
示例18: Persistent
public Persistent(object payload, long sequenceNr = 0L, string persistenceId = null, bool isDeleted = false, ActorRef sender = null)
{
Payload = payload;
SequenceNr = sequenceNr;
IsDeleted = isDeleted;
PersistenceId = persistenceId ?? string.Empty;
Sender = sender;
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:8,代码来源:Persistent.cs
示例19: Subscribe
/// <summary>
/// Subscribes the specified subscriber.
/// </summary>
/// <param name="subscriber">The subscriber.</param>
/// <param name="channel">The channel.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <exception cref="System.ArgumentNullException">subscriber</exception>
public override bool Subscribe(ActorRef subscriber, Type channel)
{
if (subscriber == null)
throw new ArgumentNullException("subscriber");
if (debug)
Publish(new Debug(SimpleName(this), GetType(), "subscribing " + subscriber + " to channel " + channel));
return base.Subscribe(subscriber, channel);
}
开发者ID:ClusterReply,项目名称:akka.net,代码行数:16,代码来源:EventStream.cs
示例20: Tell
public void Tell(object message, ActorRef sender)
{
if (sender == null)
{
throw new ArgumentNullException("sender");
}
TellInternal(message, sender);
}
开发者ID:Badmoonz,项目名称:akka.net,代码行数:9,代码来源:ActorRef.cs
注:本文中的Akka.Actor.ActorRef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论