Skip to content

Commit 2d7dc4c

Browse files
committed
use boost optional
1 parent 7baff37 commit 2d7dc4c

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/viam/examples/modules/complex/proto/buf.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ deps:
44
- remote: buf.build
55
owner: googleapis
66
repository: googleapis
7-
commit: 751cbe31638d43a9bfb6162cd2352e67
8-
digest: shake256:87f55470d9d124e2d1dedfe0231221f4ed7efbc55bc5268917c678e2d9b9c41573a7f9a557f6d8539044524d9fc5ca8fbb7db05eb81379d168285d76b57eb8a4
7+
commit: 61b203b9a9164be9a834f58c37be6f62
8+
digest: shake256:e619113001d6e284ee8a92b1561e5d4ea89a47b28bf0410815cb2fa23914df8be9f1a6a98dcf069f5bc2d829a2cfb1ac614863be45cd4f8a5ad8606c5f200224

src/viam/sdk/module/service.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
7474
}
7575
};
7676
try {
77-
auto deadline = ctx->deadline();
78-
parent.server_->add_resource(res, &deadline);
77+
parent.server_->add_resource(res, ctx->deadline());
7978
} catch (const std::exception& exc) {
8079
return grpc::Status(::grpc::INTERNAL, exc.what());
8180
}

src/viam/sdk/rpc/server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ bool deadline_exceeded(const std::chrono::system_clock::time_point& deadline) {
5151
} // namespace
5252

5353
void Server::add_resource(std::shared_ptr<Resource> resource) {
54-
add_resource(std::move(resource), nullptr);
54+
add_resource(std::move(resource), boost::none);
5555
}
5656

5757
void Server::add_resource(std::shared_ptr<Resource> resource,
58-
std::chrono::system_clock::time_point* deadline) {
58+
boost::optional<std::chrono::system_clock::time_point> deadline) {
5959
if (deadline && deadline_exceeded(*deadline)) {
6060
throw Exception(ErrorCondition::k_general, "Deadline expired");
6161
}

src/viam/sdk/rpc/server.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Server {
5656
/// @throws `Exception` if a matching `ResourceServer` doesn't exist in the server.
5757
/// @throws `Exception` if the deadline is not nil and has passed
5858
void add_resource(std::shared_ptr<Resource> resource,
59-
std::chrono::system_clock::time_point* deadline);
59+
boost::optional<std::chrono::system_clock::time_point> deadline);
6060

6161
/// @brief Adds a listening port to the server.
6262
/// @param address The address to listen at.

0 commit comments

Comments
 (0)