Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 9938 Details for
Bug 59909
CFlowStack removesThreads to late
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch which solves the problem
CFlowStack.java (text/plain), 3.70 KB, created by
Arno Schmidmeier
on 2004-04-26 05:41:01 EDT
(
hide
)
Description:
Patch which solves the problem
Filename:
MIME Type:
Creator:
Arno Schmidmeier
Created:
2004-04-26 05:41:01 EDT
Size:
3.70 KB
patch
obsolete
>/* ******************************************************************* > * Copyright (c) 1999-2001 Xerox Corporation, > * 2002 Palo Alto Research Center, Incorporated (PARC). > * All rights reserved. > * This program and the accompanying materials are made available > * under the terms of the Common Public License v1.0 > * which accompanies this distribution and is available at > * http://www.eclipse.org/legal/cpl-v10.html > * > * Contributors: > * Xerox/PARC initial implementation > * Arno Schmidmeier improved cleanup handling > * ******************************************************************/ > > >package org.aspectj.runtime.internal; > >import org.aspectj.lang.NoAspectBoundException; >import org.aspectj.runtime.CFlow; > >import java.util.Stack; >import java.util.Hashtable; >import java.util.Enumeration; > >public class CFlowStack { > private Hashtable stacks = new Hashtable(); > private Thread cached_thread; > private Stack cached_stack; > private int change_count = 0; > private static final int COLLECT_AT = 20000; > private static final int MIN_COLLECT_AT = 100; > private int oldsize=1; > > private synchronized Stack getThreadStack() { > if (Thread.currentThread() != cached_thread) { > cached_thread = Thread.currentThread(); > cached_stack = (Stack)stacks.get(cached_thread); > if (cached_stack == null) { > cached_stack = new Stack(); > stacks.put(cached_thread, cached_stack); > } > change_count++; > // Collect more often if there are many threads, but not *too* often > int size = Math.max(1, stacks.size()); // should be >1 b/c always live threads, but... > if (doesNeedCleanUp(size)) { > cleanupThreadStack(); > } > } > return cached_stack; > } > > private boolean doesNeedCleanUp(int size) { > if (oldsize<size) > return true; > return change_count > Math.max(MIN_COLLECT_AT, COLLECT_AT/size); > } > > private void cleanupThreadStack() { > Stack dead_stacks = new Stack(); > for (Enumeration e = stacks.keys(); e.hasMoreElements(); ) { > Thread t = (Thread)e.nextElement(); > if (!t.isAlive()) dead_stacks.push(t); > } > for (Enumeration e = dead_stacks.elements(); e.hasMoreElements(); ) { > Thread t = (Thread)e.nextElement(); > stacks.remove(t); > } > change_count = 0; > oldsize=stacks.size(); > } > > //XXX dangerous, try to remove > public void push(Object obj) { > getThreadStack().push(obj); > } > > public void pushInstance(Object obj) { > getThreadStack().push(new CFlow(obj)); > } > > public void push(Object[] obj) { > getThreadStack().push(new CFlowPlusState(obj)); > } > > public void pop() { > getThreadStack().pop(); > } > > public Object peek() { > Stack stack = getThreadStack(); > if (stack.isEmpty()) throw new org.aspectj.lang.NoAspectBoundException(); > return (Object)stack.peek(); > } > > public Object get(int index) { > CFlow cf = peekCFlow(); > return (null == cf ? null : cf.get(index)); > } > > public Object peekInstance() { > CFlow cf = peekCFlow(); > if (cf != null ) return cf.getAspect(); > else throw new NoAspectBoundException(); > } > > public CFlow peekCFlow() { > Stack stack = getThreadStack(); > if (stack.isEmpty()) return null; > return (CFlow)stack.peek(); > } > > public CFlow peekTopCFlow() { > Stack stack = getThreadStack(); > if (stack.isEmpty()) return null; > return (CFlow)stack.elementAt(0); > } > > public boolean isValid() { > return !getThreadStack().isEmpty(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
aclement
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 59909
: 9938 |
9939
|
10255
|
10331