Exemplo n.º 1
0
	void ClipmapRenderer::shutdown()
	{
		onDestroyGpuResources();
		onShutdown();
		window_ = 0;
		geoClipmaps_ = 0;
	}
Exemplo n.º 2
0
void Service::start()
{
    try
    {
        sp_modules_->loadModules();

        observers_.notify(&IObserver::onServerPrepared);
        if (!isShutdown())
            run();
    }
    catch (exception& e)
    {
        shutdown_now = true;
        try
        {
            observers_.notify(&IObserver::onServerClosing);
            onShutdown();
        }
        catch (...)
        {
        }

        throw;
    }

    waitForShutdown();
}
Exemplo n.º 3
0
void TcpConnection::run()
{
    try
    {
        //Poco::Net::SocketAddress address = _socket.peerAddress();
        //std::string peer(_socket.peerAddress().toString().data());

        //char hostname[48] = {0};
        //memcpy(hostname, _socket.peerAddress().toString().c_str(), strlen(_socket.peerAddress().toString().c_str()));
        debug_log("connection established.");
        sendMessage(10001, (const byte*)"hello", 5);
        for (;;)
        {
			bool readable = _socket.poll(Poco::Timespan(30, 0), Poco::Net::Socket::SelectMode::SELECT_READ);
			if (readable == true && onReadable() == false)
            {
                return;
            }
        }
    }
    catch (Poco::Exception& e)
    {
        onShutdown(ShutdownReason::SR_EXCEPTION);
    }
    catch (...)
    {
        error_log("unknown exception.");
    }
}
void TimingSwitchDialog::setupSignal()
{
	connect(ui->setClient,SIGNAL(clicked()),this,SLOT(onSetClient()));
	connect(ui->shutdown,SIGNAL(clicked()),this,SLOT(onShutdown()));
	connect(ui->restart,SIGNAL(clicked()),this,SLOT(onRestart()));
	connect(ui->timingOk,SIGNAL(clicked()),this,SLOT(onTimingShutdown()));
	connect(ui->timingCancel,SIGNAL(clicked()),this,SLOT(onCancelTiming()));
}
Exemplo n.º 5
0
/*************** MAIN *********************/
int main (int argc, char *argv[])
{
    QApplication q_app (argc, argv);
    PacmanVision pacv_app;

    QObject::connect(&q_app, SIGNAL( aboutToQuit() ), &pacv_app, SLOT( onShutdown()));
    if (pacv_app.init(argc, argv))
        return q_app.exec();
    else
        return 1;
}
Exemplo n.º 6
0
// 返回false意味着连接已被对端关闭
bool TcpConnection::onReadable()
{
    int bytes_transferred = _socket.receiveBytes(_buffer, MAX_RECV_LEN, 0);
    debug_log("received %d bytes.", bytes_transferred);
    if (bytes_transferred == 0)
    {
        onShutdown(ShutdownReason::SR_GRACEFUL_SHUTDOWN);
        return false;
    }

    return _blockPacketization.appendBlock(_buffer, bytes_transferred);
}
Exemplo n.º 7
0
void Service::waitForShutdown()
{
    observers_.notify(&IObserver::onServerRunning);

    while (!shutdown_now)
    {
        ::sleep(2);
    }

    bool expected = false;
    if (already_shutdown_.compare_exchange_strong(expected, true))
    {
        try
        {
            observers_.notify(&IObserver::onServerClosing);
            onShutdown();
        }
        catch (...)
        {
        }

        exit();
    }
}
Exemplo n.º 8
0
bool CapApp::onInit(int argc, char* argv[])
{
	(void)argc;
	(void)argv;

	// ----------------------------------------------
	// FTP	
	cellSysmoduleLoadModule(CELL_SYSMODULE_NET);
	cellNetCtlInit();
	cellSysmoduleLoadModule(CELL_SYSMODULE_HTTP);
	sys_net_initialize_network();
	ftp_on();

	// Load settings...
	if(!iniRead()) {
		iniWrite(); // create settings file...
	}

	cellSysmoduleLoadModule(CELL_SYSMODULE_FS);

	cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT);
	cellScreenShotEnable();

	InputInit();

	while(!videoOutIsReady())
	{
		// ...
	}


	PSGLinitOptions options = 
	{
		enable:					PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS,
		maxSPUs:				1,
		initializeSPUs:			GL_FALSE,
		persistentMemorySize:	0,
		transientMemorySize:	0,
		errorConsole:			0,
		fifoSize:				0,  
		hostMemorySize:			128* 1024*1024,  // 128 mbs for host memory 
	};

