示例#1
0
bool ItemJSBinding::addExtender(ChromiumDLL::JavaScriptExtenderI* extender)
{
	if (!extender)
		return false;

	bool found = false;

	g_ItemLock.lock();

	for (size_t x=0; x<g_vExtenderList.size(); x++)
	{
		if (g_vExtenderList[x] == extender)
		{
			found = true;
			break;
		}
	}

	if (!found)
		g_vExtenderList.push_back(extender);

	g_ItemLock.unlock();

	return !found;
}
示例#2
0
// master线程等待所有线程初始化完成
void wait_for_thread_init() {
    s_init_lock.Hold();
    while (s_init_count < s_net_setting.net_thread_num_) {
        pthread_cond_wait(&s_init_cond, &s_init_lock.GetMutex());
    }
    s_init_lock.Release();
}
示例#3
0
uint32 ItemJSBinding::AddItem(ScriptCoreItemI* item)
{
	uint32 hash = UTIL::MISC::RSHash_CSTR(gcString("{0}", (uint64)item));

	g_ItemLock.lock();
	g_ItemMap[hash] = item;
	g_ItemLock.unlock();

	return hash;
}
示例#4
0
void ItemJSBinding::RemoveItem(uint32 itemId)
{
	g_ItemLock.lock();

	auto it = g_ItemMap.find(itemId);

	if (it != g_ItemMap.end())
		g_ItemMap.erase(it);

	g_ItemLock.unlock();
}
示例#5
0
ScriptCoreItemI* ItemJSBinding::GetItem(uint32 itemId)
{
	ScriptCoreItemI* ret = NULL;

	g_ItemLock.lock();

	auto it = g_ItemMap.find(itemId);

	if (it != g_ItemMap.end())
		ret= it->second;

	g_ItemLock.unlock();

	return ret;
}
示例#6
0
 // Called after a fork(), when we know we're alone again, to get
 // everything back in the proper order.
 void reinit() {
   mutex_.init();
   waiting_to_stop_.init();
   waiting_to_run_.init();
   pending_threads_ = 1;
   should_stop_ = false;
 }
示例#7
0
const char* ItemJSBinding::getRegistrationCode()
{
	DesuraJSBase<ItemJSBinding>::getRegistrationCode();

	g_ItemLock.lock();

	for (size_t x=0; x<g_vExtenderList.size(); x++)
	{
		const char* code = g_vExtenderList[x]->getRegistrationCode();
		m_szRegCode.append(code);
	}

	g_ItemLock.unlock();

	return m_szRegCode.c_str();
}
示例#8
0
JSObjHandle ItemJSBinding::execute(ChromiumDLL::JavaScriptFunctionArgs* args)
{
	JSObjHandle ret =  DesuraJSBase<ItemJSBinding>::execute(args);
	
	if (!ret->isException() || g_vExtenderList.empty())
		return ret;

	g_ItemLock.lock();

	for (size_t x=0; x<g_vExtenderList.size(); x++)
	{
		ret = g_vExtenderList[x]->execute(args);

		if (!ret->isException())
			break;
	}

	g_ItemLock.unlock();
	return ret;
}
示例#9
0
    void restart() {
      mutex_.init();
      condition_.init();
      pause_condition_.init();

      state = cUnknown;
      stop_ = false;
      pause_ = false;
      paused_ = false;

      run();
    }
示例#10
0
	void log(const std::string& message)
	{
		mutex.lock();
		os << "logger: " << message << "\n";
		mutex.unlock();
	}
示例#11
0
void WildcardManager::needSpecial(WCSpecialInfo *info)
{
	m_WCMutex.lock();
	onNeedSpecialEvent(*info);
	m_WCMutex.unlock();
}
示例#12
0
// worker线程初始化完成后通知master线程
void register_thread_init() {
    s_init_lock.Hold();
    ++s_init_count;
    pthread_cond_signal(&s_init_cond);
    s_init_lock.Release();
}