本文整理汇总了C++中Task::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ Task::activate方法的具体用法?C++ Task::activate怎么用?C++ Task::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::activate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseReleaseEvent
void Menu::mouseReleaseEvent(QMouseEvent *event)
{
QAction *action = actionAt(event->pos());
if (action && action->data().type() == QVariant::ULongLong)
{
TaskManager::TaskPtr taskPointer = TaskManager::TaskManager::self()->findTask(action->data().toULongLong());
if (taskPointer)
{
TaskManager::GroupManager *groupManager = new TaskManager::GroupManager(this);
Task *task = new Task(new TaskManager::TaskItem(groupManager, taskPointer), groupManager);
if (event->button() == Qt::LeftButton)
{
task->activate();
}
else if (event->button() == Qt::MidButton)
{
task->close();
}
delete task;
delete groupManager;
}
}
KMenu::mouseReleaseEvent(event);
}
示例2: task
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("RMCast_Retransmission_Test"));
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("This is ACE Version %u.%u.%u\n\n"),
ACE::major_version(),
ACE::minor_version(),
ACE::beta_version()));
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Running single threaded test\n")));
//! Run the test in single threaded mode
Tester tester;
tester.run (100);
tester.validate_message_count ();
}
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Running multi threaded test\n")));
//! Run the test in multi-threaded mode
Tester tester;
Task task (&tester);
if (task.activate (THR_NEW_LWP|THR_JOINABLE, 4) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Cannot activate the threads\n")),
1);
ACE_Thread_Manager::instance ()->wait ();
tester.validate_message_count ();
}
ACE_END_TEST;
return 0;
}
示例3: attributes
void
run_test (PortableServer::POA_ptr poa,
int use_callbacks)
{
TAO_EC_Event_Channel_Attributes attributes (poa, poa);
attributes.disconnect_callbacks = use_callbacks;
TAO_EC_Event_Channel ec_impl (attributes);
ec_impl.activate ();
RtecEventChannelAdmin::EventChannel_var event_channel =
ec_impl._this ();
Task task (event_channel.in (), use_callbacks);
if (task.activate (THR_BOUND|THR_NEW_LWP, 1) != 0)
{
ACE_ERROR ((LM_ERROR, "Cannot activate the tasks\n"));
}
// Wait for all the threads to complete and the return
ACE_Thread_Manager::instance ()->wait ();
event_channel->destroy ();
deactivate_servant (&ec_impl);
}
示例4: task
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
int result =
parse_args (argc, argv);
if (result != 0)
return result;
// Thread Manager for managing task.
ACE_Thread_Manager thread_manager;
// Create task.
Task task (thread_manager,
orb.in ());
// Task activation flags.
long flags =
THR_NEW_LWP |
THR_JOINABLE |
orb->orb_core ()->orb_params ()->thread_creation_flags ();
// Activate task.
result =
task.activate (flags);
if (result == -1)
{
if (errno == EPERM)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot create thread with scheduling policy %s\n"
"because the user does not have the appropriate privileges, terminating program....\n"
"Check svc.conf options and/or run as root\n",
sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
2);
}
else
// Unexpected error.
ACE_ASSERT (0);
}
// Wait for task to exit.
result =
thread_manager.wait ();
ACE_ASSERT (result != -1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught");
return -1;
}
return 0;
}
示例5: release
int Resource::release(Arrival* arrival, int amount) {
remove_from_server(sim->verbose, sim->now(), arrival, amount);
arrival->unregister_entity(this);
// serve another
Task* task = new Task(sim, "Post-Release",
boost::bind(&Resource::post_release, this),
PRIORITY_RELEASE_POST);
task->activate();
return SUCCESS;
}
示例6: task
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc,
argv);
int result =
parse_args (argc, argv);
if (result != 0)
return result;
// Make sure we can support multiple priorities that are required
// for this test.
check_supported_priorities (orb.in ());
// Thread Manager for managing task.
ACE_Thread_Manager thread_manager;
// Create task.
Task task (thread_manager,
orb.in ());
// Task activation flags.
long flags =
THR_NEW_LWP |
THR_JOINABLE |
orb->orb_core ()->orb_params ()->thread_creation_flags ();
// Activate task.
result =
task.activate (flags);
ACE_ASSERT (result != -1);
ACE_UNUSED_ARG (result);
// Wait for task to exit.
result =
thread_manager.wait ();
ACE_ASSERT (result != -1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return -1;
}
return 0;
}
示例7: task
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int result = 0;
try
{
// Standard initialization:
// parse arguments and get all the references (ORB,
// RootPOA, RTORB, RTCurrent, POAManager).
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return -1;
// Make sure we can support multiple priorities that are required
// for this test.
if (!check_supported_priorities (orb.in ()))
return 2;
// Thread Manager for managing task.
ACE_Thread_Manager thread_manager;
// Create task.
Task task (thread_manager,
orb.in ());
// Task activation flags.
long flags =
THR_NEW_LWP |
THR_JOINABLE |
orb->orb_core ()->orb_params ()->thread_creation_flags ();
// Activate task.
result =
task.activate (flags);
if (result == -1)
{
if (errno == EPERM)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot create thread with scheduling policy %s\n"
"because the user does not have the appropriate privileges, terminating program....\n"
"Check svc.conf options and/or run as root\n",
sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
2);
}
else
// Unexpected error.
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Cannot create thread. errno = %d\n",
ACE_ERRNO_GET),
-1);
}
// Wait for task to exit.
result =
thread_manager.wait ();
}
catch (const ::CORBA::Exception & ex)
{
ex._tao_print_exception(
"Exception caught:");
return -1;
}
return result;
}
示例8: servant_locator
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int retval = 0;
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var obj =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (obj.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
CORBA::PolicyList policies;
CORBA::ULong current_length = 0;
policies.length (current_length + 1);
policies[current_length++] =
root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);
policies.length (current_length + 1);
policies[current_length++] =
root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN);
policies.length (current_length + 1);
policies[current_length++] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
PortableServer::POA_var child_poa =
root_poa->create_POA ("child",
poa_manager.in (),
policies);
if (!set_nil_servant_manager (child_poa.in()))
retval = -1;
Servant_Locator servant_locator (child_poa.in ());
child_poa->set_servant_manager (&servant_locator);
if (!overwrite_servant_manager (child_poa.in()))
retval = -1;
PortableServer::ObjectId_var first_oid =
PortableServer::string_to_ObjectId ("first");
CORBA::Object_var first_object =
child_poa->create_reference_with_id (first_oid.in (),
"IDL:test:1.0");
test_var first_test =
test::_narrow (first_object.in ());
PortableServer::ObjectId_var second_oid =
PortableServer::string_to_ObjectId ("second");
CORBA::Object_var second_object =
child_poa->create_reference_with_id (second_oid.in (),
"IDL:test:1.0");
test_var second_test =
test::_narrow (second_object.in ());
first_task.object (first_test.in ());
second_task.object (second_test.in ());
first_task.activate ();
second_task.activate ();
first_task.wait ();
second_task.wait ();
root_poa->destroy (1,
1);
orb->destroy ();
ACE_DEBUG ((LM_DEBUG,
"%s successful\n",
argv[0]));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught");
retval = -1;
}
return retval;
}
示例9: task
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB, resolve references and parse arguments.
// ORB.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// Parse arguments.
if (parse_args (argc, argv) != 0)
return -1;
// Make sure we can support multiple priorities that are required
// for this test.
if (!check_supported_priorities (orb.in ()))
return 2;
// Thread Manager for managing task.
ACE_Thread_Manager thread_manager;
// Create task.
Task task (thread_manager,
orb.in ());
// Task activation flags.
long flags =
THR_NEW_LWP |
THR_JOINABLE |
orb->orb_core ()->orb_params ()->thread_creation_flags ();
// Activate task.
int result =
task.activate (flags);
if (result == -1)
{
if (errno == EPERM)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot create thread with scheduling policy %s\n"
"because the user does not have the appropriate privileges, terminating program....\n"
"Check svc.conf options and/or run as root\n",
sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
2);
}
else
// Unexpected error.
ACE_ASSERT (0);
}
// Wait for task to exit.
result =
thread_manager.wait ();
ACE_ASSERT (result != -1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
"Unexpected exception in MT_Client_Protocol_Priority test client:");
return -1;
}
return 0;
}
示例10: task
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
Task task (orb.in ());
int result =
task.activate ();
ACE_ASSERT (result != -1);
ACE_UNUSED_ARG (result);
CORBA::PolicyList policies (1);
policies.length (1);
policies[0] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
PortableServer::POA_var child_poa =
root_poa->create_POA ("child_poa",
poa_manager.in (),
policies);
test_i *base_servant =
new test_i (orb.in (),
child_poa.in ());
PortableServer::ServantBase_var safe_base_servant (base_servant);
PortableServer::ObjectId_var base_oid =
PortableServer::string_to_ObjectId ("base");
child_poa->activate_object_with_id (base_oid.in (),
base_servant);
PortableServer::ObjectId_var id_act =
root_poa->activate_object (base_servant);
CORBA::Object_var object_act = root_poa->id_to_reference (id_act.in ());
test_var base_test =
test::_narrow (object_act.in ());
test_i *first_servant =
new test_i (orb.in (),
child_poa.in ());
PortableServer::ServantBase_var safe_first_servant (first_servant);
PortableServer::ObjectId_var first_oid =
PortableServer::string_to_ObjectId ("first");
child_poa->activate_object_with_id (first_oid.in (),
first_servant);
PortableServer::ObjectId_var id_actu =
root_poa->activate_object (first_servant);
object_act = root_poa->id_to_reference (id_actu.in ());
test_var first_test =
test::_narrow (object_act.in ());
base_servant->set_other (first_test.in ());
base_test->method ();
PortableServer::ObjectId_var second_oid =
PortableServer::string_to_ObjectId ("second");
object =
child_poa->create_reference_with_id (second_oid.in (),
"IDL:test:1.0");
test_var second_test =
test::_narrow (object.in ());
test_i *second_servant =
new test_i (orb.in (),
child_poa.in ());
PortableServer::ServantBase_var safe_second_servant (second_servant);
child_poa->activate_object_with_id (second_oid.in (),
second_servant);
//.........这里部分代码省略.........
示例11: task
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
int result =
parse_args (argc, argv);
if (result != 0)
return result;
// Make sure we can support multiple priorities that are required
// for this test.
if (!check_supported_priorities (orb.in ()))
return 2;
// The following finds out the lowest priority for this
// scheduling policy. This will give us the biggest range on NT
// since the default priority is 0 where as the lowest priority
// is -15.
int minimum_priority =
ACE_Sched_Params::priority_min (orb->orb_core ()->orb_params ()->ace_sched_policy ());
// Thread Manager for managing task.
ACE_Thread_Manager thread_manager;
// Create task.
Task task (thread_manager,
orb.in ());
// Task activation flags.
long flags =
THR_NEW_LWP |
THR_JOINABLE |
orb->orb_core ()->orb_params ()->thread_creation_flags ();
// Activate task.
result =
task.activate (flags,
1, 0,
minimum_priority);
if (result == -1)
{
if (errno == EPERM)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot create thread with scheduling policy %C\n"
"because the user does not have the appropriate privileges, terminating program....\n"
"Check svc.conf options and/or run as root\n",
sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
2);
}
else
// Unexpected error.
ACE_ASSERT (0);
}
// Wait for task to exit.
result =
thread_manager.wait ();
ACE_ASSERT (result != -1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Unexpected exception!");
return -1;
}
return 0;
}