Create a new reply for an existing Thread.

        Mark thread as unread for all other participants, and
        mark thread as read by replier.
175742
def new_reply(cls, thread, user, content):
        
        msg = cls.objects.create(thread=thread, sender=user, content=content)
        thread.userthread_set.exclude(user=user).update(deleted=False, unread=True)
        thread.userthread_set.filter(user=user).update(deleted=False, unread=False)
        message_sent.send(sender=cls, message=msg, thread=thread, reply=True)
        return msg
1160529
Map<AsyncLogger, NewEpochResponseProto> createNewUniqueEpoch()
      throws IOException {
    Preconditions.checkState(!loggers.isEpochEstablished(),
        "epoch already created");
    
    Map<AsyncLogger, GetJournalStateResponseProto> lastPromises =
      loggers.waitForWriteQuorum(loggers.getJournalState(),
          getJournalStateTimeoutMs, "getJournalState()");
    
    long maxPromised = Long.MIN_VALUE;
    for (GetJournalStateResponseProto resp : lastPromises.values()) {
      maxPromised = Math.max(maxPromised, resp.getLastPromisedEpoch());
    }
    assert maxPromised >= 0;
    
    long myEpoch = maxPromised + 1;
    Map<AsyncLogger, NewEpochResponseProto> resps =
        loggers.waitForWriteQuorum(loggers.newEpoch(nsInfo, myEpoch),
            newEpochTimeoutMs, "newEpoch(" + myEpoch + ")");
        
    loggers.setEpoch(myEpoch);
    return resps;
  }
551027
def join(self, *args, **kwargs):
        
        super(ThreadReturn, self).join(*args, **kwargs)
        return self._return
86116
def _reader_thread_func(self, read_stdout: bool) -> None:
        
        if read_stdout:
            read_stream = self._proc.stdout
            write_stream = self._stdout
        else:
            read_stream = self._proc.stderr
            write_stream = self._stderr

        # The thread should have been started only if this stream was a pipe
        assert read_stream is not None

        # Run until process completes
        while self._proc.poll() is None:
            # noinspection PyUnresolvedReferences
            available = read_stream.peek()
            if available:
                read_stream.read(len(available))
                self._write_bytes(write_stream, available)
1208203
def start
      @stop = false
      @reader_thread = Thread.new {
        begin
          message = @port.gets(@separator)
          changed
          notify_observers(message)
        end while (@stop == false)
      }
    end
235248
def respond_to_missing?(method, include_private = false)
      __respond_to_writer?(method) ||
        __respond_to_method_for_read?(method, *args, &block) ||
        __respond_to_method_for_write?(method) ||
        super
    end
334458
def create(self, req, parent, name, mode, fi):
        
        self.reply_err(req, errno.ENOSYS)
1045693
def mark_topics_read(self, request, pk):
        
        track_handler.mark_forums_read([self.forum, ], request.user)
        messages.success(request, self.success_message)
        return HttpResponseRedirect(self.get_forum_url())
555648
def get_all_messages_in_thread(self, participant_id, thread_id, check_who_read=True):
        
        try:
            messages = Message.objects.filter(thread__id=thread_id).\
                order_by('-id').\
                select_related('thread').\
                prefetch_related('thread__participation_set', 'thread__participation_set__participant')
        except Exception:
            return Message.objects.none()

        messages = self.check_who_read(messages)
        return messages
876804
private void incrementThreadLockCount()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "incrementThreadLockCount", this);
    //get the current thread
    Thread currentThread = Thread.currentThread();
    //get it's current read lock count
    LockCount count = (LockCount) readerThreads.get(currentThread);
    //if it doesn't exist, create it
    if(count == null)
    {
      count = new LockCount();
      readerThreads.put(currentThread, count);
    }
    //increment the count
    if(count.count == 0) readerThreadCount++;
    count.count++;
    readLockCount++;
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "incrementThreadLockCount");
  }
377141
def reply_with_message(self, rep_msg):
        
        self._post_reply()
        return self.client_connection.reply(rep_msg, self.msg)
941438
def newResponseEvent(self):
        
        respEvt = ResponseEvent()
        self.respLock.acquire()
        eid = id(respEvt)
        self.respEvents[eid] = respEvt
        self.respLock.release()
        return (respEvt,eid)
664054
def _recv_thread(self):
        
        for msg, metadata in self._source:
            if msg.msg_type:
                self._call(msg, **metadata)
        # Break any upstream iterators
        for sink in self._sinks:
            i = sink()
            if i is not None:
                i.breakiter()
        self._dead = True
848212
def mark_as_read(self, room_name):
        
        api_meth = self.set_user_items_url(room_name)
        message_ids = self.unread_items(room_name).get('chat')
        if message_ids:
            return self.post(api_meth, data={'chat': message_ids})
        else:
            raise GitterItemsError(room_name)
331108
def add_comment(self, body, allow_create=False, allow_hashes=False,
                    summary=None):
        
        thread_id = self.lookup_thread_id()
        if not allow_create and not self.redis.exists(thread_id):
            raise ValueError('Tried to add comment to non-exist thread %s' % (
                thread_id))

        comment = comments.SingleComment(
            self.user, datetime.datetime.now(datetime.timezone.utc), body, 
            summary=summary)
        lpush = self.redis.lpush(thread_id, comment.to_json())
        logging.debug('Pushing comment to redis returned %s', str(lpush))
        if self.ltrim:
            ltrim = self.redis.ltrim(thread_id, 0, self.ltrim)
            logging.debug('Redis ltrim returend %s', str(ltrim))
        else:
            ltrim = None

        return {'status': 'OK', 'lpush': lpush, 'ltrim': ltrim}
684277
def update(self, force=False):
        

        # The thread has already 404'ed, this function shouldn't do anything anymore.
        if self.is_404 and not force:
            return 0

        if self._last_modified:
            headers = {'If-Modified-Since': self._last_modified}
        else:
            headers = None

        # random connection errors, just return 0 and try again later
        try:
            res = self._board._requests_session.get(self._api_url, headers=headers)
        except:
            # try again later
            return 0

        # 304 Not Modified, no new posts.
        if res.status_code == 304:
            return 0

        # 404 Not Found, thread died.
        elif res.status_code == 404:
            self.is_404 = True
            # remove post from cache, because it's gone.
            self._board._thread_cache.pop(self.id, None)
            return 0

        elif res.status_code == 200:
            # If we somehow 404'ed, we should put ourself back in the cache.
            if self.is_404:
                self.is_404 = False
                self._board._thread_cache[self.id] = self

            # Remove
            self.want_update = False
            self.omitted_images = 0
            self.omitted_posts = 0

            self._last_modified = res.headers['Last-Modified']
            posts = res.json()['posts']

            original_post_count = len(self.replies)
            self.topic = Post(self, posts[0])

            if self.last_reply_id and not force:
                self.replies.extend(Post(self, p) for p in posts if p['no'] > self.last_reply_id)
            else:
                self.replies[:] = [Post(self, p) for p in posts[1:]]

            new_post_count = len(self.replies)
            post_count_delta = new_post_count - original_post_count
            if not post_count_delta:
                return 0

            self.last_reply_id = self.replies[-1].post_number

            return post_count_delta

        else:
            res.raise_for_status()
1052018
def async_make_reply(msgname, types, arguments_future, major):
    """"""
    arguments = yield arguments_future
    raise gen.Return(make_reply(msgname, types, arguments, major))