Can a channel created by one thread be used by another thread?
I have a service application that runs multiple threads to talk to many remote RO SDK servers. The threads use a TROSuperTcpChannel to communicate (“ChannelA”). At some point, I have a large file that can take up to 5 minutes to send to the server. This is done by cutting it into chunks of about 2Mb and sending it in a loop. Thus ensures that we are able to see the flow and control timeouts in case of disconnect. However, there is additional priority information that needs to be sent while the 5 minute loop is happening, so I have to find a solution. One thing we are considering is having the thread (“ThreadA”) opening another channel (“ChannelB”) which is then left idle. During the long sends, we could have another thread (“ThreadB”) send the priority using ChannelB. The key question is whether this is supported - I don’t want to have weird issues due to thread safety. I’d have it so that ThreadA would not be using ChannelB.
Alternatively of course, is it possible to do multiple calls on the same channel at the same time? Is there a better system that anyone can suggest? I look forward to your input…
Super TCP channel puts all requests into pool and they are sent asynchonically so you can do multiple calls on the same channel at the same time.
if you send the priority info via “ChannelA”, this info will be sent as soon as the channel sent 2mb chunk to server.
if it is suitable for you - you can use only one channel. also you can split chunks more, say, 1mb or 512 kb.
Thank you for responding. I read in the documentation that you can make multiple calls, but there is no information on “how”, so I presume this is via the _async variants of the calls - is that right? The problem of course is my code is a nice tight loop sending chunks of the data, so going async would be a problem. However, if I could send to the ThreadA channel from ThreadB, then I’d be happy to do that - but I would need to know that this is properly supported and thread safe.
Another option I’ve pondered is having my ThreadA loop check a [thread safe] structure that ThreadB can put stuff in for sending. But my ideal is that ThreadB could send to all the instances of ThreadA via their existing or ChannelB without the ThreadA code knowing anything.
You don’t need to use _async version of SuperTCP channels because it is designed to be async by default, i.e. all calls are processed asynchronously.
You can use ChannelA in ThreadB, but you still need to use own TROBinMessage instance because it isn’t thread-safe.
Okay, the code for this will be lovely - the interfaces require the message and channel, so I guess that means new interfaces. I’d have to work on ownership quite carefully.I shall do some experimenting.