Debian Codegraph @

cpp/src/work_queue.cpp

raw
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 #include "proton/work_queue.hpp"
21
22 #include "proton/duration.hpp"
23
24 #include "contexts.hpp"
25 #include "proactor_container_impl.hpp"
26 #include "proactor_work_queue_impl.hpp"
27
28 #include <proton/session.h>
29 #include <proton/link.h>
30
31 namespace proton {
32
33 work_queue::work_queue() = default;
34 work_queue::work_queue(container& c) { *this = container::impl::make_work_queue(c); }
35
36 work_queue::~work_queue() = default;
37
38 work_queue& work_queue::operator=(impl* i) { impl_.reset(i); return *this; }
39
40 bool work_queue::add(internal::v03::work f) {
41 // If we have no actual work queue, then can't defer
42 if (!impl_) return false;
43 return impl_->add(f);
44 }
45
46 bool work_queue::add(internal::v11::work f) {
47 // If we have no actual work queue, then can't defer
48 if (!impl_) return false;
49 return impl_->add(f);
50 }
51
52 bool work_queue::add(void_function0& f) {
53 return add(make_work(&void_function0::operator(), &f));
54 }
55
56 void work_queue::schedule(duration d, internal::v03::work f) {
57 // If we have no actual work queue, then can't defer
58 if (!impl_) return;
59 return impl_->schedule(d, f);
60 }
61
62 void work_queue::schedule(duration d, internal::v11::work f) {
63 // If we have no actual work queue, then can't defer
64 if (!impl_) return;
65 return impl_->schedule(d, f);
66 }
67
68 void work_queue::schedule(duration d, void_function0& f) {
69 schedule(d, make_work(&void_function0::operator(), &f));
70 }
71
72 work_queue& work_queue::get(pn_connection_t* c) {
73 return connection_context::get(c).work_queue_;
74 }
75
76 work_queue& work_queue::get(pn_session_t* s) {
77 return get(pn_session_connection(s));
78 }
79
80 work_queue& work_queue::get(pn_link_t* l) {
81 return get(pn_link_session(l));
82 }
83
84 }