Пример #1
0
	// 请求计数
	void TrackeragStatistic::SubmitClientRequest(unsigned packet_size)
	{
		// counter
		Submit(StatisticType::CLIENT_REQUEST, 1);
		// bytes
		Submit(StatisticType::CLIENT_REQUEST_BYTES, packet_size);
	}
Пример #2
0
void releaseOpenVrSystem() {
    if (activeHmd) {
        Lock lock(mutex);
        #if DEV_BUILD
            qCDebug(displayplugins) << "OpenVR: decrementing refcount";
        #endif
        --refCount;
        if (0 == refCount) {
            #if DEV_BUILD
                qCDebug(displayplugins) << "OpenVR: zero refcount, deallocate VR system";
            #endif

            // HACK: workaround openvr crash, call submit with an invalid texture, right before VR_Shutdown.
            const GLuint INVALID_GL_TEXTURE_HANDLE = -1;
            vr::Texture_t vrTexture{ (void*)INVALID_GL_TEXTURE_HANDLE, vr::API_OpenGL, vr::ColorSpace_Auto };
            static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_LEFT{ 0, 0, 0.5f, 1 };
            static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_RIGHT{ 0.5f, 0, 1, 1 };

            auto compositor = vr::VRCompositor();
            if (compositor) {
                compositor->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT);
                compositor->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT);
            }

            vr::VR_Shutdown();
            _openVrQuitRequested = false;
            activeHmd = nullptr;
        }
    }
}
Пример #3
0
	// 响应计数
	void TrackeragStatistic::SubmitListResponse(unsigned packet_size)
	{
		// counter
		Submit(StatisticType::TRACKER_RESPONSE, 1);
		// bytes
		Submit(StatisticType::TRACKER_RESPONSE_BYTES, packet_size);
	}
Пример #4
0
	void TrackeragStatistic::SubmitCommitResponse(unsigned packet_size)
	{
		// counter
		Submit(StatisticType::RESPONSE_CLIENT, 1);
		// bytes
		Submit(StatisticType::RESPONSE_CLIENT_BYTES, packet_size);
	}
Пример #5
0
	// 请求计数
	void TrackeragStatistic::SubmitTrackerRequest(unsigned packet_size, int send_num)
	{
		// counter
		Submit(StatisticType::REQUEST_TRACKER, send_num);
		// bytes
		Submit(StatisticType::REQUEST_TRACKER_BYTES, packet_size*send_num);
	}
