blob: 66494ca05c44359320d9ba3f49cd17bd5c12a309 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package io.v.impl.google.channel;
import io.v.v23.OutputChannel;
import io.v.v23.verror.VException;
/**
* An implementation of {@link OutputChannel} that calls to native code for most
* of its functionalities.
*/
public class OutputChannelImpl<T> implements OutputChannel<T> {
private final long nativePtr;
private static native <T> void nativeWriteValue(long nativePtr, T value) throws VException;
private static native <T> void nativeClose(long nativePtr) throws VException;
private static native <T> void nativeFinalize(long nativePtr);
private OutputChannelImpl(long nativePtr) {
this.nativePtr = nativePtr;
}
@Override
public void writeValue(T value) throws VException {
nativeWriteValue(nativePtr, value);
}
@Override
public void close() throws VException {
nativeClose(nativePtr);
}
@Override
protected void finalize() throws Throwable {
nativeFinalize(nativePtr);
}
}