void CLogSvcServer::RegisterServerSocketEventHandlers( void ) { TEventCallback callback( this, &CLogSvcServer::OnServerSocketClientConnected ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ClientConnectedEvent , callback ); TEventCallback callback2( this, &CLogSvcServer::OnServerSocketClientDisconnected ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ClientDisconnectedEvent , callback2 ); TEventCallback callback3( this, &CLogSvcServer::OnServerSocketClientError ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ClientErrorEvent , callback3 ); TEventCallback callback4( this, &CLogSvcServer::OnServerSocketServerSocketClosed ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ServerSocketClosedEvent , callback4 ); TEventCallback callback5( this, &CLogSvcServer::OnServerSocketServerSocketError ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ServerSocketErrorEvent , callback5 ); TEventCallback callback6( this, &CLogSvcServer::OnServerSocketServerSocketClientError ); SubscribeTo( &m_tcpServer , COMCORE::CTCPServerSocket::ServerSocketClientErrorEvent , callback6 ); }
void ImageMT::Square() { if(m_pLayers.GetCount()<=0) return; Layer* pLayer = m_pLayers[0]; double f = m_fPower.GetData(); AtomicInc(threads); Thread().Run(callback4(&Layer::MakeLayerAsThread,pLayer,f,this,0)); }
void MyServiceAsyncClient::sync_getDataById(apache::thrift::RpcOptions& rpcOptions, std::string& _return, int64_t id) { apache::thrift::ClientReceiveState _returnState; std::unique_ptr<apache::thrift::RequestCallback> callback4(new apache::thrift::ClientSyncCallback(&_returnState, getChannel()->getEventBase(), false)); getDataById(rpcOptions, std::move(callback4), id); getChannel()->getEventBase()->loopForever(); SCOPE_EXIT { if (_returnState.header() && !_returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(_returnState.header()->releaseHeaders()); } }; if (!_returnState.buf()) { assert(_returnState.exception()); std::rethrow_exception(_returnState.exception()); } recv_getDataById(_return, _returnState); }
void Threads::Process(const FractalJobHandeler & job) { ProgressInfo statTotal(statusBar); rows = inp_row.GetData(); cols = inp_col.GetData(); densityR = picbox.GetSize().cy / rows; densityC = picbox.GetSize().cx / cols; maxIter = inp_iter.GetData(); logmax= log10((double)maxIter); max_threads = inp_threads.GetData(); statTotal.Set(0,rows*cols); TimeStop startTime; for (int r = 0; r < rows; r++){ for (int c = 0; c < cols; c++) { while(threads >= max_threads) waitforfinish.Wait(); AtomicInc(threads); Thread().Run(callback4(this, &Threads::ThreadRenderJob, r, c, job, 0)); INTERLOCKED_(job_lock) active.Add((r * cols + c), 0); statTotal.Text(Format("Invoking calculations for sector R:%02d C:%02d",r,c)); time.Set(FormatTS(startTime.Elapsed())); picbox.Refresh(); statTotal.Set(r * cols + c,rows*cols); ProcessEvents(); } } while(threads > 0) waitforfinish.Wait(); time.Set(FormatTS(startTime.Elapsed())); picbox.Refresh(); }