Пример #6
0
void if2mem(char* file,
                   char* result,
                   char* bindir,
                   int suppressWarnings, /* suppress warnings? */
                   int profiling, /* profiling */
                   int optimize, /* Perform aggressive optimization */
                   int optimizeInlined /* optimize inlined calls */
            ) {
   char manager[MAXPATHLEN];
   charStarQueue* argv = 0;

   sprintf(manager,"%s/if2mem",bindir);
   enqueue(&argv,manager);

   enqueue(&argv,file);
   enqueue(&argv,result);

   if ( !optimize ) {
      enqueue(&argv,"-v"); /* no invar */
      enqueue(&argv,"-V"); /* no Oinvar */
      enqueue(&argv,"-c"); /* no cse */
      enqueue(&argv,"-g"); /* no gcse */
      enqueue(&argv,"-f"); /* no fold */
   }

   if ( suppressWarnings ) enqueue(&argv,"-w");
   if ( profiling ) enqueue(&argv,"-W");

   if ( Submit(&argv) != 0 ) {
      compilerError("if2 memory manager failure");
   }

}
Пример #7
0
void if2up(char* file,
           char* result,
           char* bindir,
           int suppressWarnings, /* suppress warnings? */
           int profiling /* profiling */
           ) {
   char updater[MAXPATHLEN];
   charStarQueue* argv = 0;

   sprintf(updater,"%s/if2up",bindir);
   enqueue(&argv,updater);

   enqueue(&argv,file);
   enqueue(&argv,result);

   if ( suppressWarnings ) enqueue(&argv,"-w");
   if ( profiling ) enqueue(&argv,"-W");

   enqueue(&argv,"-I"); /* Suppress Sequent code improvement migration */

   if ( Submit(&argv) != 0 ) {
      compilerError("if2 update in place failure");
   }

}
Пример #8
0
void VulkanRenderManager::EndSyncFrame(int frame) {
	FrameData &frameData = frameData_[frame];
	Submit(frame, false);

	// This is brutal! Should probably wait for a fence instead, not that it'll matter much since we'll
	// still stall everything.
	vkDeviceWaitIdle(vulkan_->GetDevice());

	// At this point we can resume filling the command buffers for the current frame since
	// we know the device is idle - and thus all previously enqueued command buffers have been processed.
	// No need to switch to the next frame number.
	VkCommandBufferBeginInfo begin{
		VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
		nullptr,
		VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
	};
	VkResult res = vkBeginCommandBuffer(frameData.mainCmd, &begin);
	assert(res == VK_SUCCESS);

	if (useThread_) {
		std::unique_lock<std::mutex> lock(frameData.push_mutex);
		frameData.readyForFence = true;
		frameData.push_condVar.notify_all();
	}
}
Пример #9
0
void VulkanRenderManager::EndSubmitFrame(int frame) {
	FrameData &frameData = frameData_[frame];
	frameData.hasBegun = false;

	Submit(frame, true);

	if (!frameData.skipSwap) {
		VkSwapchainKHR swapchain = vulkan_->GetSwapchain();
		VkPresentInfoKHR present = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR };
		present.swapchainCount = 1;
		present.pSwapchains = &swapchain;
		present.pImageIndices = &frameData.curSwapchainImage;
		present.pWaitSemaphores = &renderingCompleteSemaphore_;
		present.waitSemaphoreCount = 1;

		VkResult res = vkQueuePresentKHR(vulkan_->GetGraphicsQueue(), &present);
		// TODO: Deal with VK_SUBOPTIMAL_KHR ?
		if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_SUBOPTIMAL_KHR) {
			// ignore, it'll be fine. this happens sometimes during resizes, and we do make sure to recreate the swap chain.
		} else {
			_assert_msg_(G3D, res == VK_SUCCESS, "vkQueuePresentKHR failed! result=%s", VulkanResultToString(res));
		}
	} else {
		frameData.skipSwap = false;
	}
}
Bool BonkEnc::CDDBBatch::SubmitAll()
{
	while (submits.Length() > 0)
	{
		if (!Submit(submits.GetNth(0))) return False;
	}

	return True;
}
Пример #11
0
void FCrashReportClient::UserCommentChanged(const FText& Comment, ETextCommit::Type CommitType)
{
	UserComment = Comment;

	// Implement Shift+Enter to commit shortcut
	if (CommitType == ETextCommit::OnEnter && FSlateApplication::Get().GetModifierKeys().IsShiftDown())
	{
		Submit();
	}
}
Пример #12
0
FReply FCrashReportClient::SubmitAndRestart()
{
	Submit();

	const FString CrashedAppPath = ErrorReport.FindCrashedAppPath();
	const FCrashDescription& CrashDescription = GetCrashDescription();
	const FString CommandLineArguments = CrashDescription.CommandLine;

	FPlatformProcess::CreateProc(*CrashedAppPath, *CommandLineArguments, true, false, false, NULL, 0, NULL, NULL);

	return FReply::Handled();
}
FReply FCrashReportClient::SubmitAndRestart()
{
	Submit();

	// Check for processes that were started from the Launcher using -EpicPortal on the command line
	bool bRunFromLauncher = FParse::Param(*FPrimaryCrashProperties::Get()->RestartCommandLine, TEXT("EPICPORTAL"));
	const FString CrashedAppPath = ErrorReport.FindCrashedAppPath();

	bool bLauncherRestarted = false;
	if (bRunFromLauncher)
	{
		// We'll restart Launcher-run processes by having the installed Launcher handle it
		IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();

		if (DesktopPlatform != nullptr)
		{
			// Split the path so we can format it as a URI
			TArray<FString> PathArray;
			CrashedAppPath.Replace(TEXT("//"), TEXT("/")).ParseIntoArray(PathArray, TEXT("/"), false);	// WER saves this out on Windows with double slashes as the separator for some reason.
			FString CrashedAppPathUri;

			// Exclude the last item (the filename). The Launcher currently expects an installed application folder.
			for (int32 ItemIndex = 0; ItemIndex < PathArray.Num() - 1; ItemIndex++)
			{
				FString& PathItem = PathArray[ItemIndex];
				CrashedAppPathUri += FPlatformHttp::UrlEncode(PathItem);
				CrashedAppPathUri += TEXT("/");
			}
			CrashedAppPathUri.RemoveAt(CrashedAppPathUri.Len() - 1);

			// Re-run the application via the Launcher
			FOpenLauncherOptions OpenOptions(FString::Printf(TEXT("apps/%s"), *CrashedAppPathUri));
			OpenOptions.bSilent = true;
			if (DesktopPlatform->OpenLauncher(OpenOptions))
			{
				bLauncherRestarted = true;
			}
		}
	}

	if (!bLauncherRestarted)
	{
		// Launcher didn't restart the process so start it ourselves
		const FString CommandLineArguments = FPrimaryCrashProperties::Get()->RestartCommandLine;
		FPlatformProcess::CreateProc(*CrashedAppPath, *CommandLineArguments, true, false, false, NULL, 0, NULL, NULL);
	}

	return FReply::Handled();
}
Пример #14
0
void CSimAdaptationRequests::SubmitOrQueueL(const RMessage2 &aMessage)
	{
	CAdaptationMessage *messageCopy = new(ELeave) CAdaptationMessage(aMessage);
		
	if(!IsActive())
		{
		Submit(messageCopy);
		}
	else 
		{
		CleanupStack::PushL(messageCopy);
		DEBUGPRINT2A("CSimAdaptationRequests queuing request with function id: %d", aMessage.Function());
		User::LeaveIfError(iPendingRequestsQueue.Queue(messageCopy));
		CleanupStack::Pop(messageCopy);
		}	
	}
