Polyphase Game Engine
Loading...
Searching...
No Matches
HttpHandle.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <memory>
5#include <stdint.h>
6
7#include "PolyphaseAPI.h"
8
10{
11public:
12 HttpHandle() = default;
13 HttpHandle(uint64_t id, std::shared_ptr<std::atomic<bool>> cancelFlag)
14 : mId(id), mCancelFlag(std::move(cancelFlag)) {}
15
16 uint64_t GetId() const { return mId; }
17 bool IsValid() const { return mCancelFlag != nullptr; }
18
19 // Marks the request for cancellation. The worker thread checks the flag
20 // during its loop and aborts cleanly. Idempotent and safe to call from any
21 // thread; safe to call after the request has already completed.
22 void Cancel();
23 bool IsCancelled() const;
24
25private:
26 uint64_t mId = 0;
27 std::shared_ptr<std::atomic<bool>> mCancelFlag;
28};
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition HttpHandle.h:10
HttpHandle(uint64_t id, std::shared_ptr< std::atomic< bool > > cancelFlag)
Definition HttpHandle.h:13
bool IsValid() const
Definition HttpHandle.h:17
uint64_t GetId() const
Definition HttpHandle.h:16
HttpHandle()=default
Definition SmartPointer.h:631