void Thread::runThread()
{
  char buffer[1024];
#if defined(_SYSTEM_WIN32_)
  icl_core::os::snprintf(buffer, 1023, "%s, %lu", getDescription().c_str(), threadId());
#elif defined(_SYSTEM_DARWIN_)
  icl_core::os::snprintf(buffer, 1023, "%s, %p", getDescription().c_str(), threadId().m_thread_id);
#else
  icl_core::os::snprintf(buffer, 1023, "%s, %lu", getDescription().c_str(), threadId().m_thread_id);
#endif
  m_thread_info = buffer;

  LOGGING_TRACE_CO(IclCoreThread, Thread, threadInfo(), "Begin." << endl);

  m_thread_mutex.lock();
  m_execute = true;
  m_starting = false;
  m_finished = false;

  // If this is actually a periodic thread, this call makes it periodic.
  // It this is a "normal" thread, this call does nothing.
  makePeriodic();

  // Call the run loop.
  run();

  m_execute = false;
  m_thread_mutex.unlock();
  m_finished = true;

  LOGGING_TRACE_CO(IclCoreThread, Thread, threadInfo(), "Done." << endl);
}
Ejemplo n.º 2
0
void CT_StartAppTestStep::TestStartApp9L()
	{
	INFO_PRINTF1(_L("Test to check the StartApp API with forced memory failures..."));
	CApaCommandLine* cmdLn=CApaCommandLine::NewLC();
	TFileName filename;
	TThreadId threadId(0);
	TInt fail;
	_LIT(KLitExePath,"\\sys\\bin\\texe.exe");
	TFullName exePath(KLitExePath);
	filename = SearchAndReturnCompleteFileName(exePath);	
	cmdLn->SetExecutableNameL(filename);
	TInt ret = KErrNoMemory;
	//Without the fix for the Incident INC104463, the OOM test causes panic 
	//KERN-EXEC 56.	
	for(fail=1; ret == KErrNoMemory; fail++)
		{	
		__UHEAP_SETFAIL(RHeap::EDeterministic, fail);
		__UHEAP_MARK;
		ret = iApaLsSession.StartApp(*cmdLn, threadId);
		__UHEAP_MARKEND;
		__UHEAP_RESET;
		TEST((ret==KErrNoMemory || ret==KErrNone));
		if(ret == KErrNone)
			{
			TEST(threadId.Id() != 0);
			}
		}	
	INFO_PRINTF3(_L("Iteration count is %d and the value of return is %d "),fail-1 ,ret);
	CleanupStack::PopAndDestroy(cmdLn); 
	INFO_PRINTF1(KCompleted);
	}
Ejemplo n.º 3
0
INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam, LPARAM)
{
	ptrT idT(wParam ? getTStringA(wParam, "ChatRoomID") : NULL);

	GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
	gcd.ptszID = idT;

	GCEVENT gce = { sizeof(gce), &gcd };
	gce.time = ::time(NULL);

	CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
	CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, reinterpret_cast<LPARAM>(&gce));

	if (!wParam) {
		facy.clear_chatrooms();
	}
	else if (!IsSpecialChatRoom(wParam)) {
		ptrA threadId(getStringA(wParam, FACEBOOK_KEY_TID));
		if (!threadId)
			return 0;

		auto it = facy.chat_rooms.find(std::string(threadId));
		if (it != facy.chat_rooms.end()) {
			delete it->second;
			facy.chat_rooms.erase(it);
		}
	}

	return 0;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------
// clean
// Purpose : Clean the message object to make it ready for reuse.
// Caller must lock.
//------------------------------------------------------------------------
void CxaTM_RMMessage::clean()
{
   iv_msgid = 0;
   threadId(-1);
   iv_sendAttempts = 0;
   iv_sleepTime = XATM_MSG_INIT_SLEEPTIME;
   memset(&iv_xid, 0, sizeof(iv_xid));
   memset(ip_req, 0, sizeof(RM_Req_Msg_Type));
   memset(ip_rsp, 0, sizeof(RM_Rsp_Msg_Type));
} //CxaTM_RMMessage::clean
Ejemplo n.º 5
0
  void operator()() {
    id = threadId();
    wait();
    // ++j;
    j = getJ()+1;
    std::cout << "Hello " << "World " << "from "
	      << id // std::this_thread::get_id() 
              << " where j is " << j 
              << " start is " << Hi::start << std::endl;    
  }
