VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
piped_request_waiter.h
Go to the documentation of this file.
1 // Copyright (c) 2018, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
8 #ifndef _UGCS_VSM_PIPED_REQUEST_WAITER_H_
9 #define _UGCS_VSM_PIPED_REQUEST_WAITER_H_
10 
12 #include <ugcs/vsm/utils.h>
13 #include <ugcs/vsm/sockets.h>
14 
15 #include <atomic>
16 
17 namespace ugcs {
18 namespace vsm {
19 
23 
24 public:
27 
28  virtual
29  ~Piped_request_waiter();
30 
31  virtual void
32  Notify() override;
33 
35  bool
36  Wait(std::chrono::milliseconds timeout = std::chrono::milliseconds(-1));
37 
39  void
40  Ack();
41 
43  sockets::Socket_handle
45  {
46  return read_pipe;
47  }
48 
49 private:
51  sockets::Socket_handle write_pipe = INVALID_SOCKET;
52 
54  sockets::Socket_handle read_pipe = INVALID_SOCKET;
55 
59  std::atomic_bool notified = { false };
60 };
61 
62 } /* namespace vsm */
63 } /* namespace ugcs */
64 
65 #endif /* _UGCS_VSM_PIPED_REQUEST_WAITER_H_ */
sockets::Socket_handle Get_wait_pipe()
Get the platform handler of the wait pipe.
Definition: piped_request_waiter.h:44
Various common utilities.
Request container declaration.
void Ack()
Consume one notification event.
virtual void Notify() override
Notify all listeners about request submission.
bool Wait(std::chrono::milliseconds timeout=std::chrono::milliseconds(-1))
Wait for an event for specific amount of time.
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
Request waiter which uses a pipe to signal about request submissions.
Definition: piped_request_waiter.h:21
Represents request synchronization entity which is used for request queues protected access...
Definition: request_container.h:361