Ejemplo n.º 1
0
        internal Chan <T> GetOrCreate <T>() where T : struct
        {
            lock (lockObj)
            {
                var type = typeof(T);
                if (chs.ContainsKey(type))
                {
                    return((Chan <T>)chs[type]);
                }

                chs[type] = new Chan <T>();
                return((Chan <T>)chs[type]);
            }
        }
Ejemplo n.º 2
0
        public WaitResultInstruction()
        {
            var ch = Chan <T> .Make();

            ch.Receive(
                (result, ok) =>
            {
                if (ok)
                {
                    _result = result;
                }
                _keepWaiting = false;
            }
                );
        }
Ejemplo n.º 3
0
        internal bool IsExists <T>(out Chan <T> ch) where T : struct
        {
            lock (lockObj)
            {
                var type = typeof(T);
                if (chs.ContainsKey(type))
                {
                    ch = (Chan <T>)chs[type];
                    return(true);
                }

                ch = null;
                return(false);
            }
        }
Ejemplo n.º 4
0
        public ForInstruction(Action <T> onReceive)
        {
            var ch = Chan <T> .Make();

            ch.Receive(
                (t, ok) =>
            {
                if (!ok)
                {
                    _keepWaiting = false;
                    return;
                }
                onReceive(t);
            }
                );
        }