SyncFenceCompat


class SyncFenceCompat : AutoCloseable


A synchronization primitive which signals when hardware units have completed work on a particular resource. They initially start in an unsignaled state and make a one-time transaction to either a signaled or error state.

SyncFenceCompat is a presentation fence used in combination with SurfaceControlCompat.Transaction.setBuffer. Note that depending on API level, this will utilize either android.hardware.SyncFence or a compatibility implementation.

Summary

Constants

const Long

An invalid signal time.

const Long

A pending signal time.

Public companion functions

SyncFenceCompat

Creates a native synchronization fence from an EGLSync object.

Public functions

Boolean
await(timeoutNanos: Long)

Waits for a SyncFenceCompat to signal for up to the timeout duration

Boolean

Waits forever for a SyncFenceImpl to signal

open Unit

Close the SyncFenceImpl

Long

Returns the time that the fence signaled in the CLOCK_MONOTONIC time domain.

Boolean

Checks if the SyncFence object is valid.

Constants

SIGNAL_TIME_INVALID

const val SIGNAL_TIME_INVALIDLong

An invalid signal time. Represents either the signal time for a SyncFence that isn't valid (that is, isValid is false), or if an error occurred while attempting to retrieve the signal time.

SIGNAL_TIME_PENDING

const val SIGNAL_TIME_PENDINGLong

A pending signal time. This is equivalent to the max value of a long, representing an infinitely far point in the future.

Public companion functions

createNativeSyncFence

Added in 1.0.2
fun createNativeSyncFence(): SyncFenceCompat

Creates a native synchronization fence from an EGLSync object.

Throws
kotlin.IllegalStateException

if EGL dependencies cannot be resolved

Public functions

await

Added in 1.0.2
fun await(timeoutNanos: Long): Boolean

Waits for a SyncFenceCompat to signal for up to the timeout duration

Parameters
timeoutNanos: Long

time in nanoseconds to wait for before timing out.

awaitForever

Added in 1.0.2
fun awaitForever(): Boolean

Waits forever for a SyncFenceImpl to signal

close

Added in 1.0.2
open fun close(): Unit

Close the SyncFenceImpl

getSignalTimeNanos

Added in 1.0.2
@RequiresApi(value = 26)
fun getSignalTimeNanos(): Long

Returns the time that the fence signaled in the CLOCK_MONOTONIC time domain. This returns an instant, SyncFenceCompat.SIGNAL_TIME_INVALID if the SyncFence is invalid, and if the fence hasn't yet signaled, then SyncFenceCompat.SIGNAL_TIME_PENDING is returned.

isValid

Added in 1.0.2
fun isValid(): Boolean

Checks if the SyncFence object is valid.

Returns
Boolean

true if it is valid, false otherwise