Пример #15
0
void CSimAdaptationRequests::RunL()
	{
	
	WriteResponseDataToClientMessageL();

	DEBUGPRINT2A("CSimAdaptationRequests processed the request with funtion id: %d", iCurrentMessage->Function());
	iCurrentMessage->Complete(iStatus.Int());
	delete iCurrentMessage;
	iCurrentMessage = NULL;  

	if( (iPendingRequestsQueue.IsEmpty()) == EFalse )
		{
		CAdaptationMessage *messageCopy = NULL;
		iPendingRequestsQueue.Dequeue(messageCopy);
		Submit(messageCopy);
		} 
	}
Пример #16
0
	void Device::ReadBulk(const EndpointPtr & ep, const IObjectOutputStreamPtr &outputStream, int timeout)
	{
		UrbPtr urb = std::make_shared<Urb>(_fd.Get(), USBDEVFS_URB_TYPE_BULK, ep);
		size_t transferSize = urb->GetTransferSize();

		size_t r;
		bool continuation = false;
		do
		{
			urb->SetContinuationFlag(continuation);
			continuation = true;
			Submit(urb, timeout);

			ProcessControl();
			r = urb->Recv(outputStream);
		}
		while(r == transferSize);
	}
Пример #17
0
void CDissolveDialog::OnActionEvent(LONG id, void * p, DWORD we)
{
	switch(id)
	{
	case DIS_OKBTN:
		{
			PutError(
				Submit(),
				0);
			break;
		}
	case DIS_CANCELBTN:
		{
			Clear();
			break;
		}
	}
}
Пример #18
0
	void Device::WriteBulk(const EndpointPtr & ep, const IObjectInputStreamPtr &inputStream, int timeout)
	{
		UrbPtr urb = std::make_shared<Urb>(_fd.Get(), USBDEVFS_URB_TYPE_BULK, ep);
		size_t transferSize = urb->GetTransferSize();

		size_t r;
		bool continuation = false;
		do
		{
			r = urb->Send(inputStream);
			urb->SetZeroPacketFlag(r != transferSize);
			urb->SetContinuationFlag(continuation);
			continuation = true;
			Submit(urb, timeout);

			ProcessControl();
		}
		while(r == transferSize);
	}
Пример #19
0
void ReplicatedKeyspaceDB::OnExpiryTimer()
{
	assert(RLOG->IsMaster());
	
	uint64_t	expiryTime;
	Cursor		cursor;
	ByteString	key;
	KeyspaceOp*	op;

	Log_Trace();
	
	if (expiryAdded)
		return;
	
	transaction = RLOG->GetTransaction();
	if (!transaction->IsActive())
		transaction->Begin();
	
	table->Iterate(transaction, cursor);	
	kdata.Set("!!t:");
	if (!cursor.Start(kdata))
		ASSERT_FAIL();
	cursor.Close();
	
	if (kdata.length < 2)
		ASSERT_FAIL();
	
	if (kdata.buffer[0] != '!' || kdata.buffer[1] != '!')
		ASSERT_FAIL();

	ReadExpiryTime(kdata, expiryTime, key);
	
	op = new KeyspaceOp;
	op->cmdID = 0;
	op->type = KeyspaceOp::EXPIRE;
	op->key.Allocate(key.length);
	op->key.Set(key);
	// expiryTime is set in Append()
	op->service = NULL;
	Add(op);
	Submit();
}
Пример #20
0
 void ProcessNaviMesh(Render2 *render, Scene::Node *node, System::Object* o)
 {
     if (!o)
         return;
     AI::NaviMesh *mesh = (AI::NaviMesh*)o;
     auto m_frame = render->GetCurrentFrame();
     if (m_frame->IsEnabledNaviMeshRendering())
     {
         if (mesh)
         {
             auto r = Gpu::AsRenderable(*mesh, m_frame->GetVideoDriver());
             m_frame->PushAllState();
             m_frame->EnableTexturing(false);
             m_frame->EnableLighting(false);
             m_frame->EnableBlending(true);
             m_frame->SetDiffuseColor(0, 0, 1.0, .5);
             m_frame->Submit(r, true);
             m_frame->PopAllState();
         }
     }
     render->ProcessChildren(node);
 }