#if CELL_SDK_VERSION < 0x340000
	options.enable |=	PSGL_INIT_HOST_MEMORY_SIZE;
#endif

	// Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL
	sys_spu_initialize(6, 1);
	psglInit(&options);

	const unsigned int resolutions[] = { 
		CELL_VIDEO_OUT_RESOLUTION_1080, 
		CELL_VIDEO_OUT_RESOLUTION_960x1080, 
		CELL_VIDEO_OUT_RESOLUTION_720, 
		CELL_VIDEO_OUT_RESOLUTION_480 
	};

	const int numResolutions = sizeof(resolutions) / sizeof(resolutions[0]);

	int bestResolution = chooseBestResolution(resolutions,numResolutions);

	getResolutionWidthHeight(bestResolution, deviceWidth, deviceHeight);

	if(bestResolution)
	{
		PSGLdeviceParameters params;

		params.enable				= PSGL_DEVICE_PARAMETERS_COLOR_FORMAT |
									  PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT |
									  PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE;
		params.colorFormat			= GL_ARGB_SCE;
		params.depthFormat			= GL_NONE;
		params.multisamplingMode	= GL_MULTISAMPLING_NONE_SCE;
		params.enable				|= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT;
		params.width				= deviceWidth;
		params.height				= deviceHeight;

		device						= psglCreateDeviceExtended(&params);
		context						= psglCreateContext();

		psglMakeCurrent(context, device);
		psglResetCurrentContext();

		initGraphics();

		if( cellSysutilRegisterCallback( 0, callback_sysutil_exit, NULL ) < 0 ) {
			//...
		}

		dbgFontInit();

		fbaRL = new c_fbaRL();

		while(bRun)
		{
			onRender();
			onUpdate();
			cellSysutilCheckCallback();
		}

	} else {
		// resolution error...
	}

	ftp_off();

	onShutdown();

	return false;
}

void CapApp::onRender()
{
	if(fbaRL) { fbaRL->DlgDisplayFrame(); }

	// get render target buffer dimensions and set viewport	
	psglGetRenderBufferDimensions(device,&app.renderWidth,&app.renderHeight);

	glViewport(0, 0, app.renderWidth, app.renderHeight);

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if(fbaRL) { fbaRL->RenderBackground(); }
	if(fbaRL) { fbaRL->nFrameStep = 0; fbaRL->DisplayFrame(); }
	if(fbaRL) { fbaRL->nFrameStep = 1; fbaRL->DisplayFrame(); }
	dbgFontDraw();

	psglSwap();
}

bool CapApp::onUpdate()
{
	if(!mFrame) mFrame = 0;
	mFrame++;

	InputFrameStart();
	if(fbaRL) fbaRL->InputFrame();
	InputFrameEnd();	

	return true;
}

