private Init ( int room_id, int scene_type, |
||
room_id | int | |
scene_type | int | |
userpool | ||
conn | ||
return | bool |
internal void ActiveFieldRoom(int roomid, int sceneId) { LogSys.Log(LOG_TYPE.INFO, "[0] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); Room rm = room_pool_.NewRoom(); if (null == rm) { Interlocked.Decrement(ref preactive_room_count_); LogSys.Log(LOG_TYPE.ERROR, "Failed active field room {0} in thread {1}, preactive room count {2}", roomid, cur_thread_id_, preactive_room_count_); return; } LogSys.Log(LOG_TYPE.INFO, "[1] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); rm.ScenePool = scene_pool_; rm.Init(roomid, sceneId, user_pool_, connector_); LogSys.Log(LOG_TYPE.INFO, "[2] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); rm.IsFieldRoom = true; LogSys.Log(LOG_TYPE.INFO, "[3] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); //工作全部完成后再加到激活房间列表,开始tick active_room_.Add(rm); Interlocked.Decrement(ref preactive_room_count_); LogSys.Log(LOG_TYPE.DEBUG, "active field room {0} in thread {1}, preactive room count {2}", roomid, cur_thread_id_, preactive_room_count_); }
internal void ActiveRoom(int roomid, int sceneId, MyAction <bool> callbackOnFinish) { LogSys.Log(LOG_TYPE.INFO, "[0] active room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); Room rm = room_pool_.NewRoom(); if (null == rm) { //由于并发原因,有可能lobby或主线程会多发起一些房间激活。 //我们通过预留一定数量的房间来降低这种情形发生的概率。 Interlocked.Decrement(ref preactive_room_count_); if (null != callbackOnFinish) { callbackOnFinish(false); } LogSys.Log(LOG_TYPE.ERROR, "Failed active room {0} in thread {1}, preactive room count {2}", roomid, cur_thread_id_, preactive_room_count_); return; } LogSys.Log(LOG_TYPE.INFO, "[1] active room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); rm.ScenePool = scene_pool_; rm.Init(roomid, sceneId, user_pool_, connector_); LogSys.Log(LOG_TYPE.INFO, "[2] active room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_); /* * //临时添加测试观察者 * for (int obIx = 0; obIx < 5; ++obIx) { * uint key = 0xf0000000 + (uint)((roomid << 4) + obIx); * string observerName = "Observer_" + key; * if (rm.AddObserver(key, observerName, key)) { * LogSys.Log(LOG_TYPE.DEBUG, "Add room observer successed, guid:{0} name:{1} key:{2}", key, observerName, key); * } else { * LogSys.Log(LOG_TYPE.DEBUG, "Add room observer failed, guid:{0} name:{1} key:{2}", key, observerName, key); * } * } */ //工作全部完成后再加到激活房间列表,开始tick active_room_.Add(rm); Interlocked.Decrement(ref preactive_room_count_); if (null != callbackOnFinish) { callbackOnFinish(true); } LogSys.Log(LOG_TYPE.DEBUG, "active room {0} in thread {1}, preactive room count {2}", roomid, cur_thread_id_, preactive_room_count_); }