本文整理汇总了C++中doWork函数的典型用法代码示例。如果您正苦于以下问题:C++ doWork函数的具体用法?C++ doWork怎么用?C++ doWork使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doWork函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(DriverConductorNetworkTest, shouldBeAbleToAddAndRemoveSingleNetworkSubscription)
{
int64_t client_id = nextCorrelationId();
int64_t sub_id = nextCorrelationId();
int64_t remove_correlation_id = nextCorrelationId();
ASSERT_EQ(addNetworkSubscription(client_id, sub_id, CHANNEL_1, STREAM_ID_1, -1), 0);
doWork();
EXPECT_EQ(aeron_driver_conductor_num_network_subscriptions(&m_conductor.m_conductor), 1u);
EXPECT_EQ(readAllBroadcastsFromConductor(null_handler), 1u);
ASSERT_EQ(removeSubscription(client_id, remove_correlation_id, sub_id), 0);
doWork();
auto handler = [&](std::int32_t msgTypeId, AtomicBuffer& buffer, util::index_t offset, util::index_t length)
{
ASSERT_EQ(msgTypeId, AERON_RESPONSE_ON_OPERATION_SUCCESS);
const command::OperationSucceededFlyweight response(buffer, offset);
EXPECT_EQ(response.correlationId(), remove_correlation_id);
};
EXPECT_EQ(aeron_driver_conductor_num_network_subscriptions(&m_conductor.m_conductor), 0u);
EXPECT_EQ(readAllBroadcastsFromConductor(handler), 1u);
}
示例2: WinMain
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int cmdShow)
{
StringVector sv = Helper::split(lpCmdLine, '-');
bool minimized = false;
for (StringVector::iterator itr = sv.begin(); itr != sv.end(); ++ itr)
{
if (*itr == "minimized" || *itr == "m")
{
minimized = true;
break;
}
}
if (minimized)
{
return doWork();
}
else
{
if(AllocConsole())
{
freopen("CONOUT$", "w", stdout);
SetConsoleTitle(SERVER_APP_NAME);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
}
outbuf ob;
std::streambuf *sb = std::cout.rdbuf(&ob);
int result = doWork();
std::cout.rdbuf(sb);
return result;
}
}
示例3: main
int main() {
int x = 10, y = 50, z = 15, sum, max;
doWork(x, y, z, &sum, &max);
printf("Sum = %d, Max = %d\n", sum, max);
return 0;
}
示例4: QByteArray
bool BlinkyTapeUploader::upgradeFirmware(int timeout) {
QByteArray sketch = QByteArray(reinterpret_cast<const char*>(PRODUCTION_DATA),PRODUCTION_LENGTH);
bootloaderPollTimeout = timeout;
char buff[BUFF_LENGTH];
snprintf(buff, BUFF_LENGTH, "Sketch size: %iB",
sketch.length()),
qDebug() << buff;
// The entire sketch must fit into the available memory, minus a single page
// at the end of flash for the configuration header
// TODO: Could save ~100 bytes if we let the sketch spill into the unused portion
// of the header.
if(sketch.length() > FLASH_MEMORY_AVAILABLE) {
qDebug() << "sketch can't fit into memory!";
errorString = QString("Sorry! The Pattern is a bit too big to fit in BlinkyTape memory right now. We're working on improving this! Avaiable space=%1, Pattern size=%2")
.arg(FLASH_MEMORY_AVAILABLE)
.arg(sketch.length());
return false;
}
// Put the sketch, pattern, and metadata into the programming queue.
flashData.push_back(FlashSection(PRODUCTION_ADDRESS, sketch));
setProgress(0);
// TODO: Calculate this based on feedback from the programmer.
setMaxProgress(300);
stateStartTime = QDateTime::currentDateTime();
state = State_WaitForBootloaderPort;
bootloaderResetTimer->singleShot(0,this,SLOT(doWork()));
return true;
}
示例5: while
void Parallel::run(int threadIndex)
{
while (true)
{
// Wait for new work in a critical section
{
std::unique_lock<std::mutex> lock(_mutex);
// Indicate that this thread is no longer doing work
_active[threadIndex] = false;
// Tell the main thread when all parallel threads are inactive
if (!threadsActive()) _conditionMain.notify_all();
// Wait for new work
while (true)
{
_conditionExtra.wait(lock);
// Check for termination request (don't bother with _active; it's no longer used)
if (_terminate) return;
// Check that we actually have new work
if (_active[threadIndex]) break;
}
}
// Do work as long as some is available
doWork();
}
}
示例6: QMainWindow
//COnstructor
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//Server object
ser = new Server();
//THread for server
m_thread = new QThread;
//Connection to signal the server class to start working and checking for messages
connect(this, SIGNAL(startServer()), ser, SLOT(doWork()));
//Connection to notify the GUI to update
connect(ser, SIGNAL(sendText(QString)), this, SLOT(writeText(QString)));
//Start the thread
ser->moveToThread(m_thread);
m_thread->start();
//Start the server working to check for messages
emit startServer();
}
示例7: db2_access
int db2_access(test_req_t *req, test_req_t *resp)
{
SQLHENV henv; /* environment handle */
SQLHDBC hdbc; /* connection handle */
SQLRETURN rc = SQL_ERROR;
SQLHSTMT shdl;
btlogger_debug("op=%c data=%s db=%s\n", req->op, req->data, req->db);
if (init(req->db, &henv, &hdbc) != SQL_SUCCESS)
return (int) rc;
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &shdl);
if ( rc != SQL_SUCCESS ) {
(void) check_error(SQL_HANDLE_STMT, shdl, rc, "SQLAllocHandle", (SQLCHAR *) "statement handle");
} else {
rc = doWork(req->op, req->data, henv, hdbc, shdl, resp);
(void) SQLFreeStmt(shdl, SQL_DROP);
}
fini(henv, hdbc);
return (int) rc;
}
示例8: loop
void loop() {
// do housekeeping
doWork();
// character received on serial port? may be a connection attempt
if (Serial.available() > 0) {
// indicate connected status
digitalWrite(13, HIGH); // set the LED on
// start the OPDI protocol, passing a pointer to the housekeeping function
// this call blocks until the slave is disconnected
uint8_t result = Opdi->start(&doWork);
// no regular disconnect?
if (result != OPDI_DISCONNECTED) {
digitalWrite(13, LOW); // set the LED off
delay(500);
// flash error code on LED
for (uint8_t i = 0; i < result; i++) {
digitalWrite(13, HIGH); // set the LED on
delay(200); // wait
digitalWrite(13, LOW); // set the LED off
delay(200); // wait
}
}
digitalWrite(13, LOW); // set the LED off
}
}
示例9: QObject
HtmlParser::HtmlParser(const QUrl &url, const QString &text, QObject *parent)
:
QObject(parent),
_info(new UrlInfo, [](UrlInfo* p){delete p;}),
_downloaded(false),
_text(text),
_downloader(nullptr)
{
_info->_url = url.toString();
_info->_found = false;
_info->_status = UrlInfo::DOWNLOADING;
_info->_percentage = 0;
emit processing(_info.data());
QThread * thread = new QThread();
_downloader = new HtmlDownloader(url);
_downloader->moveToThread(thread);
connect( thread, SIGNAL(started()), _downloader, SLOT(doWork()));
connect( _downloader, SIGNAL(finished(QString)), thread, SLOT(quit()));
connect( _downloader, SIGNAL(finished(QString)), this, SLOT(downloaded(QString)), Qt::ConnectionType::DirectConnection);
connect(_downloader, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
connect( thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
示例10: doWork
void Worker::onGoFromService (InputParametersRS input)
{
try {
doWork( input);
} catch ( Interrupt & ) {
// std::cerr << "*** Worker interrupted ***\n";
dbg(1) << "RS interrupted\n";
emit interrupt ();
} catch ( std::runtime_error & e) {
std::cerr << "Worker runtime-exception: " << e.what() << "\n";
emit error( QString("runtime-exception: %1").arg(e.what()));
} catch ( std::exception & e) {
std::cerr << "Worker std-exception: " << e.what() << "\n";
emit error( QString("std-exception: %1").arg(e.what()));
} catch ( std::string & s) {
std::cerr << "Worker exception: " << s << "\n";
emit error( QString("exception: %1").arg(s.c_str()));
} catch ( QString & s) {
std::cerr << "Worker exception: " << s << "\n";
emit error( QString("exception: %1").arg(s));
} catch ( char * s) {
std::cerr << "Worker exception: " << s << "\n";
emit error( QString("exception: %1").arg(s));
} catch (...) {
std::cerr << "Worker uncaught exception...\n";
dbg(1) << "Worker uncaught exception\n";
emit error ( "Uncaught exception");
// throw;
}
}
示例11: doWork
void OscListenerWorker::Start()
{
if (!running) {
running = true;
doWork();
}
}
示例12: createProc
void createProc(int number, pid_t* pid_array){
int i = 0;
pid_t pid;
int *array;
//Preparing random order squence
array = (int*)malloc(sizeof(int)*number);
for(i = 0; i < number; ++i)
array[i] = i;
shuffle(array, number);
unlockSem(0); //aby mohol prvy bezat
for(i = 0; i < number; ++i){
switch(pid = fork()){
case 0:
doWork(array[i], getNext(array, i + 1, number));
exit(EXIT_SUCCESS);
case -1:
perror("fork");
exit(EXIT_FAILURE);
default:
pid_array[i] = pid;
break;
}
}
free(array);
}
示例13: if
void QuebrarSenha::quebrarSenhaZIP()
{
QString text = ui->lineEdit->text();
QThread *workerThread;
CountWorker *worker;
int i;
//Esta é a parte mais importante do programa;
//Está sendo criado 4 threads, onde cada thread é responsável por executar uma porção das senhas em paralelo
//As senhas variam de 0 a 500000
for(i = 0; i < 4; i++){
workerThread = new QThread;
QLabel *label;
if(i==0) label=ui->thread0;
else if(i==1) label=ui->thread1;
else if(i==2) label=ui->thread2;
else if(i==3) label=ui->thread3;
worker = new CountWorker(i*125000, (i+1)*125000, text, label);
worker->moveToThread(workerThread);
connect(workerThread, SIGNAL(started()), worker, SLOT(doWork()));
connect(worker, SIGNAL(finished()), workerThread, SLOT(quit()));
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
connect(worker, SIGNAL(updateCount(int, QLabel*)), this, SLOT(updateCount(int, QLabel*)));
connect(worker, SIGNAL(updateSenha(int)), this, SLOT(updateSenha(int)));
connect(worker, SIGNAL(updateProgressBar(float)), this, SLOT(updateProgressBar(float)));
workerThread->start();
}
}
示例14: main
//========
// main()
//========
int main(int argc, char** argv) {
bool isok = false;
try {
Input input(argc, argv);
doWork(input);
isok = true;
} catch(const Help& h) {
std::cout << prognm << std::endl;
std::cout << " citation: " + citation << std::endl;
std::cout << " version: " + version << std::endl;
std::cout << " authors: " + authors << std::endl;
std::cout << usage() << std::endl;
isok = true;
} catch(const Version& v) {
std::cout << prognm << std::endl;
std::cout << " citation: " + citation << std::endl;
std::cout << " version: " + version << std::endl;
std::cout << " authors: " + authors << std::endl;
isok = true;
} catch(std::string& msg) {
std::cerr << prognm << std::endl;
std::cerr << " citation: " + citation << std::endl;
std::cerr << " version: " + version << std::endl;
std::cerr << " authors: " + authors << std::endl;
std::cerr << usage() << std::endl;
std::cerr << msg << std::endl;
} catch(std::exception& e) {
std::cerr << usage() << std::endl;
std::cerr << e.what() << std::endl;
} catch(...) {
std::cerr << usage() << std::endl;
std::cerr << "Unknown Error. Aborting" << std::endl;
}
return(isok ? EXIT_SUCCESS : EXIT_FAILURE);
}
示例15: doWork
void Compute::receiveB(int indexX, float *data, int size) {
for(int j=0; j<subBlockDimYx; j++)
for(int k=0; k<blockDimZ; k++)
B[indexX*subBlockDimYx*blockDimZ + j*blockDimZ + k] = data[j*blockDimZ + k];
countB++;
if(countA == num_chare_z-1 && countB == num_chare_x-1)
doWork();
}