Android-cuttlefish cvd tool
sem.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <chrono>
19
22
23namespace cuttlefish::cvdalloc {
24
25constexpr std::chrono::seconds kSemNoTimeout = std::chrono::seconds(0);
26
27/*
28 * Write into the socket.
29 *
30 * Any other processes Wait'ing to read on the socket will be unblocked.
31 */
32Result<void> Post(const SharedFD socket);
33
34/*
35 * Wait on the socket.
36 *
37 * The process wil block until the socket can be read from, the socket is
38 * shut down, or the timeout is reached. The Result is ok if the socket
39 * can be successfully read from.
40 */
41Result<void> Wait(const SharedFD socket, std::chrono::seconds timeout);
42
43} // namespace cuttlefish::cvdalloc
Definition: expected.h:86
Definition: shared_fd.h:129
Definition: sem.cpp:20
constexpr std::chrono::seconds kSemNoTimeout
Definition: sem.h:25
Result< void > Wait(const SharedFD socket, std::chrono::seconds timeout)
Definition: sem.cpp:28
Result< void > Post(const SharedFD socket)
Definition: sem.cpp:22