OpenJDK / lambda / lambda / jdk
changeset 6046:44399f708eb9
Restore suggestDepth and suggestTargetSize as they are still in use
author | dholmes |
---|---|
date | Mon, 24 Sep 2012 00:47:56 -0400 |
parents | 37342573989e |
children | 191924fbb51c |
files | src/share/classes/java/util/concurrent/ForkJoinUtils.java |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/util/concurrent/ForkJoinUtils.java Sun Sep 23 18:52:42 2012 -0400 +++ b/src/share/classes/java/util/concurrent/ForkJoinUtils.java Mon Sep 24 00:47:56 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,20 @@ private ForkJoinUtils() {}; // no construction + public static int suggestDepth(long s) { + long leafSize = suggestTargetSize(s); + int d = 0; + while (s > leafSize) { + s /= 2; + ++d; + } + return d; + } + + public static long suggestTargetSize(long s) { + return 1 + ((s + 7) >>> 3) / defaultFJPool().getParallelism(); + } + /** * The exception thrown if initialization of the * {@link #defaultFJPool default ForkJoinPool}