Branch data Line data Source code
1 : : // Copyright 2026 HPActor Contributors
2 : : //
3 : : // Licensed under the Apache License, Version 2.0 (the "License");
4 : : // you may not use this file except in compliance with the License.
5 : : // You may obtain a copy of the License at
6 : : //
7 : : // http://www.apache.org/licenses/LICENSE-2.0
8 : : //
9 : : // Unless required by applicable law or agreed to in writing, software
10 : : // distributed under the License is distributed on an "AS IS" BASIS,
11 : : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : // See the License for the specific language governing permissions and
13 : : // limitations under the License.
14 : :
15 : : #pragma once
16 : :
17 : : #include <hpactor/actor/daemon_actor.hpp>
18 : :
19 : : namespace hpactor {
20 : :
21 : : class PollingActor : public DaemonActor {
22 : : public:
23 : 1 : PollingActor(ActorContext* ctx, ActorSystem& sys, int cpu_core = -1)
24 : 1 : : DaemonActor(ctx, sys) {
25 : 1 : if (cpu_core >= 0) set_cpu_affinity(cpu_core);
26 : 1 : }
27 : :
28 : : void set_poll_budget(uint32_t max_events) { poll_budget_ = max_events; }
29 : : uint32_t poll_budget() const { return poll_budget_; }
30 : :
31 : : protected:
32 : : uint32_t poll_budget_ = 64;
33 : : };
34 : :
35 : : } // namespace hpactor
|