Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The signal handler is a static method so it is not bound to any instance of your class.</p> <p>The sigaction man page contains the paragraph (relating to the siginfo_t parameter):</p> <pre><code> * SIGPOLL/SIGIO fills in si_band and si_fd. The si_band event is a bit mask containing the same values as are filled in the revents field by poll(2). The si_fd field indicates the file descriptor for which the I/O event occurred. </code></pre> <p>Assuming that you want to continue with your current signal based design (poll() may be easier), I would suggest a static map of file descriptors to instances of your WorkWithSignals class.</p> <p>Then in the static signal handler, lookup the instance related to the given file descriptor (your socket_ field) and then call a non-static method to do the needed work with the specific object.</p> <p>to the decl of WorkWithSignals add</p> <pre><code>static std::map&lt;int, WorkWithSignals*&gt; object_registry_; </code></pre> <p>and the needed def in the source file. Manage membership in the map by adding to the map before registering the signal handler and removing from the map before destroying the object. Then:</p> <pre><code> void sigio_handler ( int sig, siginfo_t* siginfo, void* empty ) { std::map&lt;int, WorkWithSignals*&gt;::iterator it = object_registry_.find(siginfo-&gt;si_fd); if(it == object_registry_.end()) // handle error case assert(false); // Check that si_band is masked with the read flag as in the poll() call (look for revents) WorkWithSignals* obj = it-&gt;second; obj-&gt;received(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload