Probleme mit boost::thread_group in einer Klasse



  • Hey @all,

    und zwar hätte ich folgendes vor:

    // Header
    
    class System{
    private:
    	boost::thread_group threads;
    
    	void initialize();
    	void TCPServer(unsigned short _port = 0);
    public:
    	System();
    	~System();
    	void instanceServer(unsigned short _port);
    	void instanceClient();
    };
    
    // Source
    System::System() {
    	initialize();
    }
    
    System::~System() {
    	this->threads.join_all();
    }
    
    void System::initialize() {
    }
    
    void System::instanceServer(unsigned short _port) {
    	// Server
    	this->threads.create_thread(boost::bind(&System::TCPServer, _port));
    }
    
    void System::instanceClient() {
    }
    
    void System::TCPServer(unsigned short _port) {
    	// Mach was
    }
    
    // Hauptprogramm
    int main(int argc, char* argv[]) {
    	System *sys = new System();
    	sys->instanceServer(80);
    	return 0;
    }
    

    Wenn ich das kompilieren möchte erhalte ich folgende Fehlermeldung:

    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(18) : error C2091: function returns function
    system.cpp(19) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
            with
            [
                R=void (unsigned short),
                F=boost::_mfi::dm<void (unsigned short),System>,
                L=boost::_bi::list1<boost::_bi::value<unsigned short>>
            ]
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(24) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(29) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(35) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(41) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(47) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(53) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(59) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(65) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(71) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(77) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(83) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(89) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(95) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(101) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(107) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(113) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(119) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(125) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(131) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(137) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(142) : error C2091: function returns function
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(318) : warning C4180: qualifier applied to function type has no meaning; ignored
            c:\boost_80\include\boost-1_33_1\boost\bind\bind_template.hpp(160) : see reference to class template instantiation 'boost::_mfi::dm<R,T>' being compiled
            with
            [
                R=void (unsigned short),
                T=System
            ]
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(326) : warning C4180: qualifier applied to function type has no meaning; ignored
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(336) : warning C4180: qualifier applied to function type has no meaning; ignored
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(350) : warning C4180: qualifier applied to function type has no meaning; ignored
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(355) : warning C4180: qualifier applied to function type has no meaning; ignored
    c:\boost_80\include\boost-1_33_1\boost\mem_fn.hpp(369) : warning C4180: qualifier applied to function type has no meaning; ignored
    

    Kann mir jemand sagen helfen wie ich es fertig bekomme das ich eine Methode mit boost::threads mit und ohne argumente aufrufen kann?

    Vielen Dank im Voraus

    _freeze_


Anmelden zum Antworten