static void test_logger_multi_threads() { ELoggerManager::init("log4e.properties"); class ThreadX : public EThread { public: virtual void run() { long i = 0; while (true) { ENDC ndc("abc"); EMDC mdc("x1", "v1"); mdc.put("x2", "v2"); ELOG_I(logger, "i=%d", i++); ELOG_W(logger, "i=%d", i++); ELOG_E(logger, "i=%d", i++); EThread::sleep(100); } } }; EArray<ThreadX*> arr; for (int i = 0; i < 10; i++) { ThreadX* thread = new ThreadX(); arr.add(thread); thread->start(); } while (true) { ELoggerManager::flushConfig(); //! EThread::sleep(50); } for (int i = 0; i < arr.size(); i++) { ThreadX* thread = arr.getAt(i); thread->join(100); } }
//---------------------------------------------------------------------------- BspTree2::BspTree2 (BspPolygon2& polygon, const EArray& edges) { assertion(edges.size() > 0, "Invalid input.\n"); // Construct splitting line from first edge. Vector2d end0 = polygon.mVArray[edges[0].I0]; Vector2d end1 = polygon.mVArray[edges[0].I1]; // Add edge to coincident list. mCoincident.push_back(edges[0]); // Split remaining edges. EArray posArray, negArray; int imax = (int)edges.size(); for (int i = 1; i < imax; ++i) { int v0 = edges[i].I0; int v1 = edges[i].I1; Vector2d vertex0 = polygon.mVArray[v0]; Vector2d vertex1 = polygon.mVArray[v1]; Vector2d intr; int vmid; switch (Classify(end0, end1, vertex0, vertex1, intr)) { case TRANSVERSE_POSITIVE: // modify edge <V0,V1> to <V0,I> and add new edge <I,V1> vmid = polygon.InsertVertex(intr); polygon.SplitEdge(v0, v1, vmid); posArray.push_back(Edge2(vmid, v1)); negArray.push_back(Edge2(v0, vmid)); break; case TRANSVERSE_NEGATIVE: // modify edge <V0,V1> to <V0,I> and add new edge <I,V1> vmid = polygon.InsertVertex(intr); polygon.SplitEdge(v0, v1, vmid); posArray.push_back(Edge2(v0, vmid)); negArray.push_back(Edge2(vmid, v1)); break; case ALL_POSITIVE: posArray.push_back(edges[i]); break; case ALL_NEGATIVE: negArray.push_back(edges[i]); break; default: // COINCIDENT mCoincident.push_back(edges[i]); break; } } if (posArray.size() > 0) { mPosChild = new0 BspTree2(polygon, posArray); } else { mPosChild = 0; } if (negArray.size() > 0) { mNegChild = new0 BspTree2(polygon, negArray); } else { mNegChild = 0; } }
void Stat::GetSummaryArray(EArray& arr) { arr.setZero(num_topic_); for (int k = 0; k < num_topic_; ++k) arr(k) = summary_[k]; }