Пример #21
0
	void MScheduler::LeaveFrame()
	{
#if AX_PROFILING_ENABLED
# if !AX_ASYNC_FRAME_STEP_JOBS_ENABLED
		for( uint32 i = 1; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->m_FramePhase = EFramePhase::Leave;
		}

		AX_MEMORY_BARRIER();
# endif
#endif

#if !AX_ASYNC_FRAME_STEP_JOBS_ENABLED
		m_pWorkers[ 0 ]->m_TailCPUTimestamp = GetCPUCycles();
		Detail_v1::Notify( Detail_v1::ENotify::Frame, Detail_v1::ENotifyPhase::Leave );
#endif

		m_TailFrameMicrosecs = System::Microseconds();

#if AX_PROFILING_ENABLED
# if AX_ASYNC_FRAME_STEP_JOBS_ENABLED
		SJobChain *const pFrameChain = AllocChains( 1 );
		AX_ASSERT_NOT_NULL( pFrameChain );

		pFrameChain->pJobs = AllocTasks( m_cWorkers );
		AX_ASSERT_NOT_NULL( pFrameChain->pJobs );

		for( uint32 i = 0; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->SubmitLeaveFrameJob( *pFrameChain );
		}

		Submit( pFrameChain );
		WaitForAllJobs();
# endif
#endif

		//BasicDebugf( "MScheduler seconds = %.5f", System::MicrosecondsToSeconds( m_TailFrameMicrosecs - m_HeadFrameMicrosecs ) );
		//BasicDebugf( "Head = %u Tail = %u", ( unsigned int )m_HeadFrameMicrosecs, ( unsigned int )m_TailFrameMicrosecs );
	}
Пример #22
0
	bool ArrayEditor<ElementType>::OnEventButtonSavePressed(const CEGUI::EventArgs& arg)
	{
		OC_UNUSED(arg);
		Submit();
		return true;
	}
Пример #23
0
	void MScheduler::EnterFrame()
	{
		m_cFrameChains = 0;
		m_cFrameTasks = 0;

#if AX_ASYNC_LOCAL_WORK_ENABLED
		for( uint32 i = 0; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->m_uArenaIndex = i; //start checking here
		}
#else
		m_cSubmittedChains = 0;
		for( uint32 i = 0; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->m_uChainIndex = 0;
# if !AX_ASYNC_PER_CHAIN_INDEX_ENABLED
			m_pWorkers[ i ]->m_uLocalIndex = 0;
# endif
		}
#endif

		AX_MEMORY_BARRIER();

#if AX_PROFILING_ENABLED
		//
		//	Don't want to consider profiling overhead (to the maximum extent
		//	possible) as we're interested primarily in the performance of the
		//	actual content being scheduled.
		//

		ResetAllProfilePools();

# if AX_ASYNC_FRAME_STEP_JOBS_ENABLED
		SJobChain *const pFrameChain = AllocChains( 1 );
		AX_ASSERT_NOT_NULL( pFrameChain );

		pFrameChain->pJobs = AllocTasks( m_cWorkers );
		AX_ASSERT_NOT_NULL( pFrameChain->pJobs );

		for( uint32 i = 0; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->SubmitEnterFrameJob( *pFrameChain );
		}

		m_HeadFrameMicrosecs = System::Microseconds();
		Submit( pFrameChain );
		//WaitForAllJobs();
# else
		m_HeadFrameMicrosecs = System::Microseconds();

#if !AX_ASYNC_FRAME_STEP_JOBS_ENABLED
		m_pWorkers[ 0 ]->m_HeadCPUTimestamp = GetCPUCycles();
		Detail_v1::Notify( Detail_v1::ENotify::Frame, Detail_v1::ENotifyPhase::Enter );
#endif

		for( uint32 i = 1; i < m_cWorkers; ++i ) {
			m_pWorkers[ i ]->m_FramePhase = EFramePhase::Enter;
		}


		AX_MEMORY_BARRIER();
# endif
#else
		m_HeadFrameMicrosecs = System::Microseconds();
#endif
	}
