use of libcore.util.MutableInt in project robovm by robovm.
the class IoBridge method available.
public static int available(FileDescriptor fd) throws IOException {
try {
MutableInt available = new MutableInt(0);
Libcore.os.ioctlInt(fd, FIONREAD, available);
if (available.value < 0) {
// If the fd refers to a regular file, the result is the difference between
// the file size and the file position. This may be negative if the position
// is past the end of the file. If the fd refers to a special file masquerading
// as a regular file, the result may be negative because the special file
// may appear to have zero size and yet a previous read call may have
// read some amount of data and caused the file position to be advanced.
available.value = 0;
}
return available.value;
} catch (ErrnoException errnoException) {
if (errnoException.errno == ENOTTY) {
// The fd is unwilling to opine about its read buffer.
return 0;
}
throw errnoException.rethrowAsIOException();
}
}
use of libcore.util.MutableInt in project robovm by robovm.
the class ProcessManager method watchChildren.
/**
* Loops indefinitely and calls ProcessManager.onExit() when children exit.
*/
private void watchChildren() {
MutableInt status = new MutableInt(-1);
while (true) {
try {
// Wait for children in our process group.
int pid = Libcore.os.waitpid(0, status, 0);
// Work out what onExit wants to hear.
int exitValue;
if (WIFEXITED(status.value)) {
exitValue = WEXITSTATUS(status.value);
} else if (WIFSIGNALED(status.value)) {
exitValue = WTERMSIG(status.value);
} else if (WIFSTOPPED(status.value)) {
exitValue = WSTOPSIG(status.value);
} else {
throw new AssertionError("unexpected status from waitpid: " + status.value);
}
onExit(pid, exitValue);
} catch (ErrnoException errnoException) {
if (errnoException.errno == ECHILD) {
// Expected errno: there are no children to wait for.
// onExit will sleep until it is informed of another child coming to life.
waitForMoreChildren();
continue;
} else {
throw new AssertionError(errnoException);
}
}
}
}
use of libcore.util.MutableInt in project j2objc by google.
the class IoBridge method available.
public static int available(FileDescriptor fd) throws IOException {
try {
MutableInt available = new MutableInt(0);
Libcore.os.ioctlInt(fd, FIONREAD, available);
if (available.value < 0) {
// If the fd refers to a regular file, the result is the difference between
// the file size and the file position. This may be negative if the position
// is past the end of the file. If the fd refers to a special file masquerading
// as a regular file, the result may be negative because the special file
// may appear to have zero size and yet a previous read call may have
// read some amount of data and caused the file position to be advanced.
available.value = 0;
}
return available.value;
} catch (ErrnoException errnoException) {
if (errnoException.errno == ENOTTY) {
// The fd is unwilling to opine about its read buffer.
return 0;
}
throw errnoException.rethrowAsIOException();
}
}
use of libcore.util.MutableInt in project XobotOS by xamarin.
the class IoBridge method available.
public static int available(FileDescriptor fd) throws IOException {
try {
MutableInt available = new MutableInt(0);
Libcore.os.ioctlInt(fd, FIONREAD, available);
if (available.value < 0) {
// If the fd refers to a regular file, the result is the difference between
// the file size and the file position. This may be negative if the position
// is past the end of the file. If the fd refers to a special file masquerading
// as a regular file, the result may be negative because the special file
// may appear to have zero size and yet a previous read call may have
// read some amount of data and caused the file position to be advanced.
available.value = 0;
}
return available.value;
} catch (ErrnoException errnoException) {
if (errnoException.errno == ENOTTY) {
// The fd is unwilling to opine about its read buffer.
return 0;
}
throw errnoException.rethrowAsIOException();
}
}
use of libcore.util.MutableInt in project android_frameworks_base by ParanoidAndroid.
the class KeyguardMessageArea method update.
/**
* Update the status lines based on these rules:
* AlarmStatus: Alarm state always gets it's own line.
* Status1 is shared between help, battery status and generic unlock instructions,
* prioritized in that order.
* @param showStatusLines status lines are shown if true
*/
void update() {
MutableInt icon = new MutableInt(0);
CharSequence status = concat(getChargeInfo(icon), getOwnerInfo(), getCurrentMessage());
setCompoundDrawablesWithIntrinsicBounds(icon.value, 0, 0, 0);
setText(status);
}
Aggregations