aboutsummaryrefslogtreecommitdiff
path: root/macros/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/util.rs')
-rw-r--r--macros/src/util.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/macros/src/util.rs b/macros/src/util.rs
new file mode 100644
index 00000000..45f1feef
--- /dev/null
+++ b/macros/src/util.rs
@@ -0,0 +1,48 @@
+use std::collections::HashMap;
+
+use syn::Ident;
+
+use syntax::App;
+
+pub type Ceilings = HashMap<Ident, Ceiling>;
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum Ceiling {
+ Owned,
+ Shared(u8),
+}
+
+impl Ceiling {
+ pub fn is_owned(&self) -> bool {
+ *self == Ceiling::Owned
+ }
+}
+
+pub fn compute_ceilings(app: &App) -> Ceilings {
+ let mut ceilings = HashMap::new();
+
+ for resource in &app.idle.resources {
+ ceilings.insert(resource.clone(), Ceiling::Owned);
+ }
+
+ for task in app.tasks.values() {
+ for resource in &task.resources {
+ if let Some(ceiling) = ceilings.get_mut(resource) {
+ match *ceiling {
+ Ceiling::Owned => *ceiling = Ceiling::Shared(task.priority),
+ Ceiling::Shared(old) => {
+ if task.priority > old {
+ *ceiling = Ceiling::Shared(task.priority);
+ }
+ }
+ }
+
+ continue;
+ }
+
+ ceilings.insert(resource.clone(), Ceiling::Owned);
+ }
+ }
+
+ ceilings
+}
ion> Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-release/scripts/upload-npm.ts (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-08-31insert `enumerable: true` when neededGravatar Dylan Conway 2-11/+120
2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243
2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45
2023-08-31export non-enumerable valuesGravatar Dylan Conway 2-4/+79
2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0