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 : : // Actor reference implementation - see actor_ref.hpp
16 : :
17 : : #include <hpactor/core/actor_system.hpp>
18 : : #include <hpactor/ref/actor_ref.hpp>
19 : :
20 : : namespace hpactor {
21 : :
22 : 4 : void ActorRef::send(const ActorAddress& target, TypedMessage msg) {
23 : 4 : (void)try_send(target, std::move(msg));
24 : 4 : }
25 : :
26 : : mailbox::EnqueueResult
27 : 332 : ActorRef::try_send(const ActorAddress& target, TypedMessage msg,
28 : : mailbox::DeliveryOptions options) {
29 : 332 : if (is_local()) {
30 : 332 : Actor* actor = get_actor();
31 : 332 : if (actor != nullptr) {
32 : 996 : return actor->get()->system().try_deliver_local(
33 : 332 : target.id, std::move(msg), /*priority=*/0,
34 : 332 : /*deadline_ns=*/INT64_MAX, options);
35 : : }
36 : 0 : return {mailbox::EnqueueResultCode::ActorNotFound, target.id};
37 : : } else {
38 : 0 : ActorProxy* proxy = get_proxy();
39 : 0 : if (proxy != nullptr) {
40 : 0 : return proxy->try_send(target, std::move(msg), options);
41 : : }
42 : 0 : return {mailbox::EnqueueResultCode::ActorNotFound, target.id};
43 : : }
44 : : }
45 : :
46 : : } // namespace hpactor
|