Example #1
0
int _tmain(int argc, _TCHAR* argv[])
{
    hasTicked_ = false;
    numTicked_ = 0;


    std::function<void()> slot = std::bind(Ticked);
    boost::signals2::connection callbackConnection =  tickPublisher.connect(slot);

    {
    boost::timer::auto_cpu_timer timer;
    std::cout << "start Ticker" << std::endl;

    TickWrapper ticker;
    tickerThread_ = new std::thread(std::bind(&TickWrapper::Tick, &ticker, period));
    WaitUntilTicked(1);
    
    std::cout << "stop Ticker" << std::endl;
    tickingCondition_.notify_all();

    }
    tickPublisher.disconnect(callbackConnection);
    std::getchar();
    return 0;
}
Example #2
0
namespace LSL
{
boost::signals2::signal<void()> battleSig;

struct User
{
	User(const std::string& id, const std::string& nick,
	     const std::string& country, const int cpu)
	{
		battleSig.connect(*this);
	}
	void operator()() const
	{
		std::cout << "I was called" << std::endl;
	}
};

struct Battle
{
	void update()
	{
		battleSig();
	}
};
}
Example #3
0
int main()
{
  s.connect([](int i){
    std::lock_guard<std::mutex> lock{m};
    std::cout << i << '\n';
  });
  std::thread t1{loop};
  std::thread t2{loop};
  t1.join();
  t2.join();
}
Example #4
0
File: main.cpp Project: CCJY/coliru
int main(void) {
    string str1("Hello");
    string str2("World");
    
    cSignal.connect(boost::bind(f,
        boost::bind(&string::c_str, _1),
        boost::bind(&string::c_str, _2)));
    
    cSignal(str1, str2);
    
    return 0;
}
Example #5
0
File: main.cpp Project: CCJY/coliru
int main()
{
    try
    {
        work_lock = boost::make_shared<boost::asio::io_service::work>(svc);
        textEntered.connect(&handleInputText);

        boost::thread_group tg;
        tg.create_thread(boost::bind(&boost::asio::io_service::run, &svc));
        tg.create_thread(&worker);

        boost::this_thread::sleep_for(boost::chrono::seconds(3));
        work_lock.reset();

        tg.join_all();
    }
    catch(std::exception &ex)
    {
        std::cerr<<"main() exited with exception:"<<ex.what();
    }
    return 0;
}
Example #6
0
 inline void wait( boost::signals2::signal<void()>& sig, const microseconds& timeout_us=microseconds::maximum() ) {
   promise<void>::ptr p(new promise<void>("fc::signal::wait"));
   boost::signals2::scoped_connection c( sig.connect( [=]() { p->set_value(); } )); 
   p->wait( timeout_us ); 
 }
Example #7
0
 inline T wait( boost::signals2::signal<void(T)>& sig, const microseconds& timeout_us=microseconds::maximum() ) {
   typename promise<T>::ptr p(new promise<T>("fc::signal::wait"));
   boost::signals2::scoped_connection c( sig.connect( [=]( T t ) { p->set_value(t); } )); 
   return p->wait( timeout_us ); 
 }
Example #8
0
void connect_stdinput(boost::function<void(std::string)> cb)
{
	input_got_one_line.connect(cb);
}
 void setSaveAsCommit( const boost::signals2::signal<void (const std::string&)>::slot_type& cb )
 {
     mSaveAsSignal.connect(cb);
 }
Example #10
0
 MyClass() {
     sig.connect(boost::bind(&MyClass::print_args, this, _1, _2, 10));
 }
				// IsFOMAOpen の状態をもらってくる
				void slot_sync_isFOMAOpen(boost::signals2::signal<void(bool)> &sig_){
					connections(sig_.connect([&](bool flag_)->void{this->sync_isFOMAOpen(flag_); }));
				}
Example #12
0
	User(const std::string& id, const std::string& nick,
	     const std::string& country, const int cpu)
	{
		battleSig.connect(*this);
	}