Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Oneway_Send_Timeouts / Server_Task.h
blob2fa8cd818a3a3e96eeb414ab8128c95bfd4fc328
1 #ifndef _SERVER_TASK_
2 #define _SERVER_TASK_
4 #include "Server.h"
6 #include "ace/ARGV.h"
7 #include "ace/Task.h"
9 #include <string>
11 class Server_Task : public ACE_Task_Base
13 public:
14 Server_Task (const std::string& args)
15 : args_ (args)
17 ~Server_Task () { this->force_shutdown (); }
19 virtual int svc ()
21 bool initializer = false;
23 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
24 if (!server_)
26 ACE_ARGV my_args (args_.c_str ());
28 // Initialize Server ORB in new thread
30 #ifdef ACE_HAS_CPP14
31 server_ = std::make_unique<Server> (my_args.argc (), my_args.argv ());
32 #else
33 server_.reset (new Server(my_args.argc (), my_args.argv ()));
34 #endif
36 ACE_ASSERT (server_);
37 initializer = true;
41 if (initializer)
43 server_->run (false);
44 this->force_shutdown (); // servant thread is responsible for shutdown
46 else
48 server_->run (true);
51 return 0;
54 bool ready ()
56 if (server_)
58 return server_->init_;
61 return false;
64 void force_shutdown ()
66 if (server_)
68 server_->shutdown ();
72 private:
73 std::string args_;
74 std::unique_ptr<Server> server_;
75 TAO_SYNCH_MUTEX mutex_;
78 #endif //_SERVER_TASK_