Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::browser::BrowserShareReleaseQueue Class Reference

Texture share releases waiting for the worker that made the shares. More...

#include "donner/gpu/browser/BrowserShareReleaseQueue.h"

Classes

struct  Release
 A release to run on the owner. More...

Public Member Functions

bool post (const Release &release, const std::function< void()> &notify={})
 Queues release for the owner, unless the queue is closed.
std::vector< Release > takeAll ()
 Takes every queued release, oldest first. Owner only.
void close ()
 Refuses every later post and drops what is still queued, because the owner is going. Owner only; waits for a post in progress to finish.
bool closed () const
 Whether close has run.

Static Public Member Functions

static std::shared_ptr< BrowserShareReleaseQueue > ForThisThread ()
 The calling thread's queue, for a share made on this thread to post its release into from elsewhere.
static void DrainThisThread (const std::function< void(const Release &)> &run)
 Runs run for each release posted to the calling thread's queue, oldest first.

Detailed Description

Texture share releases waiting for the worker that made the shares.

The last holder of a share may be let go on any thread, because an export token may be, but only the worker that made a share can tell its browser side to let the texture go. A holder let go on another thread posts its release here instead, and the owner runs what is posted the next time it drains the queue. A queue whose owner has gone is closed: a post is then refused and does nothing, and whatever was still waiting is dropped with the worker's browser state.

Any thread may post; only the owner drains or closes.


Class Documentation

◆ donner::gpu::browser::BrowserShareReleaseQueue::Release

struct donner::gpu::browser::BrowserShareReleaseQueue::Release

A release to run on the owner.

Class Members
uint32_t producer = 0 Logical device that made the share.
BrowserTextureShareId share = 0 Share to release.

Member Function Documentation

◆ DrainThisThread()

void donner::gpu::browser::BrowserShareReleaseQueue::DrainThisThread ( const std::function< void(const Release &)> & run)
static

Runs run for each release posted to the calling thread's queue, oldest first.

Does nothing once that queue has gone with its thread: it was closed then, and held nothing to run.

Parameters
runRuns one release on this thread.

◆ ForThisThread()

std::shared_ptr< BrowserShareReleaseQueue > donner::gpu::browser::BrowserShareReleaseQueue::ForThisThread ( )
static

The calling thread's queue, for a share made on this thread to post its release into from elsewhere.

Made on the thread's first use and closed when the thread exits.

Returns
The queue, or null once it has been destroyed during the thread's exit, so that an object the thread destroys after it finds no queue rather than a destroyed one.

◆ post()

bool donner::gpu::browser::BrowserShareReleaseQueue::post ( const Release & release,
const std::function< void()> & notify = {} )

Queues release for the owner, unless the queue is closed.

Parameters
releaseRelease to queue.
notifyRun, while the owner cannot close the queue, once the release is queued, so a caller can wake the owner knowing it has not gone; not run when the queue is closed. May be empty.
Returns
Whether the release was queued.

The documentation for this class was generated from the following file: