本文整理汇总了C++中TaskManager类的典型用法代码示例。如果您正苦于以下问题:C++ TaskManager类的具体用法?C++ TaskManager怎么用?C++ TaskManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TaskManager
void TestTaskManager::fail_registerMachine_command_not_found()
{
TaskManager *manager = new TaskManager();
QSignalSpy sig_reg(manager,
SIGNAL(registerMachineStatus(TaskStatus, QString)));
QVariantList response;
TaskStatus status;
QString reason;
// Fail to register with a non-existent tarsnap dir.
manager->registerMachine("fake-user", "fake-password", "fake-machine",
"fake.key", "/fake/dir",
"/tmp/gui-test-tarsnap-cache");
QTest::qWait(TASK_CMDLINE_WAIT_MS);
// Get failure message.
QVERIFY(sig_reg.count() == 1);
response = sig_reg.takeFirst();
status = response.at(0).value<TaskStatus>();
reason = response.at(1).toString();
QVERIFY(status == TaskStatus::Failed);
QVERIFY(reason == "Could not find the command-line program");
delete manager;
}
示例2: lock
void ZoneServerImplementation::printInfo() {
lock();
TaskManager* taskMgr = Core::getTaskManager();
StringBuffer msg;
if (taskMgr != NULL)
msg << taskMgr->getInfo(false) << endl;
//msg << "MessageQueue - size = " << processor->getMessageQueue()->size() << endl;
float packetloss;
if (totalSentPackets + totalSentPackets == 0)
packetloss = 0.0f;
else
packetloss = (100 * totalResentPackets) / (totalResentPackets + totalSentPackets);
#ifndef WITH_STM
msg << "sent packets = " << totalSentPackets << ", resent packets = "
<< totalResentPackets << " [" << packetloss << "%]" << endl;
#endif
msg << dec << currentPlayers << " users connected (" << maximumPlayers << " max, " << totalPlayers << " total, "
<< totalDeletedPlayers << " deleted)" << endl;
#ifndef WITH_STM
msg << ObjectManager::instance()->getInfo() << endl;
if (playerManager != NULL)
msg << dec << playerManager->getOnlineZoneClientMap()->getDistinctIps() << " total distinct ips connected";
#endif
unlock();
info(msg.toString(), true);
}
示例3: assert
void TaskManagerTest::testError()
{
TaskManager tm;
TaskObserver to;
tm.addObserver(Observer<TaskObserver, TaskStartedNotification>(to, &TaskObserver::taskStarted));
tm.addObserver(Observer<TaskObserver, TaskCancelledNotification>(to, &TaskObserver::taskCancelled));
tm.addObserver(Observer<TaskObserver, TaskFailedNotification>(to, &TaskObserver::taskFailed));
tm.addObserver(Observer<TaskObserver, TaskFinishedNotification>(to, &TaskObserver::taskFinished));
tm.addObserver(Observer<TaskObserver, TaskProgressNotification>(to, &TaskObserver::taskProgress));
AutoPtr<TestTask> pTT = new TestTask;
tm.start(pTT.duplicate());
assert (pTT->progress() == 0);
Thread::sleep(200);
pTT->cont();
while (pTT->progress() != 0.5) Thread::sleep(50);
assert (to.progress() == 0.5);
assert (to.started());
assert (pTT->state() == Task::TASK_RUNNING);
TaskManager::TaskList list = tm.taskList();
assert (list.size() == 1);
assert (tm.count() == 1);
pTT->fail();
pTT->cont();
while (pTT->state() != Task::TASK_FINISHED) Thread::sleep(50);
assert (pTT->state() == Task::TASK_FINISHED);
assert (to.finished());
assert (to.error() != 0);
while (tm.count() == 1) Thread::sleep(50);
list = tm.taskList();
assert (list.empty());
}
示例4: validate
void validate(const TaskManager& tasks, const ItemManager& items, std::ostream& os){
auto taskEnd = tasks.cend();
auto itemEnd = items.cend();
const int EQUAL = 0;
bool isAvailable;
// enumerate all tiems
for (auto item = items.cbegin(); item != itemEnd; ++item) {
isAvailable = false;
// enumerate all tasks, compare each task with item destination
for (auto singleTask = tasks.cbegin(); singleTask != taskEnd; ++singleTask) {
if((item->getDestination()).compare(singleTask->getName()) == EQUAL){
isAvailable = true;
break;
}
}
if (isAvailable == false) {
os << item->getDestination() << " is unavailable\n";
}
}
}
示例5: workerLoop
/// Worker Worker routine.
/// This is the routine every worker thread runs.
/// The worker thread continuously asks for Tasks and executes them.
///
/// Note that worker threads are NOT guarenteed to ever call Worker.exit()
/// before the program ends.
void workerLoop ( Worker * me, void* args ) {
task_worker_args* wargs = (task_worker_args*) args;
TaskManager* tasks = wargs->tasks;
TaskingScheduler * sched = wargs->scheduler;
sched->onWorkerStart();
StateTimer::setThreadState( StateTimer::FINDWORK );
StateTimer::enterState_findwork();
Task nextTask;
while ( true ) {
// block until receive work or termination reached
if (!tasks->getWork(&nextTask)) break; // quitting time
sched->num_active_tasks++;
StateTimer::setThreadState( StateTimer::USER );
StateTimer::enterState_user();
{
GRAPPA_PROFILE( exectimer, "user_execution", "", GRAPPA_USER_GROUP );
nextTask.execute();
}
StateTimer::setThreadState( StateTimer::FINDWORK );
sched->num_active_tasks--;
sched->thread_yield( ); // yield to the scheduler
}
}
示例6: main
int main()
{
CanStorage c_list;
MoneyKeeper mk;
ioHandler ioh;
TaskManager tm;
// load from file.
ioh.loadCanStorage("canlist.txt", c_list);
while (1)
{
int menu = ioh.getMenu();
if (menu == EXIT) break; // 프로그램 종료
switch (menu)
{
case COIN_DEPOSIT:
// 동전투입
tm.insertCoin(mk);
break;
case ITEM_SELECTION:
// 상품선택
tm.selectMenu(mk, c_list);
break;
case CHANGE_RETURN:
// 잔돈반환
tm.returnCoin(mk);
break;
case EXIT:
// 프로그램 종료
return 0;
}
}
}
示例7: test_task_fai
bool test_task_fai(TaskManager& task_manager,
const Waypoints &waypoints)
{
task_manager.set_factory(TaskBehaviour::FACTORY_FAI_GENERAL);
AbstractTaskFactory &fact = task_manager.get_factory();
const Waypoint *wp;
task_report(task_manager, "# adding start\n");
wp = waypoints.lookup_id(1);
if (wp) {
OrderedTaskPoint *tp = fact.createStart(*wp);
if (!fact.append(*tp)) {
return false;
}
delete tp;
}
task_manager.setActiveTaskPoint(0);
task_manager.resume();
task_report(task_manager, "# adding intermdiate\n");
wp = waypoints.lookup_id(2);
if (wp) {
OrderedTaskPoint *tp = fact.createIntermediate(*wp);
if (!fact.append(*tp, false)) {
return false;
}
delete tp;
}
task_report(task_manager, "# adding intermdiate\n");
wp = waypoints.lookup_id(3);
if (wp) {
OrderedTaskPoint *tp = fact.createIntermediate(*wp);
if (!fact.append(*tp,false)) {
return false;
}
delete tp;
}
task_report(task_manager, "# adding finish\n");
wp = waypoints.lookup_id(1);
if (wp) {
OrderedTaskPoint *tp = fact.createFinish(*wp);
if (!fact.append(*tp,false)) {
return false;
}
delete tp;
}
task_report(task_manager, "# checking task\n");
if (!fact.validate()) {
return false;
}
if (!task_manager.check_ordered_task()) {
return false;
}
return true;
}
示例8: max
void
ChartProjection::Set(const PixelRect &rc, const TaskManager &task,
const GeoPoint &fallback_loc)
{
const GeoPoint center = task.GetTaskCenter(fallback_loc);
const fixed radius = max(fixed(10000), task.GetTaskRadius(fallback_loc));
set_projection(rc, center, radius);
}
示例9: test_task_or
bool test_task_or(TaskManager& task_manager,
const Waypoints &waypoints)
{
const Waypoint *wp;
task_manager.SetFactory(TaskFactoryType::FAI_OR);
AbstractTaskFactory &fact = task_manager.GetFactory();
task_report(task_manager, "# adding start\n");
wp = waypoints.LookupId(1);
if (wp) {
OrderedTaskPoint *tp = fact.CreateStart(*wp);
if (!fact.Append(*tp)) {
return false;
}
delete tp;
}
task_manager.SetActiveTaskPoint(0);
task_manager.Resume();
task_report(task_manager, "# adding intermediate\n");
wp = waypoints.LookupId(2);
if (wp) {
OrderedTaskPoint *tp = fact.CreateIntermediate(*wp);
if (!fact.Append(*tp)) {
return false;
}
delete tp;
}
task_report(task_manager, "# adding finish\n");
wp = waypoints.LookupId(1);
if (wp) {
OrderedTaskPoint *tp = fact.CreateFinish(*wp);
if (!fact.Append(*tp)) {
return false;
}
delete tp;
}
fact.UpdateStatsGeometry();
task_report(task_manager, "# checking task..\n");
if (!fact.Validate()) {
return false;
}
if (!task_manager.CheckOrderedTask()) {
return false;
}
return true;
}
示例10: main
int main(const ArgVec& args)
{
if (!_helpRequested)
{
TaskManager tm;
tm.start(new SampleTask);
waitForTerminationRequest();
tm.cancelAll();
tm.joinAll();
}
return Application::EXIT_OK;
}
示例11: CreateDefaultTask
static void
CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points)
{
const TCHAR start_name[] = _T("Bergneustadt");
task_manager.set_factory(OrderedTask::FACTORY_MIXED);
AbstractTaskFactory &factory = task_manager.get_factory();
const Waypoint *wp;
OrderedTaskPoint *tp;
wp = way_points.lookup_name(start_name);
if (wp != NULL) {
tp = factory.createStart(AbstractTaskFactory::START_LINE, *wp);
if (!factory.append(tp, false)) {
fprintf(stderr, "Failed to create start point\n");
}
} else {
fprintf(stderr, "No start waypoint\n");
}
wp = way_points.lookup_name(_T("Uslar"));
if (wp != NULL) {
tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp);
if (!factory.append(tp, false)) {
fprintf(stderr, "Failed to create turn point\n");
}
} else {
fprintf(stderr, "No turn point\n");
}
wp = way_points.lookup_name(_T("Suhl Goldlaut"));
if (wp != NULL) {
tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp);
if (!factory.append(tp, false)) {
fprintf(stderr, "Failed to create turn point\n");
}
} else {
fprintf(stderr, "No turn point\n");
}
wp = way_points.lookup_name(start_name);
if (wp != NULL) {
tp = factory.createFinish(AbstractTaskFactory::FINISH_LINE, *wp);
if (!factory.append(tp, false)) {
fprintf(stderr, "Failed to create finish point\n");
}
} else {
fprintf(stderr, "No finish waypoint\n");
}
}
示例12:
AirspaceWarningManager::AirspaceWarningManager(const Airspaces& airspaces,
const AIRCRAFT_STATE &state,
const TaskManager &task_manager,
const fixed& prediction_time_glide,
const fixed& prediction_time_filter):
m_airspaces(airspaces),
m_prediction_time_glide(prediction_time_glide),
m_prediction_time_filter(prediction_time_filter),
m_perf_glide(task_manager.get_glide_polar()),
m_state_filter(state, prediction_time_filter),
m_perf_filter(m_state_filter),
m_task(task_manager),
m_glide_polar(task_manager.get_glide_polar())
{
}
示例13: new
// _RequestThread
int32
AuthenticationServer::_RequestThread()
{
TaskManager taskManager;
while (!fTerminating) {
taskManager.RemoveDoneTasks();
// read the request
KMessage request;
status_t error = request.ReceiveFrom(fRequestPort);
if (error != B_OK)
continue;
// get the parameters
const char* context = NULL;
const char* server = NULL;
const char* share = NULL;
bool badPassword = true;
request.FindString("context", &context);
request.FindString("server", &server);
request.FindString("share", &share);
request.FindBool("badPassword", &badPassword);
if (!context || !server || !share)
continue;
String foundUser;
String foundPassword;
if (!badPassword && _GetAuthentication(context, server, share,
&foundUser, &foundPassword)) {
_SendRequestReply(request.ReplyPort(), request.ReplyToken(),
error, false, foundUser.GetString(), foundPassword.GetString());
} else {
// we need to ask the user: create a task that does it
UserDialogTask* task = new(nothrow) UserDialogTask(this, context,
server, share, badPassword, request.ReplyPort(),
request.ReplyToken());
if (!task) {
ERROR(("AuthenticationServer::_RequestThread(): ERROR: "
"failed to allocate "));
continue;
}
status_t error = taskManager.RunTask(task);
if (error != B_OK) {
ERROR(("AuthenticationServer::_RequestThread(): Failed to "
"start server info task: %s\n", strerror(error)));
continue;
}
}
}
return 0;
}
示例14: TaskManager
TaskManager& TaskManager::instance()
{
Kernel::Singleton* s = Kernel::Framework::instance().getSingleton("TaskManager");
if (s == nullptr)
{
TaskManager *f = new TaskManager("TaskManager");
Kernel::Framework::instance().registerSingleton("TaskManager",f);
return *f;
}
else
{
TaskManager *f = static_cast<TaskManager*>(s);
f->registerDelayed();
return *f;
}
}
示例15: RenderSpeed
void
RenderSpeed(Canvas &canvas, const PixelRect rc,
const ChartLook &chart_look,
const FlightStatistics &fs,
const NMEAInfo &nmea_info,
const DerivedInfo &derived_info,
const TaskManager &task)
{
ChartRenderer chart(chart_look, canvas, rc);
if (!fs.task_speed.HasResult() || !task.CheckOrderedTask()) {
chart.DrawNoData();
return;
}
chart.ScaleXFromData(fs.task_speed);
chart.ScaleYFromData(fs.task_speed);
chart.ScaleYFromValue(0);
chart.ScaleXFromValue(fs.task_speed.GetMinX());
DrawLegs(chart, task, nmea_info, derived_info, true);
chart.DrawXGrid(0.5,
ChartLook::STYLE_THINDASHPAPER, 0.5, true);
chart.DrawYGrid(Units::ToSysTaskSpeed(10),
ChartLook::STYLE_THINDASHPAPER, 10, true);
chart.DrawLineGraph(fs.task_speed, ChartLook::STYLE_MEDIUMBLACK);
chart.DrawTrend(fs.task_speed, ChartLook::STYLE_BLUETHIN);
chart.DrawXLabel(_T("t"), _T("hr"));
chart.DrawYLabel(_T("h"), Units::GetTaskSpeedName());
}