File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -1001,25 +1001,30 @@ int ExternalFileUnit::GetAsynchronousId(IoErrorHandler &handler) {
1001
1001
if (!mayAsynchronous ()) {
1002
1002
handler.SignalError (IostatBadAsynchronous);
1003
1003
return -1 ;
1004
- } else if (auto least{asyncIdAvailable_.LeastElement ()}) {
1005
- asyncIdAvailable_.reset (*least);
1006
- return static_cast <int >(*least);
1007
1004
} else {
1005
+ for (int j{0 }; 64 * j < maxAsyncIds; ++j) {
1006
+ if (auto least{asyncIdAvailable_[j].LeastElement ()}) {
1007
+ asyncIdAvailable_[j].reset (*least);
1008
+ return 64 * j + static_cast <int >(*least);
1009
+ }
1010
+ }
1008
1011
handler.SignalError (IostatTooManyAsyncOps);
1009
1012
return -1 ;
1010
1013
}
1011
1014
}
1012
1015
1013
1016
bool ExternalFileUnit::Wait (int id) {
1014
- if (static_cast <std::size_t >(id) >= asyncIdAvailable_. size () ||
1015
- asyncIdAvailable_.test (id)) {
1017
+ if (static_cast <std::size_t >(id) >= maxAsyncIds ||
1018
+ asyncIdAvailable_[id / 64 ] .test (id % 64 )) {
1016
1019
return false ;
1017
1020
} else {
1018
1021
if (id == 0 ) { // means "all IDs"
1019
- asyncIdAvailable_.set ();
1020
- asyncIdAvailable_.reset (0 );
1022
+ for (int j{0 }; 64 * j < maxAsyncIds; ++j) {
1023
+ asyncIdAvailable_[j].set ();
1024
+ }
1025
+ asyncIdAvailable_[0 ].reset (0 );
1021
1026
} else {
1022
- asyncIdAvailable_.set (id);
1027
+ asyncIdAvailable_[id / 64 ] .set (id % 64 );
1023
1028
}
1024
1029
return true ;
1025
1030
}
Original file line number Diff line number Diff line change @@ -36,10 +36,14 @@ class ExternalFileUnit : public ConnectionState,
36
36
public OpenFile,
37
37
public FileFrame<ExternalFileUnit> {
38
38
public:
39
+ static constexpr int maxAsyncIds{64 * 16 };
40
+
39
41
explicit ExternalFileUnit (int unitNumber) : unitNumber_{unitNumber} {
40
42
isUTF8 = executionEnvironment.defaultUTF8 ;
41
- asyncIdAvailable_.set ();
42
- asyncIdAvailable_.reset (0 );
43
+ for (int j{0 }; 64 * j < maxAsyncIds; ++j) {
44
+ asyncIdAvailable_[j].set ();
45
+ }
46
+ asyncIdAvailable_[0 ].reset (0 );
43
47
}
44
48
~ExternalFileUnit () {}
45
49
@@ -150,7 +154,7 @@ class ExternalFileUnit : public ConnectionState,
150
154
std::size_t recordOffsetInFrame_{0 }; // of currentRecordNumber
151
155
bool swapEndianness_{false };
152
156
bool createdForInternalChildIo_{false };
153
- common::BitSet<64 > asyncIdAvailable_;
157
+ common::BitSet<64 > asyncIdAvailable_[maxAsyncIds / 64 ] ;
154
158
155
159
// When a synchronous I/O statement is in progress on this unit, holds its
156
160
// state.
You can’t perform that action at this time.
0 commit comments