// ============================================================================ // main // ============================================================================ int main(int argc, char* argv[]) { yat::Message * m = 0; YAT_LOG_STATIC("Instanciating Task..."); Consumer * dt = new Consumer(kLO_WATER_MARK, kHI_WATER_MARK); YAT_LOG_STATIC("Starting Task..."); try { dt->go(2000); } catch (const yat::Exception&) { YAT_LOG_STATIC("yat exception caught - could not start task. aborting..."); dt->exit(); return 0; } catch (...) { YAT_LOG_STATIC("unknown exception caught - could not start task. aborting..."); dt->exit(); return 0; } /* for (size_t i = 0; i < kNUM_MSGS; i++) { try { //- post msg to consumer dt->post(new yat::Message(kDUMMY_MSG), kPOST_MSG_TMO); //- simulate some time consuming activity yat::ThreadingUtilities::sleep(0, 100000); } catch (const std::bad_alloc&) { YAT_LOG_STATIC("std::bad_alloc except. caught - could not post msg#" << i); } catch (const yat::Exception&) { YAT_LOG_STATIC("tango except. caught - could not post msg#" << i); } catch (...) { YAT_LOG_STATIC("unknown except. caught - could not post msg#" << i); } } */ yat::Buffer<double> data(kNUM_MSGS); for ( size_t i = 0; i < kNUM_MSGS; i++ ) data[i] = 1. * i; data.force_length(kNUM_MSGS); for (size_t i = 0; i < kNUM_MSGS; i++) { try { SharedBuffer* sb = new SharedBuffer(); sb->capacity(i + 1); sb->memcpy(data.base(), i + 1); std::cout << "SharedBuffer* sb.length = " << sb->length() << std::endl; dt->post(kDATA_MSG, sb->duplicate(), false); sb->release(); //- simulate some time consuming activity yat::ThreadingUtilities::sleep(0, 100000); } catch (const std::bad_alloc&) { YAT_LOG_STATIC("std::bad_alloc except. caught - could not post msg#" << i); } catch (const yat::Exception&) { YAT_LOG_STATIC("tango except. caught - could not post msg#" << i); } catch (...) { YAT_LOG_STATIC("unknown except. caught - could not post msg#" << i); } } try { dt->exit(); } catch (const yat::Exception&) { YAT_LOG_STATIC("tango except. caught - could stop task. aborting..."); } catch (...) { YAT_LOG_STATIC("unknown except. caught - could stop task. aborting..."); return 0; } return 0; }