Skip to content

Commit

Permalink
shutdown working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Jan 3, 2018
1 parent 81e10ae commit 62d39cc
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "/Users/Zajo/Desktop/boost/bin.v2/libs/synapse/build/test/connection_lifetime_test.test/darwin-darwin-4.2.1/debug/link-static/threadapi-pthread/connection_lifetime_test",
// "program": "/Users/Zajo/Desktop/boost/bin.v2/libs/synapse/build/example/glfw/darwin-darwin-4.2.1/debug/threadapi-pthread/glfw_example",
// "program": "/Users/emildotchevski/Desktop/boost/bin.v2/libs/synapse/build/test/connection_lifetime_test.test/darwin-darwin-4.2.1/debug/link-static/threadapi-pthread/connection_lifetime_test",
"program": "/Users/emildotchevski/Desktop/boost/bin.v2/libs/synapse/build/example/glfw/darwin-darwin-4.2.1/debug/threadapi-pthread/glfw_example",
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"externalConsole": false,
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
Expand Down
21 changes: 21 additions & 0 deletions .vscode/tasks-chooser.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,27 @@
"isBuildCommand": "true",
"command": "sh",
"args": [ "-c", "cd ${workspaceRoot}/build/test && ../../../../b2 shutdown_test6" ]
},
{
"displayName": "shutdown_test7",
"description": "shutdown_test7",
"isBuildCommand": "true",
"command": "sh",
"args": [ "-c", "cd ${workspaceRoot}/build/test && ../../../../b2 shutdown_test7" ]
},
{
"displayName": "shutdown_test8",
"description": "shutdown_test8",
"isBuildCommand": "true",
"command": "sh",
"args": [ "-c", "cd ${workspaceRoot}/build/test && ../../../../b2 shutdown_test8" ]
},
{
"displayName": "shutdown_test9",
"description": "shutdown_test9",
"isBuildCommand": "true",
"command": "sh",
"args": [ "-c", "cd ${workspaceRoot}/build/test && ../../../../b2 shutdown_test9" ]
}
],
"baseItem": {
Expand Down
3 changes: 3 additions & 0 deletions build/test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ run shutdown_test3.cpp ..//synapse ;
run shutdown_test4.cpp ..//synapse ;
run shutdown_test5.cpp ..//synapse ;
run shutdown_test6.cpp ..//synapse ;
run shutdown_test7.cpp ..//synapse ;
run shutdown_test8.cpp ..//synapse ;
run shutdown_test9.cpp ..//synapse ;
run ct_basic_test.cpp /boost//thread ..//synapse : : : <threading>multi ;
run ct_tlq_lifetime_test.cpp /boost//thread ..//synapse : : : <threading>multi ;
run ct_lambda_test.cpp /boost//thread ..//synapse : : : <threading>multi ;
Expand Down
7 changes: 6 additions & 1 deletion src/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ boost
void
destroy()
{
BOOST_SYNAPSE_ASSERT(first_rec_==-1);
if( shared_ptr<thread_local_signal_data> tlsd=tlsd_.lock() )
{
BOOST_SYNAPSE_ASSERT(tlsd);
Expand All @@ -234,6 +233,11 @@ boost
tlsd->cleanup_=&cleanup_stub;
}
}
bool
empty() const
{
return first_rec_==-1;
}
public:
int (* const emit_meta_connected_)( connection &, unsigned );
connection_list( shared_ptr<thread_local_signal_data> const & tlsd, int (*emit_meta_connected)( connection &, unsigned ) ):
Expand All @@ -253,6 +257,7 @@ boost
}
~connection_list()
{
BOOST_SYNAPSE_ASSERT(empty());
destroy();
}
weak_store const &
Expand Down
3 changes: 1 addition & 2 deletions test/shutdown_test1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -22,5 +21,5 @@ main( int argc, char const * argv[] )
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<my_signal>( e, [ ] ( ) { } );
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
return boost::report_errors();
return 0;
}
3 changes: 1 addition & 2 deletions test/shutdown_test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -22,5 +21,5 @@ main( int argc, char const * argv[] )
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
synapse::connect<my_signal>( e, [ ] ( ) { } );
return boost::report_errors();
return 0;
}
3 changes: 1 addition & 2 deletions test/shutdown_test3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -22,5 +21,5 @@ main( int argc, char const * argv[] )
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<my_signal>( e, [ ] ( ) { } );
return boost::report_errors();
return 0;
}
7 changes: 3 additions & 4 deletions test/shutdown_test4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -14,13 +13,13 @@ namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
}

int
main( int argc, char const * argv[] )
{
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<my_signal>( e, [ ] ( ) { } );
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
return boost::report_errors();
auto connected = release(synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } ));
return 0;
}
7 changes: 3 additions & 4 deletions test/shutdown_test5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -14,13 +13,13 @@ namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
}

int
main( int argc, char const * argv[] )
{
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
synapse::connect<my_signal>( e, [ ] ( ) { } );
return boost::report_errors();
auto connected = release(synapse::connect<my_signal>( e, [ ] ( ) { } ));
return 0;
}
9 changes: 4 additions & 5 deletions test/shutdown_test6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>
#include <boost/detail/lightweight_test.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
Expand All @@ -14,13 +13,13 @@ namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
}
}

int
main( int argc, char const * argv[] )
{
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
synapse::connect<my_signal>( e, [ ] ( ) { } );
return boost::report_errors();
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
auto connected = release(synapse::connect<my_signal>( e, [ ] ( ) { } ));
return 0;
}
25 changes: 25 additions & 0 deletions test/shutdown_test7.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Copyright (c) 2015-2017 Emil Dotchevski and Reverge Studios, Inc.

//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
using synapse::make_shared;

namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
}

int
main( int argc, char const * argv[] )
{
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<my_signal>( e, [ ] ( ) { } );
auto connected = release(synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } ));
exit(0);
}
25 changes: 25 additions & 0 deletions test/shutdown_test8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Copyright (c) 2015-2017 Emil Dotchevski and Reverge Studios, Inc.

//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
using synapse::make_shared;

namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
}

int
main( int argc, char const * argv[] )
{
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
auto connected = release(synapse::connect<my_signal>( e, [ ] ( ) { } ));
exit(0);
}
25 changes: 25 additions & 0 deletions test/shutdown_test9.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Copyright (c) 2015-2017 Emil Dotchevski and Reverge Studios, Inc.

//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/synapse/connect.hpp>

namespace synapse=boost::synapse;
using synapse::shared_ptr;
using synapse::make_shared;

namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
}

int
main( int argc, char const * argv[] )
{
synapse::connect<synapse::meta::connected<my_signal> >( synapse::meta::emitter(), [ ]( synapse::connection &, unsigned ) { } );
shared_ptr<my_emitter_type> e=make_shared<my_emitter_type>();
auto connected = release(synapse::connect<my_signal>( e, [ ] ( ) { } ));
exit(0);
}

0 comments on commit 62d39cc

Please sign in to comment.