本文整理汇总了C++中stream::ptr::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr::flush方法的具体用法?C++ ptr::flush怎么用?C++ ptr::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream::ptr
的用法示例。
在下文中一共展示了ptr::flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sslserver
MORDOR_UNITTEST(SSLStream, forceDuplex)
{
WorkerPool pool;
std::pair<Stream::ptr, Stream::ptr> pipes = pipeStream();
SSLStream::ptr sslserver(new SSLStream(pipes.first, false));
SSLStream::ptr sslclient(new SSLStream(pipes.second, true));
Stream::ptr server = sslserver, client = sslclient;
int sequence = 0;
pool.schedule(boost::bind(&accept, sslserver));
sslclient->connect();
pool.dispatch();
pool.schedule(boost::bind(&readWorld, client,
boost::ref(sequence)));
pool.dispatch();
MORDOR_TEST_ASSERT_EQUAL(++sequence, 2);
// Read is pending
client->write("hello");
client->flush(false);
pool.dispatch();
server->write("world");
server->flush(false);
pool.dispatch();
MORDOR_TEST_ASSERT_EQUAL(++sequence, 4);
}
示例2: writeLotsaData
static void writeLotsaData(Stream::ptr stream, unsigned long long toTransfer, bool &complete)
{
RandomStream random;
MORDOR_TEST_ASSERT_EQUAL(transferStream(random, stream, toTransfer), toTransfer);
stream->flush();
complete = true;
}
示例3: writeALot
static void writeALot(Stream::ptr stream)
{
for (size_t i = 0; i < A_LOT_OF_ITERATIONS; ++i) {
MORDOR_TEST_ASSERT_EQUAL(stream->write("t", 1u), 1u);
stream->flush(false);
}
}
示例4: basicInFibers
static void basicInFibers(Stream::ptr stream, int &sequence)
{
MORDOR_TEST_ASSERT_EQUAL(sequence, 1);
MORDOR_TEST_ASSERT_EQUAL(stream->write("a"), 1u);
stream->close();
stream->flush();
++sequence;
MORDOR_TEST_ASSERT_EQUAL(sequence, 3);
}
示例5: threadStress
void threadStress(Stream::ptr stream)
{
size_t totalRead = 0;
size_t totalWritten = 0;
size_t buf[64];
Buffer buffer;
for (int i = 0; i < 10000; ++i) {
if (i % 2) {
size_t toRead = 64;
size_t read = stream->read(buffer, toRead * sizeof(size_t));
MORDOR_TEST_ASSERT(read % sizeof(size_t) == 0);
buffer.copyOut(&buf, read);
for (size_t j = 0; read > 0; read -= sizeof(size_t), ++j) {
MORDOR_TEST_ASSERT_EQUAL(buf[j], ++totalRead);
}
buffer.clear();
} else {
size_t toWrite = 64;
for (size_t j = 0; j < toWrite; ++j) {
buf[j] = ++totalWritten;
}
buffer.copyIn(buf, toWrite * sizeof(size_t));
size_t written = stream->write(buffer, toWrite * sizeof(size_t));
totalWritten -= (toWrite - written / sizeof(size_t));
buffer.clear();
}
}
stream->close(Stream::WRITE);
while (true) {
size_t toRead = 64;
size_t read = stream->read(buffer, toRead);
if (read == 0)
break;
MORDOR_TEST_ASSERT(read % sizeof(size_t) == 0);
buffer.copyOut(&buf, read);
for (size_t i = 0; read > 0; read -= sizeof(size_t), ++i) {
MORDOR_TEST_ASSERT_EQUAL(buf[i], ++totalRead);
}
buffer.clear();
}
stream->flush();
}