Hello, support team:
I'm developing an UA based gateway program. This program will be able to process some method call request which will lead blocking I/O operation, for example, update address space configuration file or access user account data file.
In single thread mode, this kind of request will block the event loop of UA Server until the I/O blocking operation is done.
So, I wonder if it is possible to dispatch this kind of request to anther thread, and this thread will be in charge of processing and responding to the client?
If it is possible, do I need to do some lock job when I send back the responds to UA Stack? At which moment do I need to lock?
Thanks a lot
Is that possible to demultiplex the method call request
Moderator: uasdkc
-
- Sr. Member
- Posts: 14
- Joined: 28 May 2013, 03:15
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Is that possible to demultiplex the method call request
Hello,
you can dispatch all calls to the provider to another thread and process them there.
The only thing to remember is that the according XYZ_WriteComplete-callback needs to be called by the main thread that is calling UaServer_DoCom() in a loop. Hence you will have to create some sort of message queue that is filled with the responses by the worker thread and that is processed by the main thread.
Additionally you can call out of the worker thread to signal the stack to return from the UaServer_DoCom() function, so that the new response in your message loop can be handled as soon as possible.
Best regards,
Unified Automation Support Team
you can dispatch all calls to the provider to another thread and process them there.
The only thing to remember is that the according XYZ_WriteComplete-callback needs to be called by the main thread that is calling UaServer_DoCom() in a loop. Hence you will have to create some sort of message queue that is filled with the responses by the worker thread and that is processed by the main thread.
Additionally you can call
Code: Select all
OpcUa_SocketManager_SignalEvent(OpcUa_Null, OPCUA_SOCKET_RENEWLOOP_EVENT, OpcUa_True);
Best regards,
Unified Automation Support Team
-
- Sr. Member
- Posts: 14
- Joined: 28 May 2013, 03:15
Re: Is that possible to demultiplex the method call request
Ok, Thanks a lot
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Is that possible to demultiplex the method call request
Hello,
please note that it is important to set the define in order to use OpcUa_SocketManager_SignalEvent from other threads, otherwise you might run into problems.
If you are using the CMake files provided with the SDK, you can enable the define by setting the CMake option to ON.
Best regards,
Unified Automation Support Team
please note that it is important to set the define
Code: Select all
OPCUA_USE_SYNCHRONISATION
If you are using the CMake files provided with the SDK, you can enable the define by setting the CMake option
Code: Select all
BUILD_UASTACK_USE_SYNC
Best regards,
Unified Automation Support Team