script: Limit public exports. (#34915)

* script: Restrict reexport visibility of DOM types.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Mass pub->pub(crate) conversion.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Hide existing dead code warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix unit tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* More formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-10 03:19:19 -05:00 committed by GitHub
parent f220d6d3a5
commit c94d909a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
585 changed files with 5411 additions and 5013 deletions

View file

@ -18,7 +18,7 @@ use crate::script_thread::ScriptThread;
use crate::task::TaskBox;
use crate::task_source::TaskSourceName;
pub type QueuedTask = (
pub(crate) type QueuedTask = (
Option<TrustedWorkerAddress>,
ScriptThreadEventCategory,
Box<dyn TaskBox>,
@ -27,7 +27,7 @@ pub type QueuedTask = (
);
/// Defining the operations used to convert from a msg T to a QueuedTask.
pub trait QueuedTaskConversion {
pub(crate) trait QueuedTaskConversion {
fn task_source_name(&self) -> Option<&TaskSourceName>;
fn pipeline_id(&self) -> Option<PipelineId>;
fn into_queued_task(self) -> Option<QueuedTask>;
@ -37,7 +37,7 @@ pub trait QueuedTaskConversion {
fn is_wake_up(&self) -> bool;
}
pub struct TaskQueue<T> {
pub(crate) struct TaskQueue<T> {
/// The original port on which the task-sources send tasks as messages.
port: Receiver<T>,
/// A sender to ensure the port doesn't block on select while there are throttled tasks.
@ -53,7 +53,7 @@ pub struct TaskQueue<T> {
}
impl<T: QueuedTaskConversion> TaskQueue<T> {
pub fn new(port: Receiver<T>, wake_up_sender: Sender<T>) -> TaskQueue<T> {
pub(crate) fn new(port: Receiver<T>, wake_up_sender: Sender<T>) -> TaskQueue<T> {
TaskQueue {
port,
wake_up_sender,
@ -182,7 +182,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
/// Reset the queue for a new iteration of the event-loop,
/// returning the port about whose readiness we want to be notified.
pub fn select(&self) -> &crossbeam_channel::Receiver<T> {
pub(crate) fn select(&self) -> &crossbeam_channel::Receiver<T> {
// This is a new iteration of the event-loop, so we reset the "business" counter.
self.taken_task_counter.set(0);
// We want to be notified when the script-port is ready to receive.
@ -191,19 +191,19 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
}
/// Take a message from the front of the queue, without waiting if empty.
pub fn recv(&self) -> Result<T, ()> {
pub(crate) fn recv(&self) -> Result<T, ()> {
self.msg_queue.borrow_mut().pop_front().ok_or(())
}
/// Take all tasks again and then run `recv()`.
pub fn take_tasks_and_recv(&self) -> Result<T, ()> {
pub(crate) fn take_tasks_and_recv(&self) -> Result<T, ()> {
self.take_tasks(T::wake_up_msg());
self.recv()
}
/// Drain the queue for the current iteration of the event-loop.
/// Holding-back throttles above a given high-water mark.
pub fn take_tasks(&self, first_msg: T) {
pub(crate) fn take_tasks(&self, first_msg: T) {
// High-watermark: once reached, throttled tasks will be held-back.
const PER_ITERATION_MAX: u64 = 5;
let fully_active = ScriptThread::get_fully_active_document_ids();