Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Implement Dart executor for async functions in Jason (#200, #182)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlapa authored May 14, 2021
1 parent 57b7b71 commit ba1dba6
Show file tree
Hide file tree
Showing 12 changed files with 354 additions and 72 deletions.
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions jason/flutter/lib/jason.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:io';

import 'media_manager.dart';
import 'room_handle.dart';
import 'util/executor.dart';
import 'util/move_semantic.dart';
import 'util/nullable_pointer.dart';
import 'util/callback.dart' as callback;
Expand All @@ -27,6 +28,12 @@ typedef _free_Dart = void Function(Pointer);

final DynamicLibrary dl = _dl_load();

/// [Executor] that drives Rust futures.
///
/// Instantiated in the [_dl_load()] function, and must not be touched ever
/// after that.
var executor;

final _new = dl.lookupFunction<_new_C, _new_Dart>('Jason__new');

final _media_manager = dl.lookupFunction<_mediaManager_C, _mediaManager_Dart>(
Expand Down Expand Up @@ -64,6 +71,8 @@ DynamicLibrary _dl_load() {
callback.registerFunctions(dl);
completer.registerFunctions(dl);

executor = Executor(dl);

return dl;
}

Expand Down
8 changes: 4 additions & 4 deletions jason/flutter/lib/reconnect_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ class ReconnectHandle {
/// Tries to reconnect a `Room` in a loop with a growing backoff delay.
///
/// The first attempt to reconnect is guaranteed to happen not earlier than
/// `starting_delay_ms`.
/// [starting_delay_ms].
///
/// Also, it guarantees that delay between reconnection attempts won't be
/// greater than `max_delay_ms`.
/// greater than [max_delay_ms].
///
/// After each reconnection attempt, delay between reconnections will be
/// multiplied by the given `multiplier` until it reaches `max_delay_ms`.
/// multiplied by the given [multiplier] until it reaches [max_delay_ms].
///
/// If the `Room` is already reconnecting then new reconnection attempt won't
/// be performed. Instead, it will wait for the first reconnection attempt
/// result and use it here.
///
/// If `multiplier` is negative number then `multiplier` will be considered as
/// If [multiplier] is negative number then [multiplier] will be considered as
/// `0.0`.
Future<void> reconnectWithBackoff(
int startingDelayMs, double multiplier, int maxDelay) async {
Expand Down
16 changes: 8 additions & 8 deletions jason/flutter/lib/room_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class RoomHandle {
RoomHandle(this.ptr);

/// Connects to a media server and joins the `Room` with the provided
/// authorization `token`.
/// authorization [token].
///
/// Authorization token has a fixed format:
/// `{{ Host URL }}/{{ Room ID }}/{{ Member ID }}?token={{ Auth Token }}`
Expand All @@ -157,23 +157,23 @@ class RoomHandle {
}
}

/// Updates this `Room`'s `MediaStreamSettings`. This affects all the
/// `PeerConnection`s in this `Room`. If `MediaStreamSettings` are configured
/// Updates this `Room`'s [MediaStreamSettings]. This affects all the
/// `PeerConnection`s in this `Room`. If [MediaStreamSettings] are configured
/// for some `Room`, then this `Room` can only send media tracks that
/// correspond to these settings. `MediaStreamSettings` update will change
/// correspond to these settings. [MediaStreamSettings] update will change
/// media tracks in all sending peers, so that might cause a new
/// [getUserMedia()][1] request to happen.
///
/// Media obtaining/injection errors are additionally fired to
/// `on_failed_local_media` callback.
/// [RoomHandle.onFailedLocalMedia()] callback.
///
/// If `stop_first` set to `true` then affected local `Tracks` will be
/// dropped before new `MediaStreamSettings` are applied. This is usually
/// If [stop_first] set to `true` then affected local [LocalMediaTrack]s will
/// be dropped before new [MediaStreamSettings] are applied. This is usually
/// required when changing video source device due to hardware limitations,
/// e.g. having an active track sourced from device `A` may hinder
/// [getUserMedia()][1] requests to device `B`.
///
/// `rollback_on_fail` option configures `MediaStreamSettings` update request
/// [rollback_on_fail] option configures [MediaStreamSettings] update request
/// to automatically rollback to previous settings if new settings cannot be
/// applied.
///
Expand Down
Loading

0 comments on commit ba1dba6

Please sign in to comment.