Пример #24
0
int main(int argc, const char* argv[])
{
	#ifdef _WIN32
		//Start up Winsock…
		WSADATA wsadata;

		int error = WSAStartup(0x0202, &wsadata);
		if (error)	//Did something happen?
		{
			std::cerr<<"Unable to start winsock"<<std::endl;
			return -1;
		}

		if (wsadata.wVersion != 0x0202)//Did we get the right Winsock version?
		{
			Die("version mismatch");
		}
	#endif


	std::cout << "Enter Server URL: ";
	char url[0x100];
	std::cin.getline(url,sizeof(url));

	std::cout << "Enter your Nickname: ";
	char nickname[0x100] = ":";
	std::cin.getline(nickname+1,sizeof(nickname)-1);

	char*colon = strchr(url,':');
	std::string surl,sport;
	
	if (colon != NULL)
	{
		*colon = 0;
		sport = colon+1;
	}
	else
	{
		sport = ToString(DEFAULT_PORT);
	}
	surl = url;
	
	PrintLine("Attempting to connect to "+surl);

	ADDRINFOA hints;
	memset(&hints,0,sizeof(hints));
	hints.ai_protocol = IPPROTO_TCP;
    hints.ai_family = AF_UNSPEC;
	//hints.
	ADDRINFOA*result;
	if (getaddrinfo(surl.c_str(),sport.c_str(),&hints,&result) != 0)
	{
		Die("Call to getaddrinfo() failed");
	}

	bool connected = false;
	while (result)		//search through all available results until one allows connection. 
						//Chances are we get IPv4 and IPv6 results here but the server will only answer to one of those
	{
		sock = socket(result->ai_family,result->ai_socktype,result->ai_protocol);
		if (sock != INVALID_SOCKET)	//if we can create a socket then we can attempt a connection. It would be rather unusual for this not to work but...
		{
			if (!connect(sock,result->ai_addr,result->ai_addrlen))	//attempt connnection
			{
				//connected
				PrintLine("Connected to "+ToString(*result));	//yay, it worked
				connected = true;
				break;
			}
			else
			{
				closesocket(sock);		//these aren't the droids we're looking for.
				sock = INVALID_SOCKET;
			}

		}
		
		result = result->ai_next;	//moving on.
	}
	if (!connected)
		Die("Failed to connect to "+surl+":"+sport);	//so, yeah, none of them worked.

	Submit(nickname);	//includes leading ':', so that the server knows this is a name, not a message

	netThread = std::thread(NetLoop);	//start read-thread
	
	while (sock != INVALID_SOCKET)
	{
		char c = _getch();	//keep reading characters
		{
			if (c == 3)	//this only works on windows, but ctrl-c is handled better on linux anyway
			{
				Die("Ctrl+C");
				break;
			}
			consoleLock.lock();
			if (c == '\n' || c == '\r')							//user pressed enter/return:
			{
				std::string submit = inputBuffer;				//copy buffer to string
				std::cout << '\r';								//move cursor to line beginning
				for (size_t i = 0; i < inputBufferUsage+1; i++)	//overwrite line with as many blanks as there were characters
					std::cout << ' ';
				std::cout << '\r';								//move cursor to line beginning again
				inputBufferUsage = 0;							//reset character pointer
				inputBuffer[0] = 0;								//write terminating zero to first char
				consoleLock.unlock();							//release console lock
			
				Submit(submit);									//process input
			}
			else
			{
				if (c == Backspace)										//user pressed backspace
				{
					if (inputBufferUsage > 0)
					{
						inputBuffer[--inputBufferUsage] = 0;	//decrement character pointer and overwrite with 0
						std::cout << '\r'<<':'<<inputBuffer<<" \r"<<':'<<inputBuffer;
					}
				}
				else
				{
					if (c == '!' || c == '?' || ( c != -32 && (isalnum(c) || c == ' ')))	//ordinary character
					{
						if (inputBufferUsage+1 < maxInputBufferUsage)	//only allow up to 255 characters though
						{
							inputBuffer[inputBufferUsage++] = c;	//write to the end of the buffer
							inputBuffer[inputBufferUsage] = 0;		//and terminate properly
						}
						std::cout << c;		//update console
					}
				}
				consoleLock.unlock();
			}
		}
	}
	netThread.join();
	netThread.detach();
	netThread.swap(std::thread());
	#ifdef _WIN32
		WSACleanup();
	#endif
	return 0;
}
Пример #25
0
void D3D12CommandQueue::WaitIdle()
{
    /* Submit intermediate fence and wait for it to be signaled */
    Submit(intermediateFence_);
    WaitFence(intermediateFence_, ~0ull);
}
Пример #26
0
void ClientAgent::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
	// 22/8/99: this will now look for "text" to add to the
	// fInput view. -jamie
	case M_INPUT_FOCUS: {
		if (msg->HasString("text")) {
			BString newtext;
			newtext = fInput->Text();
			newtext.Append(msg->FindString("text"));
			fInput->SetText(newtext.String());
		}
		fInput->MakeFocus(true);
		// We don't like your silly selecting-on-focus.
		fInput->TextView()->Select(fInput->TextView()->TextLength(),
								   fInput->TextView()->TextLength());
	} break;

	case M_CLIENT_QUIT: {
		if (fIsLogging && !(msg->HasBool("vision:shutdown") && msg->FindBool("vision:shutdown"))) {
			BMessage logMessage(M_UNREGISTER_LOGGER);
			logMessage.AddString("name", fId.String());
			fSMsgr.SendMessage(&logMessage);
		}

		BMessage deathchant(M_CLIENT_SHUTDOWN);
		deathchant.AddPointer("agent", this);
		fSMsgr.SendMessage(&deathchant);

	} break;

	case M_THEME_FOREGROUND_CHANGE: {
		int16 which(msg->FindInt16("which"));
		if (which == C_INPUT || which == C_INPUT_BACKGROUND) {
			fActiveTheme->ReadLock();
			rgb_color fInputColor(fActiveTheme->ForegroundAt(C_INPUT));
			fInput->TextView()->SetFontAndColor(&fActiveTheme->FontAt(F_INPUT), B_FONT_ALL,
												&fInputColor);
			fInput->TextView()->SetViewColor(fActiveTheme->ForegroundAt(C_INPUT_BACKGROUND));
			fActiveTheme->ReadUnlock();
			fInput->TextView()->Invalidate();
		}
	} break;

	case M_THEME_FONT_CHANGE: {
		int16 which(msg->FindInt16("which"));
		if (which == F_INPUT) {
			fActiveTheme->ReadLock();
			rgb_color fInputColor(fActiveTheme->ForegroundAt(C_INPUT));
			fInput->TextView()->SetFontAndColor(&fActiveTheme->FontAt(F_INPUT), B_FONT_ALL,
												&fInputColor);
			fActiveTheme->ReadUnlock();
			Invalidate();
		}
	} break;

	case M_STATE_CHANGE: {
		if (msg->HasBool("bool")) {
			bool shouldStamp(vision_app->GetBool("timestamp"));
			if (fTimeStampState != shouldStamp) {
				if ((fTimeStampState = shouldStamp))
					fText->SetTimeStampFormat(vision_app->GetString("timestamp_format"));
				else
					fText->SetTimeStampFormat(NULL);
			}

			bool shouldLog = vision_app->GetBool("log_enabled");

			if (fIsLogging != shouldLog) {
				if ((fIsLogging = shouldLog)) {
					BMessage logMessage(M_REGISTER_LOGGER);
					logMessage.AddString("name", fId.String());
					fSMsgr.SendMessage(&logMessage);
				} else {
					BMessage logMessage(M_UNREGISTER_LOGGER);
					logMessage.AddString("name", fId.String());
					fSMsgr.SendMessage(&logMessage);
				}
			}
		} else if (msg->HasBool("string")) {
			BString which(msg->FindString("which"));
			if (which == "timestamp_format")
				fText->SetTimeStampFormat(vision_app->GetString("timestamp_format"));
		}
	} break;

	case M_SUBMIT_INPUT: {
		fCancelMLPaste = false;
		int32 which(0);

		msg->FindInt32("which", &which);

		if (msg->HasPointer("invoker")) {
			BInvoker* invoker(NULL);
			msg->FindPointer("invoker", reinterpret_cast<void**>(&invoker));
			delete invoker;
		}

		switch (which) {
		case PASTE_CANCEL:
			break;

		case PASTE_MULTI:
		case PASTE_MULTI_NODELAY: {
			BMessage* buffer(new BMessage(*msg));
			thread_id tid;

			// if there is some text in the input control already, submit it before
			// starting the timed paste
			if (fInput->TextView()->TextLength() != 0) {
				BString inputData(fInput->TextView()->Text());
				Submit(inputData.String(), true, true);
			}

			buffer->AddPointer("agent", this);
			buffer->AddPointer("window", Window());
			if (which == PASTE_MULTI_NODELAY) buffer->AddBool("delay", false);
			tid = spawn_thread(TimedSubmit, "Timed Submit", B_LOW_PRIORITY, buffer);
			resume_thread(tid);
		} break;

		case PASTE_SINGLE: {
			BString buffer;
			for (int32 i = 0; msg->HasString("data", i); ++i) {
				const char* data;
				msg->FindString("data", i, &data);
				buffer += (i ? " " : "");
				buffer += data;
			}

			int32 start, finish;

			if (msg->FindInt32("selstart", &start) == B_OK) {
				msg->FindInt32("selend", &finish);
				if (start != finish) fInput->TextView()->Delete(start, finish);

				if ((start == 0) && (finish == 0)) {
					fInput->TextView()->Insert(fInput->TextView()->TextLength(), buffer.String(),
											   buffer.Length());
					fInput->TextView()->Select(fInput->TextView()->TextLength(),
											   fInput->TextView()->TextLength());
				} else {
					fInput->TextView()->Insert(start, buffer.String(), buffer.Length());
					fInput->TextView()->Select(start + buffer.Length(), start + buffer.Length());
				}
			} else {
				fInput->TextView()->Insert(buffer.String());
				fInput->TextView()->Select(fInput->TextView()->TextLength(),
										   fInput->TextView()->TextLength());
			}
			fInput->TextView()->ScrollToSelection();
		} break;

		default:
			break;
		}
	} break;

	case M_PREVIOUS_INPUT: {
		fHistory->PreviousBuffer(fInput);
	} break;

	case M_NEXT_INPUT: {
		fHistory->NextBuffer(fInput);
	} break;

	case M_SUBMIT: {
		const char* buffer(NULL);
		bool clear(true), add2history(true);

		msg->FindString("input", &buffer);

		if (msg->HasBool("clear")) msg->FindBool("clear", &clear);

		if (msg->HasBool("history")) msg->FindBool("history", &add2history);

		Submit(buffer, clear, add2history);
	} break;

	case M_LAG_CHANGED: {
		msg->FindString("lag", &fMyLag);

		if (!IsHidden())
			vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_LAG, fMyLag.String());
	} break;

	case M_DISPLAY: {
		const char* buffer;

		for (int32 i = 0; msg->HasMessage("packed", i); ++i) {
			BMessage packed;

			msg->FindMessage("packed", i, &packed);
			packed.FindString("msgz", &buffer);
			Display(buffer, packed.FindInt32("fore"), packed.FindInt32("back"),
					packed.FindInt32("font"));
		}
	} break;

	case M_CHANNEL_MSG: {
		BString theNick;
		const char* theMessage(NULL);
		bool hasNick(false);
		bool isAction(false);
		BString knownAs;

		msg->FindString("nick", &theNick);
		msg->FindString("msgz", &theMessage);

		BString tempString;
		BString nickString;

		if (theMessage[0] == '\1') {
			BString aMessage(theMessage);
			aMessage.RemoveFirst("\1ACTION ");
			aMessage.RemoveLast("\1");

			tempString = " ";
			tempString += aMessage;
			tempString += "\n";

			nickString = "* ";
			nickString += theNick;
			isAction = true;
		} else {
			Display("<", theNick == fMyNick ? C_MYNICK : C_NICK);
			Display(theNick.String(), C_NICKDISPLAY);
			Display(">", theNick == fMyNick ? C_MYNICK : C_NICK);
			tempString += " ";
			tempString += theMessage;
			tempString += '\n';
		}

		// scan for presence of nickname, highlight if present
		if (theNick != fMyNick) FirstKnownAs(tempString, knownAs, &hasNick);

		tempString.Prepend(nickString);

		int32 dispColor = C_TEXT;
		if (hasNick) {
			BWindow* window(NULL);
			dispColor = C_MYNICK;
			if ((window = Window()) != NULL && !window->IsActive())
				system_beep(kSoundEventNames[(uint32)seNickMentioned]);
		} else if (isAction)
			dispColor = C_ACTION;

		Display(tempString.String(), dispColor);
	} break;

	case M_CHANGE_NICK: {
		const char* oldNick(NULL);

		msg->FindString("oldnick", &oldNick);

		if (fMyNick.ICompare(oldNick) == 0) fMyNick = msg->FindString("newnick");

		BMessage display;
		if (msg->FindMessage("display", &display) == B_NO_ERROR)
			ClientAgent::MessageReceived(&display);
	} break;

	case M_LOOKUP_WEBSTER: {
		BString lookup;
		msg->FindString("string", &lookup);
		lookup = StringToURI(lookup.String());
		lookup.Prepend("http://www.m-w.com/cgi-bin/dictionary?va=");
		vision_app->LoadURL(lookup.String());
	} break;

	case M_LOOKUP_GOOGLE: {
		BString lookup;
		msg->FindString("string", &lookup);
		lookup = StringToURI(lookup.String());
		lookup.Prepend("http://www.google.com/search?q=");
		vision_app->LoadURL(lookup.String());
	} break;

	case M_LOOKUP_ACRONYM: {
		BString lookup;
		msg->FindString("string", &lookup);
		lookup = StringToURI(lookup.String());
		lookup.Prepend("http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=");
		lookup.Append("&Find=Find");
		vision_app->LoadURL(lookup.String());
	} break;

	case B_ESCAPE:
		fCancelMLPaste = true;
		break;

	case M_DCC_COMPLETE: {
		/// set up ///
		BString nick, file, size, type, completionMsg("[@] "), fAck;
		int32 rate, xfersize;
		bool completed(true);

		msg->FindString("nick", &nick);
		msg->FindString("file", &file);
		msg->FindString("size", &size);
		msg->FindString("type", &type);
		msg->FindInt32("transferred", &xfersize);
		msg->FindInt32("transferRate", &rate);

		BPath pFile(file.String());

		fAck << xfersize;

		if (size.ICompare(fAck)) completed = false;

		/// send mesage ///
		if (completed)
			completionMsg << S_CLIENT_DCC_SUCCESS;
		else
			completionMsg << S_CLIENT_DCC_FAILED;

		if (type == "SEND")
			completionMsg << S_CLIENT_DCC_SENDTYPE << pFile.Leaf() << S_CLIENT_DCC_TO;
		else
			completionMsg << S_CLIENT_DCC_RECVTYPE << pFile.Leaf() << S_CLIENT_DCC_FROM;

		completionMsg << nick << " (";

		if (!completed) completionMsg << fAck << "/";

		completionMsg << size << S_CLIENT_DCC_SIZE_UNITS "), ";
		completionMsg << rate << S_CLIENT_DCC_SPEED_UNITS "\n";

		Display(completionMsg.String(), C_CTCP_RPY);
	} break;

	default:
		BView::MessageReceived(msg);
	}
}
Пример #27
0
bool ReplicatedKeyspaceDB::Add(KeyspaceOp* op)
{
	uint64_t storedPaxosID, storedCommandID;
	ByteString userValue;
	
	// don't allow writes for @@ keys
	if (op->IsWrite() && op->key.length > 2 &&
		op->key.buffer[0] == '@' && op->key.buffer[1] == '@')
			return false;
	// don't allow writes for !! keys
	if (op->IsWrite() && op->key.length > 2 &&
		op->key.buffer[0] == '!' && op->key.buffer[1] == '!')
			return false;

	if (catchingUp)
		return false;
	
	// reads are handled locally, they don't have to
	// be added to the ReplicatedLog
	if (op->IsGet())
	{
		// only handle GETs if I'm the master and
		// it's safe to do so (I have NOPed)
		if (op->type == KeyspaceOp::GET &&
		   (!RLOG->IsMaster() || !RLOG->IsSafeDB()))
			return false;
				
		op->value.Allocate(KEYSPACE_VAL_SIZE);
		op->status = table->Get(NULL, op->key, rdata);
		if (op->status)
		{
			ReadValue(rdata, storedPaxosID, storedCommandID, userValue);
			op->value.Set(userValue);
		}
		op->service->OnComplete(op);
		return true;
	}
	
	if (op->IsList() || op->IsCount())
	{
		if ((op->type == KeyspaceOp::LIST ||
		op->type == KeyspaceOp::LISTP ||
		op->type == KeyspaceOp::COUNT) &&
		(!RLOG->IsMaster() || !RLOG->IsSafeDB()))
			return false;

		AsyncListVisitor *alv = new AsyncListVisitor(op);
		MultiDatabaseOp* mdbop = new AsyncMultiDatabaseOp();
		mdbop->Visit(table, *alv);
		dbReader.Add(mdbop);
		return true;
	}
	
	// only handle writes if I'm the master
	if (!RLOG->IsMaster())
		return false;
	
	if (op->IsExpiry())
		expiryAdded = true;
	
	ops.Append(op);

	// TODO: huge hack
	if (estimatedLength < PAXOS_SIZE)
	{
		tmp.FromKeyspaceOp(op);
		if (tmp.Write(tmpBuffer))
			estimatedLength += tmpBuffer.length;
	}
	
	if (estimatedLength >= PAXOS_SIZE)
		Submit();
	
	return true;
}
Пример #28
0
	void SingleAccAuth::rotateSubmitQueue ()
	{
		if (!Queue_.isEmpty ())
			Submit (Queue_.takeFirst ());
	}
