Search in sources :

Example 1 with LngSource

use of suite.primitive.LngPrimitives.LngSource in project suite by stupidsing.

the class LngOutlet method equals.

@Override
public boolean equals(Object object) {
    if (Object_.clazz(object) == LngOutlet.class) {
        LngSource source1 = ((LngOutlet) object).source;
        long o0, o1;
        while (Objects.equals(o0 = source.source(), o1 = source1.source())) if (o0 == LngFunUtil.EMPTYVALUE && o1 == LngFunUtil.EMPTYVALUE)
            return true;
        return false;
    } else
        return false;
}
Also used : LngSource(suite.primitive.LngPrimitives.LngSource)

Example 2 with LngSource

use of suite.primitive.LngPrimitives.LngSource in project suite by stupidsing.

the class LngSet method forEach.

public void forEach(LngSink sink) {
    LngSource source = source_();
    long c;
    while ((c = source.source()) != LngFunUtil.EMPTYVALUE) sink.sink(c);
}
Also used : LngSource(suite.primitive.LngPrimitives.LngSource)

Example 3 with LngSource

use of suite.primitive.LngPrimitives.LngSource in project suite by stupidsing.

the class LngFunUtil method suck.

/**
 * Sucks data from a sink and produce into a source.
 */
public static LngSource suck(Sink<LngSink> fun) {
    NullableSyncQueue<Long> queue = new NullableSyncQueue<>();
    LngSink 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) LngSource(suite.primitive.LngPrimitives.LngSource) Source2(suite.util.FunUtil2.Source2) Lng_Obj(suite.primitive.LngPrimitives.Lng_Obj) Source(suite.util.FunUtil.Source) NullableSyncQueue(suite.util.NullableSyncQueue) Thread_(suite.util.Thread_) LngObjSource(suite.primitive.LngPrimitives.LngObjSource) Fun(suite.util.FunUtil.Fun) Sink(suite.util.FunUtil.Sink) LngObjPair(suite.primitive.adt.pair.LngObjPair) LngTest(suite.primitive.LngPrimitives.LngTest) Collections(java.util.Collections) Fail(suite.util.Fail) LngSink(suite.primitive.LngPrimitives.LngSink) NullableSyncQueue(suite.util.NullableSyncQueue) LngSink(suite.primitive.LngPrimitives.LngSink)

Aggregations

LngSource (suite.primitive.LngPrimitives.LngSource)3 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LogUtil (suite.os.LogUtil)1 LngObjSource (suite.primitive.LngPrimitives.LngObjSource)1 LngSink (suite.primitive.LngPrimitives.LngSink)1 LngTest (suite.primitive.LngPrimitives.LngTest)1 Lng_Obj (suite.primitive.LngPrimitives.Lng_Obj)1 LngObjPair (suite.primitive.adt.pair.LngObjPair)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