Skip to content

Instantly share code, notes, and snippets.

@mashumafi
mashumafi / task_manager.gd
Last active June 21, 2024 08:25
A task manager for WorkerThreadPool to give strongly typed tasks with signals that don't block the game loop
extends Node
class Task:
var id : int
signal completed
func _init(id: int):
self.id = id
@mashumafi
mashumafi / RandomWord.java
Created July 10, 2018 21:30
Choose a random words based on weights
import java.util.AbstractCollection;
import java.util.Iterator;
import java.util.Random;
import java.util.Vector;
public class RandomWord {
public static void main(String []args){
Vector<Item<String>> words = new Vector<Item<String>>();
words.add(new Item<String>("Hello", 3));
words.add(new Item<String>("World", 1));
def listen_event(self, event, *args, **kwargs):
'''Fires an event.'''
events = self.__events.get(event, {})
for key in events:
for val in events[key](*args, **kwargs):
yield val
# example