Ejemplo n.º 6
0
TInt RTestApaLsSession::TestExeRecognizerL(const CApaCommandLine& aCommandLine)
	{
	TThreadId dummyThreadId;
	TPckg<TThreadId> threadId(dummyThreadId);
	const TInt opcode=EAppListServStartAppWithoutReturningThreadId;
	TIpcArgs ipcArgs;
	aCommandLine.GetIpcArgsLC(ipcArgs);
	ipcArgs.Set(CApaCommandLine::EIpcFirstFreeSlot, &threadId);
	User::LeaveIfError(SendReceive(opcode, ipcArgs));
	CleanupStack::PopAndDestroy(); // the TIpcArgs
	return KErrNone;
	}
Ejemplo n.º 7
0
//------------------------------------------------------------------------
// initialize
// Purpose : initialize or reinitialize the message object.
//------------------------------------------------------------------------
void CxaTM_RMMessage::initialize(CxaTM_RM *pp_RM, 
                                 TM_DP2_SQ_MSG_TYPE pv_req_type, 
                                 int32 pv_reqLen, int32 pv_rspLen)
{
   lock();
   clean();
   threadId(SB_Thread::Sthr::self_id());
   ip_RM = pp_RM;
   iv_reqLen = pv_reqLen;
   iv_rspLen = pv_rspLen;

   ip_req->iv_msg_hdr.dialect_type = DIALECT_TM_DP2_SQ;
   ip_req->iv_msg_hdr.rr_type.request_type = (short) pv_req_type;
   ip_req->iv_msg_hdr.version.request_version = TM_SQ_MSG_VERSION_CURRENT;
   ip_req->iv_msg_hdr.miv_err.minimum_interpretation_version = TM_SQ_MSG_VERSION_CURRENT;
   unlock();
}
Ejemplo n.º 8
0
INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM)
{
	if (!m_enableChat || IsSpecialChatRoom(hContact))
		return 0;

	ptrT idT(getTStringA(hContact, "ChatRoomID"));
	ptrT nameT(getTStringA(hContact, "Nick"));
	ptrA threadId(getStringA(hContact, FACEBOOK_KEY_TID));

	if (!idT || !nameT || !threadId)
		return 0;

	facebook_chatroom *fbc;
	std::string tthread_id = threadId;

	auto it = facy.chat_rooms.find(tthread_id);
	if (it != facy.chat_rooms.end()) {
		fbc = it->second;
	}
	else {
		// We don't have this chat loaded in memory yet, lets load some info (name, list of users)
		fbc = new facebook_chatroom(tthread_id);
		LoadChatInfo(fbc);
		facy.chat_rooms.insert(std::make_pair(tthread_id, fbc));
	}

	// RM TODO: better use check if chatroom exists/is in db/is online... no?
	// like: if (ChatIDToHContact(tthread_id) == NULL) {
	ptrA users(GetChatUsers(tthread_id.c_str()));
	if (users == NULL) {
		// Add chatroom
		AddChat(fbc->thread_id.c_str(), fbc->chat_name.c_str());

		// Add chat contacts
		for (std::map<std::string, std::string>::iterator jt = fbc->participants.begin(); jt != fbc->participants.end(); ++jt) {
			AddChatContact(fbc->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
		}

		// Load last messages
		delSetting(hContact, FACEBOOK_KEY_MESSAGE_ID); // We're creating new chatroom so we want load all recent messages
		ForkThread(&FacebookProto::LoadLastMessages, new MCONTACT(hContact));
	}

	return 0;
}
/*! Returns the ID of this thread.
 *  \deprecated Obsolete coding style.
 */
icl_core::ThreadId Thread::ThreadId() const
{
  return threadId();
}