Re: Identifying quickly what is the current process

From: Philipp A. Hartmann <philipp.hartmann@offis.de>
Date: Fri Mar 12 2010 - 10:46:01 PST

On 12/03/10 19:25, Stuart Swan wrote:
> I also like the idea of adding sc_process_handle::operator< also, but I'm not quite
> sure how it would be defined. Would the comparison be based on the full process name,
> if the process handle is valid ?

  Since the referenced process object stays valid as long as the last
referencing handle lives on (even after termination of the process), it
would be good enough to just use the plain process pointer inside.

  This is actually the benefit of the explicit handle over using the raw
pointer e.g. as a key in a map: The referenced process object could get
deleted if the process terminates and no handle is still referencing it.

  Two invalid handles (with internal pointers being NULL) are then
considered equivalent (a<b == false && b<a == false), which is OK for
the total ordering, I think.

So the implementation could simply look like (based on the OSCI
implementation):

inline bool operator < (
    const sc_process_handle& left, const sc_process_handle& right )
  { return left.m_target_p < right.m_target_p; }

  Strictly speaking, this is not guaranteed to work by the C++ standard.
 For a total ordering over arbitrary pointers (not from within the same
object/array), you should use std::less. But this is minor issue for
the usual platforms.

Greetings from Oldenburg,
Philipp

[snip]

-- 
Philipp A. Hartmann
Hardware/Software Design Methodology Group
OFFIS
R&D Division Transportation | FuE-Bereich Verkehr
Escherweg 2 · 26121 Oldenburg · Germany
Phone/Fax: +49-441-9722-420/282 · PGP: 0x9161A5C0 · http://www.offis.de/

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Mar 12 10:46:20 2010

This archive was generated by hypermail 2.1.8 : Fri Mar 12 2010 - 10:46:21 PST