Search in sources :

Example 1 with FltSource

use of suite.primitive.FltPrimitives.FltSource in project suite by stupidsing.

the class FltFunUtil method suck.

/**
 * Sucks data from a sink and produce into a source.
 */
public static FltSource suck(Sink<FltSink> fun) {
    NullableSyncQueue<Float> queue = new NullableSyncQueue<>();
    FltSink enqueue = c -> enqueue(queue, c);
    Thread thread = Thread_.startThread(() -> {
        try {
            fun.sink(enqueue);
        } finally {
            enqueue(queue, EMPTYVALUE);
        }
    });
    return () -> {
        try {
            return queue.take();
        } catch (InterruptedException ex) {
            thread.interrupt();
            return Fail.t(ex);
        }
    };
}
Also used : Iterator(java.util.Iterator) LogUtil(suite.os.LogUtil) Source2(suite.util.FunUtil2.Source2) FltSink(suite.primitive.FltPrimitives.FltSink) Source(suite.util.FunUtil.Source) NullableSyncQueue(suite.util.NullableSyncQueue) Thread_(suite.util.Thread_) Fun(suite.util.FunUtil.Fun) Flt_Obj(suite.primitive.FltPrimitives.Flt_Obj) FltObjPair(suite.primitive.adt.pair.FltObjPair) FltObjSource(suite.primitive.FltPrimitives.FltObjSource) Sink(suite.util.FunUtil.Sink) FltTest(suite.primitive.FltPrimitives.FltTest) Collections(java.util.Collections) FltSource(suite.primitive.FltPrimitives.FltSource) Fail(suite.util.Fail) NullableSyncQueue(suite.util.NullableSyncQueue) FltSink(suite.primitive.FltPrimitives.FltSink)

Example 2 with FltSource

use of suite.primitive.FltPrimitives.FltSource in project suite by stupidsing.

the class FltOutlet method equals.

@Override
public boolean equals(Object object) {
    if (Object_.clazz(object) == FltOutlet.class) {
        FltSource source1 = ((FltOutlet) object).source;
        float o0, o1;
        while (Objects.equals(o0 = source.source(), o1 = source1.source())) if (o0 == FltFunUtil.EMPTYVALUE && o1 == FltFunUtil.EMPTYVALUE)
            return true;
        return false;
    } else
        return false;
}
Also used : FltSource(suite.primitive.FltPrimitives.FltSource)

Example 3 with FltSource

use of suite.primitive.FltPrimitives.FltSource in project suite by stupidsing.

the class FltSet method forEach.

public void forEach(FltSink sink) {
    FltSource source = source_();
    float c;
    while ((c = source.source()) != FltFunUtil.EMPTYVALUE) sink.sink(c);
}
Also used : FltSource(suite.primitive.FltPrimitives.FltSource)

Aggregations

FltSource (suite.primitive.FltPrimitives.FltSource)3 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LogUtil (suite.os.LogUtil)1 FltObjSource (suite.primitive.FltPrimitives.FltObjSource)1 FltSink (suite.primitive.FltPrimitives.FltSink)1 FltTest (suite.primitive.FltPrimitives.FltTest)1 Flt_Obj (suite.primitive.FltPrimitives.Flt_Obj)1 FltObjPair (suite.primitive.adt.pair.FltObjPair)1 Fail (suite.util.Fail)1 Fun (suite.util.FunUtil.Fun)1 Sink (suite.util.FunUtil.Sink)1 Source (suite.util.FunUtil.Source)1 Source2 (suite.util.FunUtil2.Source2)1 NullableSyncQueue (suite.util.NullableSyncQueue)1 Thread_ (suite.util.Thread_)1