Tornado.ioloop.IOLoop.add_callback C# (CSharp) Method

add_callback() public method

public add_callback ( System.Action callback ) : void
callback System.Action
return void
        public void add_callback(Action callback)
        {
            /*Calls the given callback on the next I/O loop iteration.

            It is safe to call this method from any thread at any time.
            Note that this is the *only* method in IOLoop that makes this
            guarantee; all other interaction with the IOLoop must be done
            from that IOLoop's thread.  add_callback() may be used to transfer
            control from other threads to the IOLoop's thread.
            */
            var list_empty = true;

            lock (_callback_lock)
            {
                list_empty = !_callbacks.Any();
                _callbacks.Add(callback); //stack_context.wrap(callback));
            }

            if (list_empty && thread.get_ident() != _thread_ident)
            {
                // If we're in the IOLoop's thread, we know it's not currently
                // polling.  If we're not, and we added the first callback to an
                // empty list, we may need to wake it up (it may wake up on its
                // own, but an occasional extra wake is harmless).  Waking
                // up a polling IOLoop is relatively expensive, so we try to
                // avoid it when we can.
                //todo _waker.wake();
            }
        }