SyncFenceCompat


@ExperimentalApi
public class SyncFenceCompat implements AutoCloseable


A helper class that allows duplicating a SyncFence, and wrapping a fence file descriptor on earlier API levels.

Summary

Public methods

static SyncFenceCompat
adoptFenceFileDescriptor(int fileDescriptor)

Take ownership of a raw native fence file descriptor into a new SyncFenceCompat.

boolean
await(int timeoutMs)

Waits for the fence to signal.

void
static SyncFenceCompat
@RequiresApi(value = 33)
duplicate(SyncFence syncFence)

Creates an instance that duplicates a SyncFence.

Public methods

adoptFenceFileDescriptor

public static SyncFenceCompat adoptFenceFileDescriptor(int fileDescriptor)

Take ownership of a raw native fence file descriptor into a new SyncFenceCompat.

The returned instance now owns the given file descriptor, and will be responsible for closing it.

Graphics APIs such as Vulkan are a common source of a native fence file descriptors.

Parameters
int fileDescriptor

The raw native fence file descriptor.

await

public boolean await(int timeoutMs)

Waits for the fence to signal.

Parameters
int timeoutMs

The timeout in milliseconds. A negative value means infinite timeout.

Returns
boolean

Whether the fence signaled within the timeout.

Throws
android.system.ErrnoException

If an error occurs while polling the fence. See the Linux manual pages for the poll system call.

close

public void close()

duplicate

@RequiresApi(value = 33)
public static SyncFenceCompat duplicate(SyncFence syncFence)

Creates an instance that duplicates a SyncFence. Both fences must be closed independently.