hmbdc
simplify-high-performance-messaging-programming
changeSched.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 #include "hmbdc/app/Client.hpp"
4 #include "hmbdc/app/Logger.hpp"
5 #include "hmbdc/Exception.hpp"
6 #include "hmbdc/os/Thread.hpp"
7 
8 namespace hmbdc { namespace app { namespace utils {
9 
11 : Client<changeSched>
13  /*virtual*/
14  void
15  messageDispatchingStartedCb(uint16_t threadSerialNumber) override {
16  hmbdc::os::setCurrrentThreadSched(policy_, priority_);
17  throw hmbdc::ExitCode(0);
18  };
19  /*virtual*/
20  bool droppedCb() override {
21  delete this;
22  return true;
23  };
24 
25  static
26  auto& to(char const* policy, int priority) {
27  return *new changeSched(policy, priority);
28  }
29 
30 private:
31  changeSched(char const* policy, int priority)
32  : policy_(policy)
33  , priority_(priority)
34  {}
35 
36  char const* policy_;
37  int priority_;
38 
39 };
40 
41 
42 
43 }}}
void messageDispatchingStartedCb(uint16_t threadSerialNumber) override
called before any messages got dispatched - only once
Definition: changeSched.hpp:15
bool droppedCb() override
callback called after the Client is safely taken out of the Context
Definition: changeSched.hpp:20
a trait class, if a Client can only run on a single specific thread in Pool, derive the Client from i...
Definition: Client.hpp:17
Definition: changeSched.hpp:10
A Client represents a thread of execution/a task. The execution is managed by a Context. a Client object could participate in message dispatching as the receiver of specifed message types.
Definition: Client.hpp:47
Exception that just has an exit code.
Definition: Exception.hpp:28
Definition: Base.hpp:12