Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/gpgmm/common/MemoryAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ namespace gpgmm {

// Event overrides
void Wait() override;
bool IsSignaled() override;
void Signal() override;

/** \brief Acquire the memory allocation.

Expand All @@ -116,6 +114,9 @@ namespace gpgmm {
std::unique_ptr<MemoryAllocation> AcquireAllocation() const;

private:
void Signal() override;
bool IsSignaled() override;

std::shared_ptr<AllocateMemoryTask> mTask;
std::shared_ptr<Event> mEvent;
};
Expand Down
24 changes: 20 additions & 4 deletions src/gpgmm/common/WorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,37 @@ namespace gpgmm {

class ThreadPool;

// An event that we can wait on, useful for joining worker threads.
/** \brief An event that we can wait on.

Used for waiting for results or joining worker threads.
*/
class Event : public NonCopyable {
public:
Event() = default;
virtual ~Event() = default;

// Blocks calling thread indefinitely until |this| event is signaled.
/** \brief Wait for the event to complete.

Wait blocks the calling thread indefinitely until the event gets signaled.
*/
virtual void Wait() = 0;

// Checks if |this| event was signaled.
/** \brief Check if event was signaled.

Event will be in signaled state once the event is completed.
*/
virtual bool IsSignaled() = 0;

// Signals the event is ready. If ready, wait() will not block.
/** \brief Signals the event is ready.

If ready, wait() will not block.
*/
virtual void Signal() = 0;

/** \brief Associates a thread pool with this event.

@param pool Shared pointer to the thread pool this event belongs with.
*/
void SetThreadPool(std::shared_ptr<ThreadPool> pool);

private:
Expand Down