|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using ZeroLevel;
|
|
|
|
|
using ZeroLevel.Network;
|
|
|
|
@ -9,8 +10,14 @@ namespace Processor
|
|
|
|
|
public class ProcessorService
|
|
|
|
|
: BaseZeroService
|
|
|
|
|
{
|
|
|
|
|
private Thread _processThread;
|
|
|
|
|
|
|
|
|
|
protected override void StartAction()
|
|
|
|
|
{
|
|
|
|
|
_processThread = new Thread(HandleIncoming);
|
|
|
|
|
_processThread.IsBackground = true;
|
|
|
|
|
_processThread.Start();
|
|
|
|
|
|
|
|
|
|
ReadServiceInfo();
|
|
|
|
|
AutoregisterInboxes(UseHost());
|
|
|
|
|
|
|
|
|
@ -21,6 +28,16 @@ namespace Processor
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleIncoming()
|
|
|
|
|
{
|
|
|
|
|
while (_incoming.IsCompleted == false)
|
|
|
|
|
{
|
|
|
|
|
int data = _incoming.Take();
|
|
|
|
|
var next = (int)(data ^ Interlocked.Increment(ref _proceed));
|
|
|
|
|
Exchange.Request<int, bool>("test.consumer", "handle", next, result => { });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void StopAction()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
@ -45,11 +62,12 @@ namespace Processor
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlockingCollection<int> _incoming = new BlockingCollection<int>();
|
|
|
|
|
|
|
|
|
|
[ExchangeHandler("handle")]
|
|
|
|
|
public void Handler(ISocketClient client, int data)
|
|
|
|
|
{
|
|
|
|
|
var next = (int)(data ^ Interlocked.Increment(ref _proceed));
|
|
|
|
|
Exchange.Request<int, bool>("test.consumer", "handle", next, result => { });
|
|
|
|
|
_incoming.Add(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|