Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a VecDequeue instead of a vec for bytes #2246

Merged
merged 2 commits into from Apr 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/desktop/src/edits.rs
@@ -1,17 +1,17 @@
use std::{cell::RefCell, rc::Rc};
use std::{cell::RefCell, collections::VecDeque, rc::Rc};

/// This handles communication between the requests that the webview makes and the interpreter. The interpreter constantly makes long running requests to the webview to get any edits that should be made to the DOM almost like server side events.
/// It will hold onto the requests until the interpreter is ready to handle them and hold onto any pending edits until a new request is made.
#[derive(Default, Clone)]
pub(crate) struct EditQueue {
queue: Rc<RefCell<Vec<Vec<u8>>>>,
queue: Rc<RefCell<VecDeque<Vec<u8>>>>,
responder: Rc<RefCell<Option<wry::RequestAsyncResponder>>>,
}

impl EditQueue {
pub fn handle_request(&self, responder: wry::RequestAsyncResponder) {
let mut queue = self.queue.borrow_mut();
if let Some(bytes) = queue.pop() {
if let Some(bytes) = queue.pop_back() {
responder.respond(wry::http::Response::new(bytes));
} else {
*self.responder.borrow_mut() = Some(responder);
Expand All @@ -23,7 +23,7 @@ impl EditQueue {
if let Some(responder) = responder.take() {
responder.respond(wry::http::Response::new(edits));
} else {
self.queue.borrow_mut().push(edits);
self.queue.borrow_mut().push_front(edits);
}
}
}
3 changes: 2 additions & 1 deletion packages/generational-box/src/lib.rs
Expand Up @@ -201,8 +201,9 @@ impl<T, S: Storage<T>> GenerationalBox<T, S> {
/// Drop the value out of the generational box and invalidate the generational box. This will return the value if the value was taken.
pub fn manually_drop(&self) -> Option<T> {
if self.validate() {
let o = Storage::take(&self.raw.0.data);
<S as AnyStorage>::recycle(&self.raw);
Storage::take(&self.raw.0.data)
o
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion packages/interpreter/src/js/hash.txt
@@ -1 +1 @@
13636418089
14148301494