# GPUSyncFence

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/GPUSyncFence.kt+class:androidx.webgpu.GPUSyncFence) Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

*** ** * ** ***


```
@ExperimentalWebGpuApi
class GPUSyncFence : AutoCloseable
```

<br />

*** ** * ** ***

A unified abstraction for fence synchronization in WebGPU

This class is backed by a `ParcelFileDescriptor` representing a sync fence.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 33) https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence#fromSyncFence(android.hardware.SyncFence)(syncFence: https://developer.android.com/reference/android/hardware/SyncFence.html)` Creates a GPUSyncFence from a platform SyncFence by extracting its file descriptor. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence#await(kotlin.Long)(timeoutMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Waits for the fence to signal. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence#close()()` |

| ### Extension functions |
|---|---|
| `https://developer.android.com/reference/android/hardware/SyncFence.html?` | `@https://developer.android.com/reference/kotlin/androidx/webgpu/ExperimentalWebGpuApi https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence?.https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence#(androidx.webgpu.GPUSyncFence).toSyncFence()()` Converts to an Android platform `https://developer.android.com/reference/android/hardware/SyncFence.html`. |

## Public companion functions

### fromSyncFence

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@RequiresApi(value = 33)
fun fromSyncFence(syncFence: SyncFence): GPUSyncFence
```

Creates a GPUSyncFence from a platform SyncFence by extracting its file descriptor.

## Public functions

### await

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
fun await(timeoutMillis: Long): Boolean
```

Waits for the fence to signal.

### close

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
open fun close(): Unit
```

## Extension functions

### GPUSyncFence.toSyncFence

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/helper/Extensions.kt+function:toSyncFence)

```
@ExperimentalWebGpuApi
fun GPUSyncFence?.toSyncFence(): SyncFence?
```

Converts to an Android platform `https://developer.android.com/reference/android/hardware/SyncFence.html`.

Safely handles API level compatibility internally. On devices below Android T (API 33), this function will safely return `null` without requiring API version checks at the call site.