ua_asyncmethod_manager.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. UA_NodeId sessionId;
  26. UA_UInt32 requestHandle;
  27. const UA_DataType *responseType;
  28. UA_DateTime dispatchTime; /* 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_AsyncMethodManager;
  36. UA_StatusCode
  37. UA_AsyncMethodManager_init(UA_AsyncMethodManager *amm);
  38. /* Deletes all entries */
  39. void UA_AsyncMethodManager_deleteMembers(UA_AsyncMethodManager *amm);
  40. UA_StatusCode
  41. UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
  42. const UA_NodeId *sessionId, const UA_UInt32 channelId,
  43. const UA_UInt32 requestId, const UA_UInt32 requestHandle,
  44. const UA_DataType *responseType, const UA_UInt32 nCountdown);
  45. /* The pointers amm and current must not be NULL */
  46. UA_StatusCode
  47. UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm, asyncmethod_list_entry *current);
  48. asyncmethod_list_entry*
  49. UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 requestId, const UA_NodeId *sessionId);
  50. void
  51. UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *amm);
  52. _UA_END_DECLS
  53. #endif
  54. #endif /* UA_ASYNCMETHOD_MANAGER_H_ */