-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_test.fl
More file actions
63 lines (47 loc) · 1.87 KB
/
memory_test.fl
File metadata and controls
63 lines (47 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Test de memoria compartida entre lenguajes
# Python: Genera datos y los guarda en memoria compartida
def generate_data():
print("[Python] Generando datos...")
data = [1, 2, 3, 4, 5]
total = sum(data)
# Guardar en memoria compartida
flow_set('numbers', data)
flow_set('total', total)
flow_set('language', 'Python')
print(f"[Python] Total calculado: {total}")
print(f"[Python] Datos guardados en memoria compartida")
generate_data()
# JavaScript: Lee de memoria compartida y procesa
async fn process_data():
console.log("\n[JavaScript] Leyendo de memoria compartida...");
const numbers = flowGet('numbers', []);
const total = flowGet('total', 0);
const lang = flowGet('language', 'unknown');
console.log(`[JavaScript] Recibido de ${lang}: ${numbers}`);
console.log(`[JavaScript] Total: ${total}`);
// Procesar y guardar resultado
const doubled = numbers.map(n => n * 2);
const newTotal = doubled.reduce((a, b) => a + b, 0);
flowSet('doubled', doubled);
flowSet('doubled_total', newTotal);
flowSet('processed_by', 'JavaScript');
console.log(`[JavaScript] Números duplicados: ${doubled}`);
console.log(`[JavaScript] Nuevo total: ${newTotal}`);
process_data()
# C++: Lee resultados finales
cpp
std::cout << "\n[C++] Leyendo resultados finales..." << std::endl;
// Leer de memoria compartida
std::string processedBy = flowGet("processed_by", "unknown");
std::cout << "[C++] Procesado por: " << processedBy << std::endl;
// Guardar resultado final
flowSet("status", "completed");
flowSet("final_stage", "C++");
std::cout << "[C++] Pipeline completado exitosamente" << std::endl;
end
# CLEANUP
import os
print("\n[Cleanup] Limpiando archivos temporales...")
if os.path.exists('__flow_mem__.json'):
os.remove('__flow_mem__.json')
print("[Cleanup] Memoria compartida limpiada")