25 lines
2.0 KiB
C
25 lines
2.0 KiB
C
/* Один планировщик на локальный экземпляр; handles владельцев не размножают пробы/выдачи.
|
|
* tick вызывается общим stream network timer, destroy отменяет все свои receive/probe handles. */
|
|
#ifndef STREAM_OPTIMIZER_H
|
|
#define STREAM_OPTIMIZER_H
|
|
|
|
#include "stream.h"
|
|
|
|
struct stream_optimizer;
|
|
struct stream_receive_info;
|
|
/* Меньшая оценка лучше: chain RTT + 2 * peer RTT + 3 мс/hop + штраф 0..1000 мс; неизвестный RTT = UINT64_MAX. */
|
|
uint64_t stream_supplier_score(const struct stream_receive_info *info, const struct stream_metric_snapshot *metrics, int valid);
|
|
/* Только монотонное расписание; pending/active — незавершённый обход/пробы текущего цикла.
|
|
* Возвращает допустимое число новых узлов, не адресов/субпотоков: 32 один раз, затем 0/1. */
|
|
struct stream_probe_schedule { uint64_t cycle, started_ms, next_ms; };
|
|
unsigned stream_probe_schedule_tick(struct stream_probe_schedule *schedule, uint64_t now_ms, unsigned pending, unsigned active);
|
|
int stream_optimizer_create(struct UTUN_INSTANCE *inst, const struct stream_descriptor *descriptor, struct stream_optimizer **out);
|
|
void stream_optimizer_destroy(struct stream_optimizer *optimizer);
|
|
void stream_optimizer_tick(struct stream_optimizer *optimizer, struct STREAM_HANDLE *subscription, uint64_t now_ms);
|
|
int stream_optimizer_configure(struct stream_optimizer *optimizer, const struct stream_selection_settings *settings);
|
|
void stream_optimizer_info(struct stream_optimizer *optimizer, struct stream_selection_info *info);
|
|
/* Подтверждённая помощь немедленно обновляет кандидатов и снимает старый backoff конкретного пира. */
|
|
void stream_optimizer_refresh(struct stream_optimizer *optimizer, uint64_t peer);
|
|
|
|
#endif
|