text
stringlengths
0
2.2M
if (0 != sts) {
return 0; // RETURN
}
d_cursor_p = d_cursor_p
+ bsls::AlignmentUtil::calculateAlignmentOffset(
d_cursor_p, static_cast<int>(d_alignment));
}
BSLS_ASSERT(d_endOfBuffer_p >= d_cursor_p + size);
char *address = d_cursor_p;
d_cursor_p += size;
return address;
}
void HeapBypassAllocator::deallocate(void *)
{
// no-op
}
} // close package namespace
} // close enterprise namespace
// ----------------------------------------------------------------------------
// Copyright 2016 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
#include "ofMain.h"
#include "ofAppNoWindow.h"
#include "ofxUnitTests.h"
#include "ofxNetwork.h"
class ofApp: public ofxUnitTestsApp{
public:
void testNonBlocking(int timeout = 0){
ofLogNotice() << "---------------------------------------";
ofLogNotice() << "testNonBlocking";
int port = ofRandom(15000, 65535);
ofxTCPServer server;
ofxTest(server.setup(port,false), "non blocking server");
ofxTCPClient client;
ofxTest(client.setup("127.0.0.1",port,false), "non blocking client");
server.waitConnectedClient(500);
bool received = false;
std::string messageSent = "message";
std::string messageReceived;
ofxTest(client.send(messageSent), "send non blocking from client");
for(int i=0;i<server.getLastID();i++){
if(!server.isClientConnected(i)){
continue;
}
for(int i=0;i<10 && !received;i++){
ofSleepMillis(200);
messageReceived = server.receive(i);
if(messageReceived == messageSent){
received = true;
}
}
ofxTest(received, "receive non blocking from server");
}
for(int i=0;i<server.getLastID();i++){
if(!server.isClientConnected(i)){
continue;
}
ofxTest(server.send(i,messageSent), "send non blocking from server");
messageReceived = "";
for(int i=0;i<10 && !received;i++){
ofSleepMillis(200);
messageReceived = client.receive();
if(messageReceived == messageSent){
received = true;
}
}
ofxTest(received, "receive non blocking from client");
break;
}
}
void testBlocking(){