void CapApp::onShutdown()
{
	iniWrite(); // save settings

	if(context) psglDestroyContext(context);
	if(device) psglDestroyDevice(device);

	InputExit();
	psglExit();
}
Exemplo n.º 9
0
void SocketReactor::run()
{
	_pThread = Thread::current();

	Socket::SocketList readable;
	Socket::SocketList writable;
	Socket::SocketList except;
	
	while (!_stop)
	{
		try
		{
			readable.clear();
			writable.clear();
			except.clear();
			int nSockets = 0;
			{
				FastMutex::ScopedLock lock(_mutex);
				for (EventHandlerMap::iterator it = _handlers.begin(); it != _handlers.end(); ++it)
				{
					if (it->second->accepts(_pReadableNotification))
					{
						readable.push_back(it->first);
						nSockets++;
					}
					if (it->second->accepts(_pWritableNotification))
					{
						writable.push_back(it->first);
						nSockets++;
					}
					if (it->second->accepts(_pErrorNotification))
					{
						except.push_back(it->first);
						nSockets++;
					}
				}
			}
			if (nSockets == 0)
			{
				onIdle();
				Thread::trySleep(static_cast<long>(_timeout.totalMilliseconds()));
			}
			else if (Socket::select(readable, writable, except, _timeout))
			{
				onBusy();

				for (Socket::SocketList::iterator it = readable.begin(); it != readable.end(); ++it)
					dispatch(*it, _pReadableNotification);
				for (Socket::SocketList::iterator it = writable.begin(); it != writable.end(); ++it)
					dispatch(*it, _pWritableNotification);
				for (Socket::SocketList::iterator it = except.begin(); it != except.end(); ++it)
					dispatch(*it, _pErrorNotification);
			}
			else onTimeout();
		}
		catch (Exception& exc)
		{
			ErrorHandler::handle(exc);
		}
		catch (std::exception& exc)
		{
			ErrorHandler::handle(exc);
		}
		catch (...)
		{
			ErrorHandler::handle();
		}
	}
	onShutdown();
}
Exemplo n.º 10
0
void SystemMenu::rebuildMenu(bool dockHiding)
{
	if (menu()) {
		menu()->clear();
	}
	
	QMenu *menu = new QMenu(this);

	about = new QAction("About this computer", this);
	menu->addAction(about);
	connect(about, SIGNAL(triggered()), this, SLOT(onAbout()));

/* TODO: Removed for now until I found clear way for managing software on different distros 
	QAction *software = new QAction("Software management ...", this);
	menu->addAction(software);
*/
	menu->addSeparator();

	QAction *pref = new QAction("System preferences ...", this);
	menu->addAction(pref);
	connect(pref, SIGNAL(triggered()), this, SLOT(onPreferences()));

	menu->addSeparator();

	if (dockHiding) {
		adock_on = new QAction("Turn Hiding Off", this);
	} else {
		int s = app->dock->dockState;
		if (s == Dockbar::Normal || s == Dockbar::Showing || s == Dockbar::AboutToShow) {
			adock_on = new QAction("Turn Hiding On", this);
		} else if (s == Dockbar::Hidden || s == Dockbar::Hiding) {
			adock_on = new QAction("Turn Hiding Off", this);
		}
	}
	//QAction *adock_magn = new QAction("Turn Magnification On", this);
	adock_pref = new QAction("Dock Preferences ...", this);
	QMenu *dock_menu = menu->addMenu("Dock");
	dock_menu->addAction(adock_on);
	connect(adock_on, SIGNAL(triggered()), this, SLOT(onShowHideDock()));
	connect(adock_pref, SIGNAL(triggered()), this, SLOT(onDockPref()));
	
	//dock_menu->addAction(adock_magn);
	dock_menu->addSeparator();
	dock_menu->addAction(adock_pref);

	menu->addSeparator();
	
/* TODO: Removed for now until I implement the features

	QAction *force_quit = new QAction("Force Quit ...", this);
	menu->addAction(force_quit);
	menu->addSeparator();
*/
	sleep = new QAction("Sleep", this);
	menu->addAction(sleep);
	connect(sleep, SIGNAL(triggered()), this, SLOT(onSleep()));

	restart = new QAction("Restart ...", this);
	menu->addAction(restart);
	connect(restart, SIGNAL(triggered()), this, SLOT(onRestart()));

	shutdown = new QAction("Shutdown ...", this);
	menu->addAction(shutdown);
	connect(shutdown, SIGNAL(triggered()), this, SLOT(onShutdown()));

	menu->addSeparator();
	logout = new QAction("Logout ...", this);
	menu->addAction(logout);
	connect(logout, SIGNAL(triggered()), this, SLOT(onLogout()));

	setMenu(menu);
	
	connect(this, SIGNAL(clicked()), this, SLOT(showMenu()));
}
void MediaFilter::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatAllocateComponent:
        {
            onAllocateComponent(msg);
            break;
        }
        case kWhatConfigureComponent:
        {
            onConfigureComponent(msg);
            break;
        }
        case kWhatStart:
        {
            onStart();
            break;
        }
        case kWhatProcessBuffers:
        {
            processBuffers();
            break;
        }
        case kWhatInputBufferFilled:
        {
            onInputBufferFilled(msg);
            break;
        }
        case kWhatOutputBufferDrained:
        {
            onOutputBufferDrained(msg);
            break;
        }
        case kWhatShutdown:
        {
            onShutdown(msg);
            break;
        }
        case kWhatFlush:
        {
            onFlush();
            break;
        }
        case kWhatResume:
        {
            // nothing to do
            break;
        }
        case kWhatSetParameters:
        {
            onSetParameters(msg);
            break;
        }
        case kWhatCreateInputSurface:
        {
            onCreateInputSurface();
            break;
        }
        case GraphicBufferListener::kWhatFrameAvailable:
        {
            onInputFrameAvailable();
            break;
        }
        case kWhatSignalEndOfInputStream:
        {
            onSignalEndOfInputStream();
            break;
        }
        default:
        {
            ALOGE("Message not handled:\n%s", msg->debugString().c_str());
            break;
        }
    }
}
Exemplo n.º 12
0
void Manager::_onShutdown(Event *e)
{
	state = MANAGER_STATE_SHUTDOWN;
	onShutdown();
}
Exemplo n.º 13
0
void RfService::shutdown()
{
    onShutdown();
}