look at this concurrency library - https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/atomic/AtomicBool.hx and 
look at library sources: src/hx/concurrent/atomic/AtomicBool.hx, src/hx/concurrent/atomic/AtomicInt.hx, src/hx/concurrent/atomic/AtomicValue.hx, src/hx/concurrent/collection/Collection.hx,
src/hx/concurrent/collection/CopyOnWriteArray.hx, src/hx/concurrent/collection/OrderedCollection.hx, src/hx/concurrent/collection/Queue.hx, src/hx/concurrent/collection/SynchronizedArray.hx,
src/hx/concurrent/collection/SynchronizedLinkedList.hx, src/hx/concurrent/collection/SynchronizedMap.hx, src/hx/concurrent/event/AsyncEventDispatcher.hx,
src/hx/concurrent/event/EventDispatcher.hx, src/hx/concurrent/event/EventDispatcherWithHistory.hx, src/hx/concurrent/event/EventListenable.hx,
src/hx/concurrent/event/SyncEventDispatcher.hx, src/hx/concurrent/executor/Executor.hx, src/hx/concurrent/executor/Schedule.hx, src/hx/concurrent/executor/ThreadPoolExecutor.hx,
src/hx/concurrent/executor/TimerExecutor.hx, src/hx/concurrent/internal/Dates.hx, src/hx/concurrent/internal/Either2.hx, src/hx/concurrent/internal/Either3.hx,
src/hx/concurrent/internal/Ints.hx, src/hx/concurrent/internal/Macros.hx, src/hx/concurrent/internal/NullAnalysisHelper.hx, src/hx/concurrent/internal/OS.hx,
src/hx/concurrent/lock/Acquirable.hx, src/hx/concurrent/lock/RLock.hx, src/hx/concurrent/lock/RWLock.hx, src/hx/concurrent/lock/Semaphore.hx, src/hx/concurrent/thread/BackgroundProcess.hx,
src/hx/concurrent/thread/ThreadPool.hx, src/hx/concurrent/thread/Threads.hx, src/hx/concurrent/ConcurrentException.hx, src/hx/concurrent/CountDownLatch.hx,
src/hx/concurrent/Future.hx, src/hx/concurrent/Service.hx
and look at test example: test/hx/concurrent/TestRunner.hx
also look at this rx library - https://github.com/GlassySundew/RxHaxe and
look at library sources: 
rx/disposables/Assignable.hx, rx/disposables/Binary.hx, rx/disposables/Boolean.hx,rx/disposables/Composite.hx,rx/disposables/ISubscription.hx,rx/disposables/MultipleAssignment.hx,rx/disposables/SerialAssignment.hx,rx/disposables/SingleAssignment.hx,rx/observables/Amb.hx,rx/observables/Append.hx,rx/observables/Average.hx,rx/observables/Blocking.hx,rx/observables/Buffer.hx,rx/observables/BufferCount.hx,rx/observables/BufferWhen.hx,rx/observables/Catch.hx,rx/observables/CombineLatest.hx,rx/observables/Concat.hx,rx/observables/Contains.hx,rx/observables/Create.hx,rx/observables/CurrentThread.hx,rx/observables/DefaultIfEmpty.hx,rx/observables/Defer.hx,rx/observables/Delay.hx,rx/observables/Dematerialize.hx,rx/observables/Distinct.hx,rx/observables/DistinctUntilChanged.hx,rx/observables/ElementAt.hx,rx/observables/Empty.hx,rx/observables/EndWith.hx,rx/observables/Error.hx,rx/observables/Filter.hx,rx/observables/Find.hx,rx/observables/First.hx,rx/observables/IObservable.hx,rx/observables/IScheduled.hx,rx/observables/IgnoreElements.hx,rx/observables/Immediate.hx,rx/observables/Last.hx,rx/observables/Length.hx,rx/observables/MakeScheduled.hx,rx/observables/Map.hx,rx/observables/Materialize.hx,rx/observables/Merge.hx,rx/observables/Never.hx,rx/observables/NewThread.hx,rx/observables/Return.hx,rx/observables/Scan.hx,rx/observables/Signal.hx,rx/observables/Single.hx,rx/observables/Skip.hx,rx/observables/SkipUntil.hx,rx/observables/Take.hx,rx/observables/TakeLast.hx,rx/observables/TakeUntil.hx,rx/observables/Test.hx,rx/observables/Throttle.hx,rx/observables/Timestamp.hx,rx/observables/Timestamped.hx,rx/observers/AsyncLockObserver.hx,rx/observers/CheckedObserver.hx,rx/observers/IObserver.hx,rx/observers/ObserverBase.hx,rx/observers/SynchronizedObserver.hx,rx/schedulers/Base.hx,rx/schedulers/CurrentThread.hx,rx/schedulers/DiscardableAction.hx,rx/schedulers/IScheduler.hx,rx/schedulers/Immediate.hx,rx/schedulers/MakeScheduler.hx,rx/schedulers/NewThread.hx,rx/schedulers/Test.hx,rx/schedulers/TimedAction.hx,rx/subjects/Async.hx,rx/subjects/Behavior.hx,rx/subjects/ISubject.hx,rx/subjects/Replay.hx,
rx/AsyncLock.hx,rx/AtomicData.hx,rx/Core.hx,rx/Mutex.hx,rx/Observable.hx,rx/ObservableFactory.hx,rx/Observer.hx,rx/Scheduler.hx,rx/Subject.hx,rx/Subscription.hx,rx/Thread.hx,rx/Utils.hx,
rx/notifiers/Notification.hx
implement ObserveOn and SubscribeOn