mirror of
https://github.com/m1ngsama/TUT.git
synced 2026-02-08 09:04:04 +00:00
Phase 10 - Complete async image downloading system HttpClient enhancements: - Add ImageDownloadTask structure for async binary downloads - Implement separate curl multi handle for concurrent image downloads - Add methods: add_image_download, poll_image_downloads, get_completed_images - Support configurable concurrency (default: 3 parallel downloads) - Cancel all images support Browser improvements: - Replace synchronous load_images() with async queue_images() - Progressive rendering - images appear as they download - Non-blocking UI during image downloads - Real-time progress display with spinner - Esc key cancels image loading - Maintains LRU image cache compatibility Performance benefits: - 3x faster image loading (3 concurrent downloads) - UI remains responsive during downloads - Users can scroll/navigate while images load - Gradual page appearance improves perceived performance Tests: - test_async_images: Full async download test suite - test_image_minimal: Minimal async workflow test - test_simple_image: Basic queueing test Technical details: - Dedicated curl multi handle for images (independent of page loading) - Queue-based download management (pending → loading → completed) - Progressive relayout as images complete - Preserves 10-minute LRU image cache
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
#include "../src/http_client.h"
|
|
#include <iostream>
|
|
#include <thread>
|
|
#include <chrono>
|
|
|
|
int main() {
|
|
std::cout << "=== Minimal Async Image Test ===\n";
|
|
|
|
try {
|
|
HttpClient client;
|
|
std::cout << "1. Client created\n";
|
|
|
|
client.add_image_download("https://httpbin.org/image/png", nullptr);
|
|
std::cout << "2. Image queued\n";
|
|
std::cout << " Pending: " << client.get_pending_image_count() << "\n";
|
|
|
|
std::cout << "3. First poll...\n";
|
|
client.poll_image_downloads();
|
|
std::cout << " After poll - Pending: " << client.get_pending_image_count()
|
|
<< ", Loading: " << client.get_loading_image_count() << "\n";
|
|
|
|
std::cout << "4. Wait a bit...\n";
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
|
std::cout << "5. Second poll...\n";
|
|
client.poll_image_downloads();
|
|
std::cout << " After poll - Pending: " << client.get_pending_image_count()
|
|
<< ", Loading: " << client.get_loading_image_count() << "\n";
|
|
|
|
std::cout << "6. Get completed...\n";
|
|
auto completed = client.get_completed_images();
|
|
std::cout << " Completed: " << completed.size() << "\n";
|
|
|
|
std::cout << "7. Destroying client...\n";
|
|
} catch (const std::exception& e) {
|
|
std::cerr << "ERROR: " << e.what() << "\n";
|
|
return 1;
|
|
}
|
|
|
|
std::cout << "8. Test completed successfully!\n";
|
|
return 0;
|
|
}
|