1 | #include "buffer_pair.hpp" |
---|
2 | |
---|
3 | #include "impi_interface.hpp" |
---|
4 | |
---|
5 | namespace xmlioserver |
---|
6 | { |
---|
7 | namespace comm |
---|
8 | { |
---|
9 | /// ////////////////////// Définitions ////////////////////// /// |
---|
10 | CBufferPair::CBufferPair(MPIComm com_client_server) |
---|
11 | : com_client_server(com_client_server) |
---|
12 | , first(BUFFER_CLIENT_SIZE), second(BUFFER_CLIENT_SIZE) |
---|
13 | , first_request(mpi_request_null), second_request(mpi_request_null) |
---|
14 | , currentBuffer(0) |
---|
15 | { /* Ne rien faire de plus */ } |
---|
16 | |
---|
17 | CBufferPair::~CBufferPair(void) |
---|
18 | { /* Ne rien faire de plus */ } |
---|
19 | |
---|
20 | ///-------------------------------------------------------------- |
---|
21 | |
---|
22 | bool CBufferPair::mustBeSent(void) |
---|
23 | { |
---|
24 | if ((currentBuffer == 0) && (first.getUsedSize() != 0) && |
---|
25 | ((second_request == mpi_request_null) || CMPIManager::Test (second_request))) |
---|
26 | return (true); |
---|
27 | |
---|
28 | if ((currentBuffer == 1) && (second.getUsedSize() != 0) && |
---|
29 | ((first_request == mpi_request_null) || CMPIManager::Test (first_request))) |
---|
30 | return (true); |
---|
31 | |
---|
32 | return (false); |
---|
33 | } |
---|
34 | |
---|
35 | //--------------------------------------------------------------- |
---|
36 | |
---|
37 | int CBufferPair::wait(void) |
---|
38 | { |
---|
39 | if (this->currentBuffer == 0) |
---|
40 | { |
---|
41 | CMPIManager::Wait(this->second_request); |
---|
42 | this->second_request = mpi_request_null; |
---|
43 | return (this->second_request); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | CMPIManager::Wait(this->first_request); |
---|
48 | this->first_request = mpi_request_null; |
---|
49 | return (this->first_request); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | //--------------------------------------------------------------- |
---|
54 | |
---|
55 | void CBufferPair::sendCurrentBuffer(void) |
---|
56 | { |
---|
57 | if (this->currentBuffer == 0) |
---|
58 | { |
---|
59 | CMPIManager::SendLinearBuffer |
---|
60 | (this->com_client_server, 0, this->first, this->first_request); |
---|
61 | this->currentBuffer = 1; |
---|
62 | this->second_request = mpi_request_null; |
---|
63 | this->second.clear(); |
---|
64 | } |
---|
65 | else if(this->currentBuffer == 1) |
---|
66 | { |
---|
67 | CMPIManager::SendLinearBuffer |
---|
68 | (this->com_client_server, 0, this->second, this->second_request); |
---|
69 | this->currentBuffer = 0; |
---|
70 | this->first_request = mpi_request_null; |
---|
71 | this->first.clear(); |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | //--------------------------------------------------------------- |
---|
76 | |
---|
77 | CLinearBuffer & CBufferPair::getCurrentBuffer(void) |
---|
78 | { |
---|
79 | if (currentBuffer == 0) return (this->first); |
---|
80 | return (this->second); |
---|
81 | } |
---|
82 | |
---|
83 | ///-------------------------------------------------------------- |
---|
84 | |
---|
85 | } // namespace tree |
---|
86 | } // namespace xmlioserver |
---|
87 | |
---|