Пример #29
0
void if1ld(charStarQueue** if1Files,
           char* mono,
           char* bindir,
           int warning,
           int profile,

           int forFortran,
           int forC,
	   int separateCompilation,

           charStarQueue** entries,
           charStarQueue** entriesForC,
           charStarQueue** entriesForFORTRAN,
           charStarQueue** reductionFunctions,


           char* QStamps
           ) {
   char loader[MAXPATHLEN];
   charStarQueue* argv = 0;
   char* entry = 0;

   sprintf(loader,"%s/if1ld",bindir);
   enqueue(&argv,loader);
   enqueue(&argv,"-o");
   enqueue(&argv,mono);

   if ( forFortran ) {
      enqueue(&argv,"-F");
   } else if ( forC ) {
      enqueue(&argv,"-C");
   } else {
      /* enqueue(&argv,"-S"); */
   }
   if ( !warning ) enqueue(&argv,"-w");
   if ( profile ) enqueue(&argv,"-W");
   if ( forFortran ) enqueue(&argv,"-F");
   if ( forC ) enqueue(&argv,"-C");
   if ( separateCompilation ) enqueue(&argv,"-S");
   while(entries && *entries) {
      entry = dequeue(entries);
      enqueue(&argv,"-e");
      enqueue(&argv,entry);
   }
   while(entriesForC && *entriesForC) {
      entry = dequeue(entriesForC);
      enqueue(&argv,"-c");
      enqueue(&argv,entry);
   }
   while(entriesForFORTRAN && *entriesForFORTRAN) {
      entry = dequeue(entriesForC);
      enqueue(&argv,"-f");
      enqueue(&argv,entry);
   }

   while(reductionFunctions && *reductionFunctions) {
      entry = dequeue(reductionFunctions);
      enqueue(&argv,"-r");
      enqueue(&argv,entry);
   }

   enqueue(&argv,QStamps);

   while(if1Files && *if1Files) {
      entry = dequeue(if1Files);
      enqueue(&argv,entry);
   }

   if ( Submit(&argv) != 0 ) {
      compilerError("if1 loader failure");
   }
}