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