Skip to content

Commit

Permalink
fix null analysis issues on Haxe 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed May 7, 2023
1 parent e5b586b commit 0b4861a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/hx/concurrent/collection/SynchronizedLinkedList.hx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ private class SynchronizedLinkedListImpl<T> implements OrderedCollection<T> {
var i = 0;
var foundAt = -1;
for (item in _items) {
#if (haxe_ver >= 4.3) @:nullSafety(Off) #end
if (startAt != null && i > startAt)
break;
if (item == x)
Expand Down
7 changes: 3 additions & 4 deletions src/hx/concurrent/executor/ThreadPoolExecutor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,12 @@ class ThreadPoolExecutor extends Executor {
}


public function submit<T>(task:Either2<Void->T,Void->Void>, ?schedule:Schedule):TaskFuture<T>
public function submit<T>(task:Either2<Void->T,Void->Void>, ?schedule:Schedule):TaskFuture<T> {
final schedule:Schedule = schedule == null ? Executor.NOW_ONCE : schedule;
return _stateLock.execute(function() {
if (state != RUNNING)
throw 'Cannot accept new tasks. Executor is not in state [RUNNING] but [$state].';

if (schedule == null)
schedule = Executor.NOW_ONCE;

final future = new TaskFutureImpl<T>(this, task, schedule);

// skip round-trip via scheduler for one-shot tasks that should be executed immediately
Expand All @@ -143,6 +141,7 @@ class ThreadPoolExecutor extends Executor {
_newScheduledTasks.push(future);
return future;
});
}


override //
Expand Down
8 changes: 4 additions & 4 deletions src/hx/concurrent/executor/TimerExecutor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package hx.concurrent.executor;

import hx.concurrent.Future.FutureResult;
import hx.concurrent.executor.Executor.AbstractTaskFuture;
import hx.concurrent.executor.Executor.Task;
import hx.concurrent.executor.Executor.TaskFuture;
Expand All @@ -30,7 +29,8 @@ class TimerExecutor extends Executor {
}


public function submit<T>(task:Either2<Void->T, Void->Void>, ?schedule:Schedule):TaskFuture<T>
public function submit<T>(task:Either2<Void->T, Void->Void>, ?schedule:Schedule):TaskFuture<T> {
final schedule:Schedule = schedule == null ? Executor.NOW_ONCE : schedule;
return _stateLock.execute(function() {
if (state != RUNNING)
throw 'Cannot accept new tasks. Executor is not in state [RUNNING] but [$state].';
Expand All @@ -40,14 +40,14 @@ class TimerExecutor extends Executor {
while (i-- > 0)
if (_scheduledTasks[i].isStopped) _scheduledTasks.splice(i, 1);

final future = new TaskFutureImpl<T>(this, task, schedule == null ? Executor.NOW_ONCE : schedule);
final future = new TaskFutureImpl<T>(this, task, schedule);
switch (schedule) {
case ONCE(0):
default: _scheduledTasks.push(future);
}
return future;
});

}

override //
function onStop() {
Expand Down

0 comments on commit 0b4861a

Please sign in to comment.