+namespace simgrid::kernel::activity {
+
+/** Semaphore Acquisition: the act / process of acquiring the semaphore.
+ *
+ * You can declare some interest on a semaphore without being blocked waiting if it's already empty.
+ * See the documentation of the MutexAcquisitionImpl for further details.
+ */
+class XBT_PUBLIC SemAcquisitionImpl : public ActivityImpl_T<SemAcquisitionImpl> {
+ actor::ActorImpl* issuer_ = nullptr;
+ SemaphoreImpl* semaphore_ = nullptr;
+ bool granted_ = false;
+
+ friend SemaphoreImpl;
+ friend actor::SemaphoreAcquisitionObserver;
+
+public:
+ SemAcquisitionImpl(actor::ActorImpl* issuer, SemaphoreImpl* sem) : issuer_(issuer), semaphore_(sem) {}
+ SemaphoreImplPtr get_semaphore() { return semaphore_; }
+ actor::ActorImpl* get_issuer() { return issuer_; }
+
+ bool test(actor::ActorImpl* issuer = nullptr) override { return granted_; }
+ void wait_for(actor::ActorImpl* issuer, double timeout) override;
+ void post() override;
+ void finish() override;
+ void cancel() override;
+ void set_exception(actor::ActorImpl* issuer) override
+ { /* nothing to do */
+ }
+};