ua_asyncmethod_manager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2019 (c) Fraunhofer IOSB (Author: Klaus Schick)
  6. * based on
  7. * Copyright 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  8. * Copyright 2014, 2017 (c) Florian Palm
  9. * Copyright 2015 (c) Sten Grüner
  10. * Copyright 2015 (c) Oleksiy Vasylyev
  11. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  12. */
  13. #ifndef UA_ASYNCMETHOD_MANAGER_H_
  14. #define UA_ASYNCMETHOD_MANAGER_H_
  15. #include <open62541/server.h>
  16. #include "open62541_queue.h"
  17. #include "ua_session.h"
  18. #include "ua_util_internal.h"
  19. #include "ua_workqueue.h"
  20. #if UA_MULTITHREADING >= 100
  21. _UA_BEGIN_DECLS
  22. typedef struct asyncmethod_list_entry {
  23. LIST_ENTRY(asyncmethod_list_entry) pointers;
  24. UA_UInt32 requestId;
  25. const UA_NodeId *sessionId;
  26. UA_UInt32 requestHandle;
  27. const UA_DataType *responseType;
  28. UA_DateTime m_tDispatchTime; /* Creation time */
  29. UA_UInt32 nCountdown; /* Counter for open UA_CallResults */
  30. UA_CallResponse response; /* The 'collected' CallResponse for our CallMethodResponse(s) */
  31. } asyncmethod_list_entry;
  32. typedef struct UA_AsyncMethodManager {
  33. LIST_HEAD(asyncmethod_list, asyncmethod_list_entry) asyncmethods; // doubly-linked list of CallRequests/Responses
  34. UA_UInt32 currentCount;
  35. UA_Server *server;
  36. } UA_AsyncMethodManager;
  37. UA_StatusCode
  38. UA_AsyncMethodManager_init(UA_AsyncMethodManager *amm, UA_Server *server);
  39. /* Deletes all entries */
  40. void UA_AsyncMethodManager_deleteMembers(UA_AsyncMethodManager *ammm);
  41. UA_StatusCode
  42. UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, const UA_NodeId *sessionId, const UA_UInt32 channelId,
  43. const UA_UInt32 requestId, const UA_UInt32 requestHandle, const UA_DataType *responseType, const UA_UInt32 nCountdown);
  44. UA_StatusCode
  45. UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm, asyncmethod_list_entry *current);
  46. asyncmethod_list_entry*
  47. UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 requestId, const UA_NodeId *sessionId);
  48. void
  49. UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *amm);
  50. _UA_END_DECLS
  51. #endif
  52. #endif /* UA_ASYNCMETHOD_MANAGER_H_ */