This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Atomics | |
/// A thread-safe, lockless, concurrent sequence which can be appended to and drained. | |
/// This is not quite a Treiber stack in the sense that single elements cannot | |
/// be **popped** off of it - Treiber stacks rely on every interaction with a given memory | |
/// address being a *single atomic read, write or exchange operation*. The Swift atomics | |
/// package is a bit too anemic for that - we would need to be able to exchange a pointer | |
/// to the head cell with a pointer to the head cell's child (if any) without reading the | |
/// head pointer twice. That's implementable in C or assembly, but not with the access | |
/// Swift atomics give us. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final class DelayedRegistration : Sendable { | |
static let singleton = DelayedRegistration() | |
private let queue : TreiberishStack<DREntry> = .init() | |
private let enqueued = ManagedAtomic(false) | |
struct DREntry : @unchecked Sendable { | |
weak var stub : FolderMonitorStub? | |
weak var monitor : (any ChangeMonitor)? | |
func withValues(_ f : (FolderMonitorStub, any ChangeMonitor) -> Void) -> Bool { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Atomics | |
/// A thread-safe, lockless, concurrent sequence which can be appended to and drained. | |
/// This is not quite a Treiber stack in the sense that single elements cannot | |
/// be **popped** off of it - Treiber stacks rely on every interaction with a given memory | |
/// address being a *single atomic read, write or exchange operation*. The Swift atomics | |
/// package is a bit too anemic for that - we would need to be able to exchange a pointer | |
/// to the head cell with a pointer to the head cell's child (if any) without reading the | |
/// head pointer twice. That's implementable in C or assembly and a memory offset, but not with the access | |
/// Swift atomics give us. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! A rough cut of how to build a processing graph for samples. | |
//! I omitted dealing with multiple channels via const generics, as it | |
//! complicates things and the point here is just how you'd chain things up. | |
/// Takes a vector of samples, does horrible things to them and returns the result. | |
fn processing_demo(input: Vec<f32>) -> Vec<f32> { | |
let mut graph = demo_graph(Vec::with_capacity(input.len())); | |
graph.process_audio(input.iter()); | |
graph.close() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use floem::{ | |
close_window, | |
context::ComputeLayoutCx, | |
event::EventPropagation, | |
keyboard::NamedKey, | |
kurbo::{Rect, Size}, | |
new_window, | |
reactive::{create_rw_signal, ReadSignal, RwSignal}, | |
style::{Background, Style, TextColor, TextOverflow}, | |
taffy::{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mastfrog.lambda.gc; | |
import java.lang.ref.WeakReference; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import static org.junit.jupiter.api.Assertions.assertTrue; | |
import org.junit.jupiter.api.Test; | |
public class LambdaGCTest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.DisplayMode; | |
import java.awt.Font; | |
import java.awt.FontMetrics; | |
import java.awt.Graphics2D; | |
import java.awt.GraphicsConfiguration; | |
import java.awt.GraphicsDevice; | |
import java.awt.GraphicsEnvironment; | |
import java.awt.geom.AffineTransform; | |
import java.awt.geom.NoninvertibleTransformException; | |
import java.awt.image.VolatileImage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dew.demo.histogram; | |
import java.util.ArrayList; | |
import java.util.List; | |
import net.java.html.json.ComputedProperty; | |
import net.java.html.json.Model; | |
import net.java.html.json.Property; | |
/** Model annotation generates class Data with | |
* one property for list of of numbers and read-only property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dew.demo.histogram; | |
import java.util.ArrayList; | |
import java.util.List; | |
import net.java.html.json.ComputedProperty; | |
import net.java.html.json.Model; | |
import net.java.html.json.Property; | |
/** Model annotation generates class Data with | |
* one property for list of of numbers and read-only property |