Skip to content

Commit

Permalink
was/Lease: return PutAction
Browse files Browse the repository at this point in the history
This will be important for the Stock-owned Control instances.
  • Loading branch information
MaxKellermann committed Jan 18, 2025
1 parent b09c435 commit 4a2d871
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/was/Lease.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

class WasLease {
public:
virtual void ReleaseWas(PutAction action) noexcept = 0;
virtual void ReleaseWasStop(uint_least64_t input_received) noexcept = 0;
virtual PutAction ReleaseWas(PutAction action) noexcept = 0;
virtual PutAction ReleaseWasStop(uint_least64_t input_received) noexcept = 0;
};
10 changes: 6 additions & 4 deletions src/was/SLease.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
#include "SLease.hxx"
#include "SConnection.hxx"

void
PutAction
WasStockLease::ReleaseWas(PutAction action) noexcept
{
connection.Put(action);
action = connection.Put(action);
Destroy();
return action;
}

void
PutAction
WasStockLease::ReleaseWasStop(uint64_t input_received) noexcept
{
connection.Stop(input_received);
connection.Put(PutAction::REUSE);
PutAction action = connection.Put(PutAction::REUSE);
Destroy();
return action;
}
4 changes: 2 additions & 2 deletions src/was/SLease.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public:
WasStockLease(const WasStockLease &) = delete;
WasStockLease &operator=(const WasStockLease &) = delete;

void ReleaseWas(PutAction action) noexcept override;
void ReleaseWasStop(uint_least64_t input_received) noexcept override;
PutAction ReleaseWas(PutAction action) noexcept override;
PutAction ReleaseWasStop(uint_least64_t input_received) noexcept override;

private:
void Destroy() noexcept {
Expand Down
7 changes: 4 additions & 3 deletions test/run_was.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ struct Context final
}

/* virtual methods from class Lease */
void ReleaseWas([[maybe_unused]] PutAction action) noexcept override {
PutAction ReleaseWas([[maybe_unused]] PutAction action) noexcept override {
process.handle.reset();
process.Close();
return PutAction::DESTROY;
}

void ReleaseWasStop([[maybe_unused]] uint_least64_t input_received) noexcept override {
ReleaseWas(PutAction::DESTROY);
PutAction ReleaseWasStop([[maybe_unused]] uint_least64_t input_received) noexcept override {
return ReleaseWas(PutAction::DESTROY);
}

/* virtual methods from class HttpResponseHandler */
Expand Down
8 changes: 4 additions & 4 deletions test/t_was_client.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ class WasConnection final
}

/* virtual methods from class WasLease */
void ReleaseWas(PutAction action) noexcept override {
lease->ReleaseLease(action);
PutAction ReleaseWas(PutAction action) noexcept override {
return lease->ReleaseLease(action);
}

void ReleaseWasStop(uint_least64_t) noexcept override {
ReleaseWas(PutAction::DESTROY);
PutAction ReleaseWasStop(uint_least64_t) noexcept override {
return ReleaseWas(PutAction::DESTROY);
}

/* virtual methods from class WasControlHandler */
Expand Down

0 comments on commit 4a2d871

Please sign in to comment.