use of com.sun.jna.Pointer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MappedFile method munlock.
public void munlock() {
final long beginTime = System.currentTimeMillis();
final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
int ret = LibC.INSTANCE.munlock(pointer, new NativeLong(this.fileSize));
log.info("munlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
}
use of com.sun.jna.Pointer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MappedFile method mlock.
public void mlock() {
final long beginTime = System.currentTimeMillis();
final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
{
int ret = LibC.INSTANCE.mlock(pointer, new NativeLong(this.fileSize));
log.info("mlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
}
{
int ret = LibC.INSTANCE.madvise(pointer, new NativeLong(this.fileSize), LibC.MADV_WILLNEED);
log.info("madvise {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
}
}
use of com.sun.jna.Pointer in project dukescript-presenters by dukescript.
the class WebKitPresenter method convertToString.
final String convertToString(JSC jsc, Pointer value) {
int type = jsc.JSValueGetType(ctx, value);
if (type == 5) {
Pointer toStr = jsc.JSStringCreateWithUTF8CString("this.toString()");
value = jsc.JSEvaluateScript(ctx, toStr, value, null, 0, null);
jsc.JSStringRelease(toStr);
}
Object ret = convertToJava(jsc, String.class, value);
return ret != null ? ret.toString() : "<null value>";
}
use of com.sun.jna.Pointer in project dukescript-presenters by dukescript.
the class Cocoa method nsString.
static Pointer nsString(String bd) {
ObjC objC = ObjC.INSTANCE;
Pointer stringClass = objC.objc_getClass("NSString");
Pointer browserDemo = new Pointer(send(stringClass, "stringWithCString:encoding:", bd, 4));
return browserDemo;
}
use of com.sun.jna.Pointer in project Terasology by MovingBlocks.
the class OpenVRProvider method setKeyboardOverlayShowing.
/**
* Turn on the keyboard overlay. This is a keyboard that hovers in front of the user, that can be typed upon by
* pointing the ray extending from the top of the controller at the key the user wants to press.
* @param showingState - true or false
* @return - true if successful. If this call fails, an error is logged.
*/
public static boolean setKeyboardOverlayShowing(boolean showingState) {
int ret;
if (showingState) {
Pointer pointer = new Memory(3);
pointer.setString(0, "mc");
Pointer empty = new Memory(1);
empty.setString(0, "");
ret = vrOverlay.ShowKeyboard.apply(0, 0, pointer, 256, empty, (byte) 1, 0);
// 0 = no error, > 0 see EVROverlayError
keyboardShowing = 0 == ret;
if (ret != 0) {
logger.error("VR Overlay Error: " + vrOverlay.GetOverlayErrorNameFromEnum.apply(ret).getString(0));
}
} else {
try {
vrOverlay.HideKeyboard.apply();
} catch (Error e) {
logger.error("Error bringing up keyboard overlay: " + e.toString());
}
keyboardShowing = false;
}
return keyboardShowing;
}
Aggregations