/src/opendnp3/cpp/lib/src/master/TaskContext.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2013-2022 Step Function I/O, LLC |
3 | | * |
4 | | * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O |
5 | | * LLC (https://stepfunc.io) under one or more contributor license agreements. |
6 | | * See the NOTICE file distributed with this work for additional information |
7 | | * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license |
8 | | * this file to you under the Apache License, Version 2.0 (the "License"); you |
9 | | * may not use this file except in compliance with the License. You may obtain |
10 | | * a copy of the License at: |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | |
21 | | #include "TaskContext.h" |
22 | | |
23 | | #include "master/IMasterTask.h" |
24 | | |
25 | | namespace opendnp3 |
26 | | { |
27 | | |
28 | | void TaskContext::AddBlock(const IMasterTask& task) |
29 | 11 | { |
30 | 11 | this->blocking_tasks.insert(&task); |
31 | 11 | } |
32 | | |
33 | | void TaskContext::RemoveBlock(const IMasterTask& task) |
34 | 80 | { |
35 | 80 | this->blocking_tasks.erase(&task); |
36 | 80 | } |
37 | | |
38 | | bool TaskContext::IsBlocked(const IMasterTask& task) const |
39 | 39.0k | { |
40 | 39.0k | for (auto& blocking : this->blocking_tasks) |
41 | 44 | { |
42 | | // is there a block with better priority that's not the same task? |
43 | 44 | if (blocking->Priority() < task.Priority() && (blocking != &task)) |
44 | 25 | return true; |
45 | 44 | } |
46 | | |
47 | 39.0k | return false; |
48 | 39.0k | } |
49 | | |
50 | | } // namespace opendnp3 |