本文整理汇总了C#中ISubscriber类的典型用法代码示例。如果您正苦于以下问题:C# ISubscriber类的具体用法?C# ISubscriber怎么用?C# ISubscriber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISubscriber类属于命名空间,在下文中一共展示了ISubscriber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IPublisher publisher = new Publisher(countOfChannels, countOfSubscribers);
IDataMediator dataMediator = (IDataMediator) publisher;
ISubscriber[] subscribers = new ISubscriber[countOfSubscribers];
for (int i = countOfSubscribers - 1; i >= 0; i--)
{
subscribers[i] = new Subscriber(publisher);
}
runSubscribe(subscribers, publisher);
Thread.CurrentThread.Priority = ThreadPriority.Highest;
for (int i = 0; i < 1000; i++)
{
Stopwatch latency = Stopwatch.StartNew();
int onLoadSubscribersCount = dataMediator.onLoad(randomBytes(10000), rnd.Next(countOfChannels));
latency.Stop();
Console.Write("latency is\t" + latency.Elapsed.Milliseconds + "\tfor\t" + onLoadSubscribersCount + "\tsubscribers");
Console.WriteLine();
}
Console.WriteLine("thats all");
Console.ReadLine();
}
示例2: SetupMessaging
public void SetupMessaging(ISubscriber mainBus)
{
mainBus.Subscribe<SystemMessage.StateChangeMessage>(_projectionManager);
if (_runProjections >= RunProjections.System)
{
mainBus.Subscribe<ProjectionManagementMessage.Post>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.UpdateQuery>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.GetQuery>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Delete>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.GetStatistics>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.GetState>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.GetResult>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Disable>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Enable>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Abort>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.SetRunAs>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Reset>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.StartSlaveProjections>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.RegisterSystemProjection>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Internal.RegularTimeout>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_projectionManager);
mainBus.Subscribe<ProjectionManagementMessage.RegisterSystemProjection>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.Started>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.Stopped>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.Faulted>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.Prepared>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.StateReport>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.ResultReport>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.StatisticsReport>(_projectionManager);
mainBus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_projectionManager);
}
mainBus.Subscribe<ClientMessage.WriteEventsCompleted>(_projectionManager);
mainBus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_projectionManager);
}
示例3: Remove
public void Remove(ISubscriber subscriber)
{
if (subscribers.ContainsKey(subscriber.GetType()))
{
subscribers.Remove(subscriber.GetType());
}
}
示例4: Subscribe
public void Subscribe(ISubscriber subscriber)
{
if (!_subscribers.Contains(subscriber))
{
_subscribers.Add(subscriber);
}
}
示例5: getInitialArray
void IPublisher.subscribe(ISubscriber subscriber, IList<int> channelsToSubscribe)
{
int[] subscribedChannels = subscriberChannels.GetOrAdd(subscriber, getInitialArray(this.channelsCapacity));
foreach (var channel in channelsToSubscribe)
{
if (0 <= channel && channel < channelSubscribers.Length - 1 && subscribedChannels[channel] == -1)
{
for (int i = 0; i < this.subscribersCapacity; i++)
{
if (channelSubscribers[channel][i] == null)
{
locks[channel][i].EnterWriteLock();
try
{
subscribedChannels[channel] = channel;
if (channelSubscribers[channel][i] == null)
{
channelSubscribers[channel][i] = subscriber;
break;
}
}
finally
{
locks[channel][i].ExitWriteLock();
}
}
}
}
}
}
示例6: Add
public void Add(ISubscriber subscriber)
{
if (!subscribers.ContainsKey(subscriber.GetType()))
{
subscribers.Add(subscriber.GetType(), subscriber);
}
}
示例7: UnSubscribe
public void UnSubscribe(ISubscriber subscriber)
{
if (_subscribers.Contains(subscriber))
{
_subscribers.Remove(subscriber);
}
}
示例8: LunchFilter
public LunchFilter(IFiber fiber,
ISubscriber<SimpleYouTubeClip> input,
IPublisher<SimpleYouTubeClip> output)
{
this.output = output;
this.subscription = input.Subscribe(fiber, NewClip);
}
示例9: EventStoreEmbeddedNodeConnection
public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
{
Ensure.NotNull(publisher, "publisher");
Ensure.NotNull(settings, "settings");
Guid connectionId = Guid.NewGuid();
_settings = settings;
_connectionName = connectionName;
_publisher = publisher;
_authenticationProvider = authenticationProvider;
_subscriptionBus = new InMemoryBus("Embedded Client Subscriptions");
_subscriptions = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);
_subscriptionBus.Subscribe<ClientMessage.SubscriptionConfirmation>(_subscriptions);
_subscriptionBus.Subscribe<ClientMessage.SubscriptionDropped>(_subscriptions);
_subscriptionBus.Subscribe<ClientMessage.StreamEventAppeared>(_subscriptions);
_subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
_subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
_subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.SubscribeToStream>(_publisher.Publish));
_subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
_subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));
bus.Subscribe(new AdHocHandler<SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
}
示例10: Subscribe
public void Subscribe(ISubscriber subscriber)
{
if(_subscribers.Contains(subscriber) == false)
{
_subscribers.Add(subscriber);
}
}
示例11: TestMassivePublish
private void TestMassivePublish(ISubscriber conn, string caption)
{
const int loop = 100000;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
var tasks = new Task[loop];
var withFAF = Stopwatch.StartNew();
for (int i = 0; i < loop; i++)
conn.Publish("foo", "bar", CommandFlags.FireAndForget);
withFAF.Stop();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
var withAsync = Stopwatch.StartNew();
for (int i = 0; i < loop; i++)
tasks[i] = conn.PublishAsync("foo", "bar");
conn.WaitAll(tasks);
withAsync.Stop();
Assert.Less(1, 2, "sanity check");
Assert.Less(withFAF.ElapsedMilliseconds, withAsync.ElapsedMilliseconds, caption);
Console.WriteLine("{2}: {0}ms (F+F) vs {1}ms (async)",
withFAF.ElapsedMilliseconds, withAsync.ElapsedMilliseconds, caption);
}
示例12: MainWindow
public MainWindow(ISubscriber<PlayerCommand> commandChannel, IPublisher<RichYouTubeClip> finishedChannel)
{
InitializeComponent();
this.finishedChannel = finishedChannel;
finishedTimer = new Timer(TimerExpired);
progressTimer = new System.Timers.Timer(1000);
progressTimer.AutoReset = true;
progressTimer.Elapsed += new System.Timers.ElapsedEventHandler(progressTimer_Elapsed);
var fiber = new DispatcherFiber(Dispatcher);
commandChannel.Subscribe(fiber, OnPlayerCommand);
fiber.Start();
WindowStyle = WindowStyle.None;
WindowState = WindowState.Maximized;
ShowInTaskbar = false;
Cursor = Cursors.None;
try
{
tv.Initialize();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error initialize remote control", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
示例13: Register
public void Register(
TFChunkDb db, QueuedHandler mainQueue, ISubscriber mainBus, TimerService timerService,
ITimeProvider timeProvider, IHttpForwarder httpForwarder, HttpService[] httpServices, IPublisher networkSendService)
{
_projections = new EventStore.Projections.Core.Projections(
db, mainQueue, mainBus, timerService, timeProvider, httpForwarder, httpServices, networkSendService,
projectionWorkerThreadCount: _projectionWorkerThreadCount, runProjections: _runProjections);
}
示例14: PlaylistController
public PlaylistController(IFiber fiber,
ISubscriber<RichYouTubeClip> newClips,
ISubscriber<RichYouTubeClip> finishedPlaying,
IPublisher<PlayerCommand> playerCommands)
{
this.playerCommands = playerCommands;
this.newClipSubscription = newClips.Subscribe(fiber, NewClip);
this.finishedSubscription = finishedPlaying.Subscribe(fiber, Finished);
}
示例15: RedisSubscriberTests
public RedisSubscriberTests()
{
_subscriber = A.Fake<ISubscriber>();
_remoteCache = A.Fake<ICacheAside>();
_itemSerializer = A.Fake<IItemSerializer>();
_connection = A.Fake<IConnectionMultiplexer>();
A.CallTo(() => _connection.GetSubscriber(A<object>._)).Returns(_subscriber);
}