The containing class is available as
File\Handle in the www repository.
Get a shared or exclusive lock on the file
public function lock( HH\Lib\File\LockType $type, ): HH\Lib\File\Lock;
This will block until it acquires the lock, which may be forever.
This involves a blocking syscall; async code will not execute while waiting for a lock.