ua_asyncmethod_manager.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 asyncOperationEntry {
  23. LIST_ENTRY(asyncOperationEntry) pointers;
  24. UA_UInt32 requestId;
  25. UA_NodeId sessionId;
  26. UA_UInt32 requestHandle;
  27. UA_DateTime dispatchTime; /* Creation time */
  28. UA_UInt32 nCountdown; /* Counter for open UA_CallResults */
  29. UA_AsyncOperationType operationType;
  30. union {
  31. UA_CallResponse callResponse;
  32. UA_ReadResponse readResponse;
  33. UA_WriteResponse writeResponse;
  34. } response;
  35. } asyncOperationEntry;
  36. typedef struct UA_AsyncMethodManager {
  37. LIST_HEAD(, asyncOperationEntry) asyncOperations;
  38. UA_UInt32 currentCount;
  39. } UA_AsyncMethodManager;
  40. void
  41. UA_AsyncMethodManager_init(UA_AsyncMethodManager *amm);
  42. /* Deletes all entries */
  43. void UA_AsyncMethodManager_clear(UA_AsyncMethodManager *amm);
  44. UA_StatusCode
  45. UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
  46. const UA_NodeId *sessionId, const UA_UInt32 channelId,
  47. const UA_UInt32 requestId, const UA_UInt32 requestHandle,
  48. const UA_AsyncOperationType operationType,
  49. const UA_UInt32 nCountdown);
  50. /* The pointers amm and current must not be NULL */
  51. void
  52. UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm, asyncOperationEntry *current);
  53. asyncOperationEntry *
  54. UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 requestId,
  55. const UA_NodeId *sessionId);
  56. void
  57. UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *amm);
  58. _UA_END_DECLS
  59. #endif
  60. #endif /* UA_ASYNCMETHOD_MANAGER_H_ */