-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1836 from benjchristensen/ring-buffer-size
Reduce Ring Buffer Default Sizes (and lower for Android)
- Loading branch information
Showing
3 changed files
with
373 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright 2014 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package rx.internal.util; | ||
|
||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
|
||
/** | ||
* Allow platform dependent logic such as checks for Android. | ||
* | ||
* Modeled after Netty with some code copy/pasted from: https://github.com/netty/netty/blob/master/common/src/main/java/io/netty/util/internal/PlatformDependent.java | ||
*/ | ||
public final class PlatformDependent { | ||
|
||
private static final boolean IS_ANDROID = isAndroid0(); | ||
|
||
/** | ||
* Returns {@code true} if and only if the current platform is Android | ||
*/ | ||
public static boolean isAndroid() { | ||
return IS_ANDROID; | ||
} | ||
|
||
private static boolean isAndroid0() { | ||
boolean android; | ||
try { | ||
Class.forName("android.app.Application", false, getSystemClassLoader()); | ||
android = true; | ||
} catch (Exception e) { | ||
// Failed to load the class uniquely available in Android. | ||
android = false; | ||
} | ||
|
||
return android; | ||
} | ||
|
||
/** | ||
* Return the system {@link ClassLoader}. | ||
*/ | ||
static ClassLoader getSystemClassLoader() { | ||
if (System.getSecurityManager() == null) { | ||
return ClassLoader.getSystemClassLoader(); | ||
} else { | ||
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { | ||
@Override | ||
public ClassLoader run() { | ||
return ClassLoader.getSystemClassLoader(); | ||
} | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.