2024-08-06 23:30:00 +02:00
|
|
|
package mp.code;
|
|
|
|
|
|
|
|
import mp.code.data.Cursor;
|
2024-08-07 02:43:25 +02:00
|
|
|
import mp.code.exceptions.CodeMPException;
|
2024-08-06 23:30:00 +02:00
|
|
|
|
2024-08-07 10:22:01 +02:00
|
|
|
import java.util.Optional;
|
|
|
|
|
2024-08-06 23:30:00 +02:00
|
|
|
public class CursorController {
|
|
|
|
private final long ptr;
|
|
|
|
|
|
|
|
CursorController(long ptr) {
|
|
|
|
this.ptr = ptr;
|
|
|
|
}
|
|
|
|
|
2024-08-07 02:43:25 +02:00
|
|
|
private static native Cursor try_recv(long self) throws CodeMPException;
|
2024-08-07 10:22:01 +02:00
|
|
|
public Optional<Cursor> tryRecv() throws CodeMPException {
|
|
|
|
return Optional.ofNullable(try_recv(this.ptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static native Cursor recv(long self) throws CodeMPException;
|
|
|
|
public Cursor recv() throws CodeMPException {
|
|
|
|
return recv(this.ptr);
|
2024-08-06 23:30:00 +02:00
|
|
|
}
|
|
|
|
|
2024-08-07 02:43:25 +02:00
|
|
|
private static native void send(long self, Cursor cursor) throws CodeMPException;
|
|
|
|
public void send(Cursor cursor) throws CodeMPException {
|
2024-08-06 23:30:00 +02:00
|
|
|
send(this.ptr, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static native void free(long self);
|
|
|
|
@Override
|
2024-08-07 02:43:25 +02:00
|
|
|
protected void finalize() {
|
2024-08-06 23:30:00 +02:00
|
|
|
free(this.ptr);
|
|
|
|
}
|
|
|
|
}
|