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