4
4
* @file: DataSeg.cpp
5
5
* @author: Steven R. Emmerson <[email protected] >
6
6
*
7
- * Copyright 2021 University Corporation for Atmospheric Research
7
+ * Copyright 2023 University Corporation for Atmospheric Research
8
8
*
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
9
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
10
+ * in compliance with the License. You may obtain a copy of the License at
12
11
*
13
12
* http://www.apache.org/licenses/LICENSE-2.0
14
13
*
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
14
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
15
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
16
+ * or implied. See the License for the specific language governing permissions and limitations under
17
+ * the License.
20
18
*/
21
19
22
20
#include " config.h"
23
21
24
22
#include " BicastProto.h"
25
23
#include " error.h"
24
+ #include " RunPar.h"
26
25
#include " Socket.h"
27
26
#include " Xprt.h"
28
27
@@ -34,37 +33,13 @@ namespace bicast {
34
33
// / An implementation of a data segment
35
34
class DataSeg ::Impl
36
35
{
37
- static std::atomic<SegSize> maxSegSize; // /< Maximum data-segment size in bytes
38
-
39
36
public:
40
37
DataSegId segId; // /< Data-segment identifier
41
38
// / Product size in bytes (for when product notice is missed)
42
39
ProdSize prodSize;
43
40
SegSize bufSize; // /< Size of buffer in bytes
44
41
char * buf; // /< buffer for data
45
42
46
- /* *
47
- * Sets the maximum size, in bytes, of a data segment. All segments except the last will be this
48
- * size.
49
- * @param[in] maxSegSize Maximum size of a data segment
50
- * @return The previous maximum segment size
51
- */
52
- static SegSize setMaxSegSize (const SegSize maxSegSize) {
53
- if (maxSegSize <= 0 )
54
- throw INVALID_ARGUMENT (" Argument is not positive: " + std::to_string (maxSegSize));
55
- SegSize prev = Impl::maxSegSize;
56
- Impl::maxSegSize = maxSegSize;
57
- return prev;
58
- }
59
-
60
- /* *
61
- * Returns the maximum size of a data segment.
62
- * @return The maximum size of a data segment
63
- */
64
- static SegSize getMaxSegSize () {
65
- return maxSegSize;
66
- }
67
-
68
43
/* *
69
44
* Returns the expected size of a data segment.
70
45
* @param[in] prodSize Size of the containing data product in bytes
@@ -75,9 +50,9 @@ class DataSeg::Impl
75
50
const ProdSize prodSize,
76
51
const SegOffset offset) noexcept {
77
52
const auto nbytes = prodSize - offset;
78
- return (nbytes <= maxSegSize)
53
+ return (nbytes <= RunPar:: maxSegSize)
79
54
? nbytes
80
- : static_cast <SegSize>( maxSegSize) ;
55
+ : RunPar:: maxSegSize;
81
56
}
82
57
83
58
/* *
@@ -86,7 +61,7 @@ class DataSeg::Impl
86
61
* @return The number of data segments in the product
87
62
*/
88
63
static ProdSize numSegs (const ProdSize prodSize) noexcept {
89
- return (prodSize + (maxSegSize - 1 )) / maxSegSize;
64
+ return (prodSize + (RunPar:: maxSegSize - 1 )) / RunPar:: maxSegSize;
90
65
}
91
66
92
67
/* *
@@ -95,7 +70,7 @@ class DataSeg::Impl
95
70
* @return The origin-0 index of the data segment
96
71
*/
97
72
static ProdSize getSegIndex (const ProdSize offset) {
98
- return offset/maxSegSize;
73
+ return offset/RunPar:: maxSegSize;
99
74
}
100
75
101
76
Impl ()
@@ -232,18 +207,8 @@ class DataSeg::Impl
232
207
}
233
208
};
234
209
235
- std::atomic<SegSize> DataSeg::Impl::maxSegSize; // /< Maximum data-segment size in bytes
236
-
237
210
/* *****************************************************************************/
238
211
239
- SegSize DataSeg::setMaxSegSize (const SegSize maxSegSize) noexcept {
240
- return Impl::setMaxSegSize (maxSegSize);
241
- }
242
-
243
- SegSize DataSeg::getMaxSegSize () noexcept {
244
- return Impl::getMaxSegSize ();
245
- }
246
-
247
212
SegSize DataSeg::size (
248
213
const ProdSize prodSize,
249
214
const SegOffset offset) noexcept {
0 commit comments