lib-edge/concurrent/edge/promises.rb
# Returns future which will fulfill when the message is added to the channel. Its value is the message.
# @param [Object] message
# @return [Future]
Returns future which will fulfill when the message is added to the channel. Its value is the message.
Returns future which will fulfill when the message is added to the channel . Its value is the message .
def push(message)
        @Mutex.synchronize do
          while true
            if @Probes.empty?
              if @Size > @Messages.size
                @Messages.push message
                return Promises.fulfilled_future message
              else
                pushed = Promises.resolvable_future
                @PendingPush.push [message, pushed]
                return pushed.with_hidden_resolvable
              end
            else
              probe = @Probes.shift
              if probe.fulfill [self, message], false
                return Promises.fulfilled_future(message)
              end
            end
          end
        end
      end
def push ( message ) @Mutex . synchronize do while true if @Probes . empty? if @Size > @Messages . size @Messages . push message return Promises . fulfilled_future message else pushed = Promises . resolvable_future @PendingPush . push [ message , pushed ] return pushed . with_hidden_resolvable end else probe = @Probes . shift if probe . fulfill [ self , message ] , false return Promises . fulfilled_future ( message ) end end end end end
Returns future which will fulfill when the message is added to the channel.
Returns future which will fulfill when the message is added to the channel .
None
Future
message
None