本文整理汇总了C#中IActorRef类的典型用法代码示例。如果您正苦于以下问题:C# IActorRef类的具体用法?C# IActorRef怎么用?C# IActorRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IActorRef类属于命名空间,在下文中一共展示了IActorRef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ClusterMetricsCollector
public ClusterMetricsCollector(IActorRef publisher)
{
_publisher = publisher;
_cluster = Cluster.Get(Context.System);
Collector = MetricsCollector.Get(Context.System.AsInstanceOf<ExtendedActorSystem>(), _cluster.Settings);
LatestGossip = MetricsGossip.Empty;
Nodes = ImmutableHashSet.Create<Address>();
_metricsCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
_cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.MetricsInterval),
_cluster.Settings.MetricsInterval, Self, InternalClusterAction.MetricsTick.Instance, Self);
_gossipCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
_cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.GossipInterval),
_cluster.Settings.GossipInterval, Self, InternalClusterAction.GossipTick.Instance, Self);
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:rogeralsing,项目名称:akka.net,代码行数:30,代码来源:ClusterMetricsCollector.cs
示例2: StockActor
public StockActor(string stockSymbol)
{
_stockSymbol = stockSymbol;
_subscribers = new HashSet<IActorRef>();
_priceLookupChild = Context.ActorOf(Context.DI().Props<StockPriceLookupActor>());
Receive<SubscribeToNewStockPricesMessage>(message => _subscribers.Add(message.Subscriber));
Receive<UnSubscribeFromNewStockPricesMessage>(message => _subscribers.Remove(message.Subscriber));
Receive<RefreshStockPriceMessage>(message => _priceLookupChild.Tell(message));
Receive<UpdatedStockPriceMessage>(message =>
{
_stockPrice = message.Price;
var stockPriceMessage = new StockPriceMessage(_stockSymbol, _stockPrice, message.Date);
foreach (var subscriber in _subscribers)
{
subscriber.Tell(stockPriceMessage);
}
});
}
开发者ID:philnee,项目名称:Akka,代码行数:25,代码来源:StockActor.cs
示例3: FileObserver
public FileObserver(IActorRef tailActor, string absoluteFilePath)
{
_tailActor = tailActor;
_absoluteFilePath = absoluteFilePath;
_fileDir = Path.GetDirectoryName(absoluteFilePath);
_fileNameOnly = Path.GetFileName(absoluteFilePath);
}
开发者ID:EthanSteiner,项目名称:akka-bootcamp,代码行数:7,代码来源:FileObserver.cs
示例4: ClientReceiveActor
public ClientReceiveActor(IActorRef 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:njannink,项目名称:sonarlint-vs,代码行数:28,代码来源:ClientReceiveActor.cs
示例5: MediWatchCommanderActor
private readonly Dictionary<int, IActorRef> _hospitalCoordinatorActors; // maps hospital id -> actor ref
#endregion Fields
#region Constructors
public MediWatchCommanderActor( IEnumerable<Hospital> hospitals, IActorRef dashboardActor )
{
_dashboardActor = dashboardActor;
_hospitalCoordinatorActors = InitializeHospitalCoordinatorActors( hospitals );
Processing();
}
开发者ID:rachid1805,项目名称:str,代码行数:13,代码来源:MediWatchCommanderActor.cs
示例6: LifeCycleTest2Actor
public LifeCycleTest2Actor(IActorRef testActor, string id, AtomicCounter generationProvider)
{
this.testActor = testActor;
this.id = id;
this.generationProvider = generationProvider;
this.CurrentGeneration = generationProvider.Next();
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:ActorLifeCycleSpec.cs
示例7: 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, IActorRef 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:njannink,项目名称:sonarlint-vs,代码行数:14,代码来源:InternalTestActorRef.cs
示例8: ConnectionAssociationHandle
public ConnectionAssociationHandle(IActorRef connection, Address localAddress, Address remoteAddress)
: base(localAddress, remoteAddress)
{
_connection = connection;
ReadHandlerSource = new TaskCompletionSource<IHandleEventListener>();
ReadHandlerSource.Task.PipeTo(connection);
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:ConnectionAssociation.cs
示例9: MailInActor
public MailInActor(IActorRef commander)
{
this.commander = commander;
Receive<CheckMail>(m =>
{
Console.Write("[MailInActor ]: Checking e-mail inbox ...");
var ex = Helpers.GetRandomInt(CalcConfig.NetworkExceptionChance);
if (ex == 2)
{
throw new SocketException();
}
ex = Helpers.GetRandomInt(CalcConfig.FatalExceptionChance);
if (ex == 5)
{
throw new ArgumentNullException();
}
// emulate receiving n e-mails
int n = Helpers.GetRandomInt(CalcConfig.MaxNumberEmailsReceived);
Console.WriteLine(" {0} e-mails found.", n);
for (int i = 0; i < n; i++)
{
var from = Helpers.GetRandomEmail();
var loanId = Helpers.GetRandomLoadId();
var calculationOrder = new CalculateLoan(from, loanId);
this.commander.Tell(calculationOrder);
}
});
}
开发者ID:volago,项目名称:calculations,代码行数:33,代码来源:MailInActor.cs
示例10: Master
public Master()
{
var layersCount = LayerDimentions.Count;
var dataShards = Enumerable.Repeat(DataSet, DataPerReplica).ToList();
var parameterShardActors = new IActorRef[layersCount - 1];
for (int i = 0; i < layersCount -1; i++)
{
parameterShardActors[i] = Context.ActorOf(new Props(typeof(ParameterShard), new object[]{ new ParameterShard(i, LearningRate, new double[3,3])}));
}
var dataShardActors = new List<IActorRef>();
foreach (var dataShard in dataShards)
{
dataShardActors.Add(Context.ActorOf(new Props(typeof(DataShard), new []{new DataShard
{
} })));
}
var shardsFinishedCount = 0;
Receive<Start>(start =>
{
foreach (var dataShardActor in dataShardActors)
{
dataShardActor.Tell(new ReadyToProcess());
}
});
Receive<Done>(done =>
{
shardsFinishedCount++;
if (shardsFinishedCount == dataShards.Count)
Console.WriteLine("Done");
});
}
开发者ID:padzikm,项目名称:Distbelief,代码行数:32,代码来源:Master.cs
示例11: RoomActor
public RoomActor(long id, string name,
IActorRef roomAccess,
IActorRef messageAccess,
ICanTell signalR)
{
_roomId =id;
_name = name;
_users = new Dictionary<long, User>();
_roomAccess = roomAccess;
_messageAccess = messageAccess;
_signalR = signalR;
Receive<UsersInRoomMessage>(message =>
{
message.Users.ForEach(user =>
{
_users.Add(user.Id, user);
});
_log.Info("RoomActor-" + _name + " established");
Become(Established);
});
Receive<FailedToGetUsersInRoomMessage>(message =>
{
_log.Error("FailedToGetUsersInRoomMessage-" + _roomId + ": " + message.Message);
ScheduleUserLoading(TimeSpan.FromSeconds(30));
});
ReceiveAny(x => Stash.Stash());
}
开发者ID:tpaananen,项目名称:TestingAkka.NET,代码行数:31,代码来源:RoomActor.cs
示例12: ConnectionRequest
public ConnectionRequest(Guid clientId, ClientStatus initialStatus, string username, IActorRef clientsActor)
{
ClientId = clientId;
InitialStatus = initialStatus;
Username = username;
ClientsHandler = clientsActor;
}
开发者ID:patchandthat,项目名称:Yakka,代码行数:7,代码来源:ConnectionMessages.cs
示例13: EchoConnectionHandler
public EchoConnectionHandler(EndPoint remote, IActorRef connection)
{
// we want to know when the connection dies (without using Tcp.ConnectionClosed)
Context.Watch(connection);
Receive<Tcp.Received>(received =>
{
var text = Encoding.UTF8.GetString(received.Data.ToArray()).Trim();
Console.WriteLine("Received '{0}' from remote address [{1}]", text, remote);
if (text == "exit")
Context.Stop(Self);
else
Sender.Tell(Tcp.Write.Create(received.Data));
});
Receive<Tcp.ConnectionClosed>(closed =>
{
Console.WriteLine("Stopped, remote connection [{0}] closed", remote);
Context.Stop(Self);
});
Receive<Terminated>(terminated =>
{
Console.WriteLine("Stopped, remote connection [{0}] died", remote);
Context.Stop(Self);
});
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:25,代码来源:Actors.cs
示例14: ConnectionResponse
public ConnectionResponse(IActorRef activeClientsActor, IActorRef hearbeatReceiver, IEnumerable<ConnectedClient> connectedClients, IActorRef messageHandler)
{
ActiveClientsActor = activeClientsActor;
HearbeatReceiver = hearbeatReceiver;
ConnectedClients = connectedClients;
MessageHandler = messageHandler;
}
开发者ID:patchandthat,项目名称:Yakka,代码行数:7,代码来源:ConnectionMessages.cs
示例15: ForwardMessages
private void ForwardMessages(BufferedMessages messages, IActorRef recipient)
{
messages.ForEach(c =>
{
recipient.Tell(c.Key, c.Value);
});
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:PerGroupingBuffer.cs
示例16: ConversationViewModel
/// <summary>
/// Creates an instance of the screen.
/// </summary>
public ConversationViewModel(IActorRef vmActor, Guid id)
{
_vmActor = vmActor;
Id = id;
_vmActor.Tell(new ConversationViewModelActor.AssociateWithViewModel(this));
}
开发者ID:patchandthat,项目名称:Yakka,代码行数:10,代码来源:ConversationViewModel.cs
示例17: Pass
public Pass(IActorRef endpoint, int? uid, int? refuseUid)
: base(false)
{
Uid = uid;
Endpoint = endpoint;
RefuseUid = refuseUid;
}
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:7,代码来源:EndpointManager.cs
示例18: API
public API(IActorRef viewsRepo, IActorRef videoDetails)
{
_viewsRepo = viewsRepo;
_videoDetails = videoDetails;
Start();
}
开发者ID:thelegendofando,项目名称:Pluralsight,代码行数:7,代码来源:API.cs
示例19: 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, IActorRef supervisor)
{
Props = props;
Deploy = deploy;
Path = path;
Supervisor = supervisor;
}
开发者ID:njimenez,项目名称:akka.net,代码行数:14,代码来源:RemoteSystemDaemon.cs
示例20: RecommendationWorkflow
public RecommendationWorkflow(IActorRef viewsRepo, IActorRef videoDetails)
{
_viewsRepo = viewsRepo;
_videoDetails = videoDetails;
AcceptingJob();
}
开发者ID:thelegendofando,项目名称:Pluralsight,代码行数:7,代码来源:RecommendationWorkflow.cs
注:本文中的IActorRef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论