Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  epoll.h

  Sprache: C
 

/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#pragma once

#include <sys/epoll.h>

#include <memory>
#include <optional>
#include <set>
#include <shared_mutex>

#include "common/libs/fs/shared_fd.h"
#include "common/libs/utils/result.h"

namespace cuttlefish {

struct EpollEvent {
  SharedFD fd;
  uint32_t events;
};

class Epoll {
 public:
  static Result<Epoll> Create();
  Epoll(); // Invalid instance
  Epoll(Epoll&&);
  Epoll& operator=(Epoll&&);

  Result<void> Add(SharedFD fd, uint32_t events);
  Result<void> Modify(SharedFD fd, uint32_t events);
  Result<void> AddOrModify(SharedFD fd, uint32_t events);
  Result<voidDelete(SharedFD fd);
  Result<std::optional<EpollEvent>> Wait();

 private:
  Epoll(SharedFD);

  /**
   * This read-write mutex is read-locked to perform epoll operations, and
   * write-locked to replace the file descriptor.
   *
   * A read-write mutex is used here to make it possible to update the watched
   * set while the epoll resource is being waited on by another thread, while
   * excluding the possibility of the move constructor or assignment constructor
   * from stealing the file descriptor out from under waiting threads.
   */

  std::shared_mutex epoll_mutex_;
  SharedFD epoll_fd_;
  /**
   * This read-write mutex is read-locked when interacting with it as a const
   * std::set, and write-locked when interacting with it as a std::set.
   */

  std::shared_mutex watched_mutex_;
  std::set<SharedFD> watched_;
};

}  // namespace cuttlefish

Messung V0.5 in Prozent
C=91 H=95 G=92

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik