Commit 45d1f30d authored by legoc's avatar legoc

Replaced Boost by standard C++

parent 2f4d3338
......@@ -13,20 +13,19 @@ AC_LANG(C++)
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AX_BOOST_BASE([1.41],, [AC_MSG_ERROR([Boost 1.41 required])])
AX_CXX_COMPILE_STDCXX_11
AC_CAMEO
CT_CXXFLAGS="$BOOST_CPPFLAGS \
$ZMQ_CFLAGS \
CT_CXXFLAGS="$ZMQ_CFLAGS \
$PROTOBUF_CFLAGS \
$CAMEO_CFLAGS"
CT_LDFLAGS="$BOOST_LDFLAGS \
$ZMQ_LDFLAGS \
CT_LDFLAGS="$ZMQ_LDFLAGS \
$PROTOBUF_LDFLAGS \
$CAMEO_LDFLAGS"
CT_LIBS="$CAMEO_LIBS $BOOST_SYSTEM_LIB"
CT_LIBS="$CAMEO_LIBS"
AC_SUBST(CT_CXXFLAGS)
AC_SUBST(CT_LDFLAGS)
......
dnl
dnl AC_CXX_CLEAN_TEMPLATE_REPOSITORY
dnl
dnl Description
dnl
dnl Sometime failed C++ compiles can leave trash in the template repository.
dnl Just clean them all away.
dnl
dnl Copyright (C) 2003, Alex Tingle <alex.autoconf@firetree.net>
dnl
dnl License:
dnl GNU General Public License
dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING.html]
dnl with this special exception
dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING-Exception.html].
dnl
AC_DEFUN([AC_CXX_CLEAN_TEMPLATE_REPOSITORY],[
# Sometime failed C++ compiles can leave trash in the template repository.
# Just clean them all away.
rm -rf ./SunWS_cache # Solaris/CC
rm -rf ./.cxx_repository # Tru64/cxx
# ...add more here.
])
This diff is collapsed.
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_date_time.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_DATE_TIME
#
# DESCRIPTION
#
# Test for Date_Time library from the Boost C++ libraries. The macro
# requires a preceding call to AX_BOOST_BASE. Further documentation is
# available at <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_DATE_TIME_LIB)
#
# And sets:
#
# HAVE_BOOST_DATE_TIME
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2008 Michael Tindal
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 21
AC_DEFUN([AX_BOOST_DATE_TIME],
[
AC_ARG_WITH([boost-date-time],
AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
[use the Date_Time library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_date_time_lib=""
else
want_boost="yes"
ax_boost_user_date_time_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
ax_cv_boost_date_time,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
[[using namespace boost::gregorian; date d(2002,Jan,10);
return 0;
]])],
ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_date_time" = "xyes"; then
AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_date_time_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_date_time*.so* $BOOSTLIBDIR/libboost_date_time*.dylib* $BOOSTLIBDIR/libboost_date_time*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_date_time.*\)\.so.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
[link_date_time="no"])
done
if test "x$link_date_time" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_date_time*.dll* $BOOSTLIBDIR/boost_date_time*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_date_time.*\)\.dll.*$;\1;' -e 's;^\(boost_date_time.*\)\.a.*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
[link_date_time="no"])
done
fi
else
for ax_lib in $ax_boost_user_date_time_lib boost_date_time-$ax_boost_user_date_time_lib; do
AC_CHECK_LIB($ax_lib, main,
[BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
[link_date_time="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_date_time" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_SYSTEM
#
# DESCRIPTION
#
# Test for System library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_SYSTEM_LIB)
#
# And sets:
#
# HAVE_BOOST_SYSTEM
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2008 Michael Tindal
# Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 17
AC_DEFUN([AX_BOOST_SYSTEM],
[
AC_ARG_WITH([boost-system],
AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
[use the System library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-system=boost_system-gcc-mt ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_system_lib=""
else
want_boost="yes"
ax_boost_user_system_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_BUILD])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::System library is available,
ax_cv_boost_system,
[AC_LANG_PUSH([C++])
CXXFLAGS_SAVE=$CXXFLAGS
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
[[boost::system::system_category]])],
ax_cv_boost_system=yes, ax_cv_boost_system=no)
CXXFLAGS=$CXXFLAGS_SAVE
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_system" = "xyes"; then
AC_SUBST(BOOST_CPPFLAGS)
AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
if test "x$ax_boost_user_system_lib" = "x"; then
for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
if test "x$link_system" != "xyes"; then
for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
else
for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_system" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_THREAD
#
# DESCRIPTION
#
# Test for Thread library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_THREAD_LIB)
#
# And sets:
#
# HAVE_BOOST_THREAD
#
# LICENSE
#
# Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2009 Michael Tindal
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 27
AC_DEFUN([AX_BOOST_THREAD],
[
AC_ARG_WITH([boost-thread],
AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@],
[use the Thread library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-thread=boost_thread-gcc-mt ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_thread_lib=""
else
want_boost="yes"
ax_boost_user_thread_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_BUILD])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::Thread library is available,
ax_cv_boost_thread,
[AC_LANG_PUSH([C++])
CXXFLAGS_SAVE=$CXXFLAGS
if test "x$host_os" = "xsolaris" ; then
CXXFLAGS="-pthreads $CXXFLAGS"
elif test "x$host_os" = "xmingw32" ; then
CXXFLAGS="-mthreads $CXXFLAGS"
else
CXXFLAGS="-pthread $CXXFLAGS"
fi
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
[[boost::thread_group thrds;
return 0;]])],
ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
CXXFLAGS=$CXXFLAGS_SAVE
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_thread" = "xyes"; then
if test "x$host_os" = "xsolaris" ; then
BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
elif test "x$host_os" = "xmingw32" ; then
BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
else
BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
fi
AC_SUBST(BOOST_CPPFLAGS)
AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
case "x$host_os" in
*bsd* )
LDFLAGS="-pthread $LDFLAGS"
break;
;;
esac
if test "x$ax_boost_user_thread_lib" = "x"; then
for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
[link_thread="no"])
done
if test "x$link_thread" != "xyes"; then
for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
[link_thread="no"])
done
fi
else
for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
AC_CHECK_LIB($ax_lib, exit,
[BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
[link_thread="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_thread" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
else
case "x$host_os" in
*bsd* )
BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
break;
;;
esac
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
This diff is collapsed.
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 18
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
This diff is collapsed.
###############################################################################
# Version 18/05/2017
# Version 29/04/2019
# defines CAMEO_CFLAGS, CAMEO_LDFLAGS, CAMEO_LIBS
#
AC_DEFUN([AC_CAMEO],
......@@ -11,9 +11,6 @@ AC_DEFUN([AC_CAMEO],
AC_LIBZMQ
AC_LIBPROTOBUF_LITE
AX_BOOST_DATE_TIME
AX_BOOST_THREAD
AX_BOOST_SYSTEM
CAMEO_CFLAGS=
CAMEO_LIBS=
......@@ -47,7 +44,7 @@ AC_DEFUN([AC_CAMEO],
CXXFLAGS="$CXXFLAGS $CAMEO_CFLAGS"
# search for library
LIBS="$LIBS $CAMEO_LIBS $LIBZMQ_LDFLAGS $LIBPROTOBUF_LDFLAGS $BOOST_LDFLAGS $LIBZMQ_LIB $LIBPROTOBUF_LIB $BOOST_THREAD_LIB -lcameo"
LIBS="$LIBS $CAMEO_LIBS $LIBZMQ_LDFLAGS $LIBPROTOBUF_LDFLAGS $LIBZMQ_LIB $LIBPROTOBUF_LIB -lcameo"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[[]])],
......@@ -60,7 +57,7 @@ AC_DEFUN([AC_CAMEO],
HAVE_CAMEO=1
LIBS="$cameo_save_LIBS"
CAMEO_LDFLAGS="$LIBZMQ_LDFLAGS $LIBPROTOBUF_LDFLAGS $CAMEO_LIBS"
CAMEO_LIBS="-lcameo $LIBZMQ_LIB $LIBPROTOBUF_LIB $BOOST_THREAD_LIB"
CAMEO_LIBS="-lcameo $LIBZMQ_LIB $LIBPROTOBUF_LIB -pthread"
fi
if test $cameo_found = yes; then
......
......@@ -14,11 +14,12 @@
* limitations under the Licence.
*/
#include <cameo/cameo.h>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cameo/cameo.h>
#include <thread>
using namespace std;
using namespace cameo;
......@@ -32,10 +33,10 @@ void testFast(Server& server) {
int i = 0;
while (N == -1 || i < N) {
auto_ptr<application::Instance> result = server.start("fast");
unique_ptr<application::Instance> result = server.start("fast");
cout << "new application " << result->getNameId() << endl;
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
this_thread::sleep_for(chrono::milliseconds(10));
result->kill();
result->waitFor();
......@@ -51,10 +52,10 @@ void testFastAsync(Server& server) {
int i = 0;
while (N == -1 || i < N) {
auto_ptr<application::Instance> result = server.start("fast");
unique_ptr<application::Instance> result = server.start("fast");
cout << "new application " << result->getNameId() << endl;
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
this_thread::sleep_for(chrono::milliseconds(10));
// replace the result to test the Instance of kill
result->kill();
......@@ -72,7 +73,7 @@ void testFastRes(Server& server) {
int i = 0;
while (N == -1 || i < N) {
auto_ptr<application::Instance> res = server.start("fastres");
unique_ptr<application::Instance> res = server.start("fastres");
cout << "new application " << res->getNameId() << endl;
application::State state = res->waitFor();
......@@ -100,7 +101,7 @@ void testFastResPar1(Server& server) {
const int M = 10;
auto_ptr<application::Instance> res[M];
unique_ptr<application::Instance> res[M];
// start in parallel
for (int j = 0; j < M; j++) {
......@@ -146,11 +147,11 @@ void testFastConnect(Server& server) {
for (int j = 0; j < 10; j++) {
auto_ptr<application::Instance> result = server.start("fastpar");
unique_ptr<application::Instance> result = server.start("fastpar");
cout << "new application " << result->getNameId() << endl;
}
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
this_thread::sleep_for(chrono::milliseconds(10));
application::InstanceArray rs = server.connectAll("fastpar");
// testing copy/transfer
......@@ -172,7 +173,7 @@ void testNoApp(Server& server) {
int i = 0;
while (N == -1 || i < N) {
auto_ptr<application::Instance> result = server.start("noapp");
unique_ptr<application::Instance> result = server.start("noapp");
cout << "new application " << result->getNameId() << endl;
application::State state = result->waitFor();
......@@ -192,11 +193,11 @@ void testNoApp(Server& server, int time) {
int i = 0;
while (N == -1 || i < N) {
auto_ptr<application::Instance> result = server.start("noapp");
unique_ptr<application::Instance> result = server.start("noapp");
cout << "new application " << result->getNameId() << endl;
if (time > 0) {
boost::this_thread::sleep(boost::posix_time::milliseconds(time));
this_thread::sleep_for(chrono::milliseconds(time));
}
application::State state = result->waitFor();
......
......@@ -14,9 +14,7 @@
* limitations under the Licence.
*/
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <thread>
#include <iostream>
#include <string>
#include <vector>
......@@ -25,33 +23,32 @@
using namespace std;
using namespace cameo;
using namespace boost;
void cancelAll() {
boost::this_thread::sleep(boost::posix_time::seconds(1));
this_thread::sleep_for(chrono::seconds(1));
application::This::cancelWaitings();
}
void cancelInstance(boost::shared_ptr<application::Instance> instance) {
void cancelInstance(shared_ptr<application::Instance> instance) {
boost::this_thread::sleep(boost::posix_time::seconds(1));
this_thread::sleep_for(chrono::seconds(1));
instance->cancelWaitFor();
}
void cancelPublisher(boost::shared_ptr<application::Publisher> publisher) {
void cancelPublisher(shared_ptr<application::Publisher> publisher) {
boost::this_thread::sleep(boost::posix_time::seconds(1));
this_thread::sleep_for(chrono::seconds(1));
publisher->cancelWaitForSubscribers();
}
void killInstance(boost::shared_ptr<application::Instance> instance) {
void killInstance(shared_ptr<application::Instance> instance) {
boost::this_thread::sleep(boost::posix_time::seconds(1));
this_thread::sleep_for(chrono::seconds(1));
instance->kill();
}
......@@ -68,32 +65,32 @@ int main(int argc, char *argv[]) {
{
cout << "starting stopcpp for cancelWaitings" << endl;
auto_ptr<application::Instance> stopApplication = server.start("stopcpp");
unique_ptr<application::Instance> stopApplication = server.start("stopcpp");
// Start thread
auto_ptr<thread> cancelThread(new thread(&cancelAll));
stopApplication->waitFor();
cout << "end of waitFor" << endl;
stopApplication->stop();
application::State state = stopApplication->waitFor();
cout << "end of stopcpp with state " << application::toString(state) << endl;
cancelThread->join();
unique_ptr<thread> cancelThread(new thread(&cancelAll));
//
// stopApplication->waitFor();
//
// cout << "end of waitFor" << endl;
//
// stopApplication->stop();
// application::State state = stopApplication->waitFor();
//
// cout << "end of stopcpp with state " << application::toString(state) << endl;
//
// cancelThread->join();
}
/*
// Test the cancel function
{
cout << "starting stopcpp for cancelWaitFor" << endl;
// Use a shared_ptr to use it in the thread and the main thread.
boost::shared_ptr<application::Instance> stopApplication(server.start("stopcpp"));
shared_ptr<application::Instance> stopApplication(server.start("stopcpp"));
// Start thread
auto_ptr<thread> cancelThread(new thread(bind(&cancelInstance, stopApplication)));
unique_ptr<thread> cancelThread(new thread(bind(&cancelInstance, stopApplication)));
stopApplication->waitFor();
......@@ -112,10 +109,10 @@ int main(int argc, char *argv[]) {
cout << "creating publisher and waiting for 1 subscriber..." << endl;
// Use a shared_ptr to use it in the thread and the main thread.
boost::shared_ptr<application::Publisher> publisher(application::Publisher::create("publisher", 1));
shared_ptr<application::Publisher> publisher(application::Publisher::create("publisher", 1));
// Start thread
auto_ptr<thread> cancelThread(new thread(bind(&cancelPublisher, publisher)));
unique_ptr<thread> cancelThread(new thread(bind(&cancelPublisher, publisher)));
bool synced = publisher->waitForSubscribers();
......@@ -129,13 +126,13 @@ int main(int argc, char *argv[]) {
cout << "starting publoopcpp for killing" << endl;
// Use a shared_ptr to use it in the thread and the main thread.
boost::shared_ptr<application::Instance> pubLoopApplication(server.start("publoopcpp"));
shared_ptr<application::Instance> pubLoopApplication(server.start("publoopcpp"));
// Start thread
auto_ptr<thread> killThread(new thread(bind(&killInstance, pubLoopApplication)));
unique_ptr<thread> killThread(new thread(bind(&killInstance, pubLoopApplication)));
// Create a subscriber
auto_ptr<application::Subscriber> subscriber = application::Subscriber::create(*pubLoopApplication, "publisher");
unique_ptr<application::Subscriber> subscriber = application::Subscriber::create(*pubLoopApplication, "publisher");
// Receiving data
string data;
......@@ -157,13 +154,13 @@ int main(int argc, char *argv[]) {
cout << "starting publoopcpp for testing cancel of a subscriber" << endl;
// Use a shared_ptr to use it in the thread and the main thread.
boost::shared_ptr<application::Instance> pubLoopApplication(server.start("publoopcpp"));
shared_ptr<application::Instance> pubLoopApplication(server.start("publoopcpp"));