kezhenxu94 commented on a change in pull request #4220: sniffer processing profile task and report status and snapshot URL: https://github.com/apache/skywalking/pull/4220#discussion_r367944277
########## File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskExecutionContext.java ########## @@ -58,4 +182,27 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(task); } + + private boolean tryToAttemptProfiling(TracingContext tracingContext, ID traceSegmentId, String firstSpanOPName, int currentUsingSlotCount) { + // if out limit started profiling count then stop add profiling + if (totalStartedProfilingCount.get() > task.getMaxSamplingCount()) { + return false; + } + + // try to occupy slot + if (!currentProfilingCount.compareAndSet(currentUsingSlotCount, currentUsingSlotCount + 1)) { + return false; + } + + final ThreadProfiler segmentContext = new ThreadProfiler(tracingContext, traceSegmentId, Thread.currentThread(), this); + for (int slot = 0; slot < profilingSegmentSlots.length; slot++) { + if (profilingSegmentSlots[slot] == null) { + profilingSegmentSlots[slot] = segmentContext; + + profilingSegmentSlots = profilingSegmentSlots; Review comment: And this one ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services