3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
23 Abstract: The main xapp class.
24 This class actually extends the messenger class as most of what
25 would be done here is just passing through to the messenger.
28 Author: E. Scott Daniels
35 #include <rmr/RIC_message_types.h>
41 #include <messenger.hpp>
44 // --------------- private -----------------------------------------------------
48 // --------------- builders -----------------------------------------------
51 If wait4table is true, then the construction of the object does not
52 complete until the underlying transport has a new copy of the route
55 If port is nil, then the default port is used (4560).
57 Xapp::Xapp( const char* port, bool wait4table ) : Messenger( port, wait4table ) {
58 // nothing to do; all handled in Messenger constructor
65 // nothing to destroy; superclass destruction is magically invoked.
69 Start n threads, each running a listener which will drive callbacks.
71 The final listener is started in the main thread; in otherwords this
72 function won't return unless that listener crashes.
74 void Xapp::Run( int nthreads ) {
76 std::thread** tinfo; // each thread we'll start
78 tinfo = new std::thread* [nthreads-1];
80 for( i = 0; i < nthreads - 1; i++ ) { // thread for each n-1; last runs here
81 tinfo[i] = new std::thread( &Xapp::Listen, this );
84 this->Listen(); // will return only when halted
86 for( i = 0; i < nthreads - 1; i++ ) { // wait for others to stop
94 Halt the xapp. This will drive the messenger's stop function to prevent any
95 active listeners from running, and will shut things down.
98 this->Stop(); // messenger shut off