File: CFMachPort_Lifetime.h

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (48 lines) | stat: -rw-r--r-- 1,961 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
    CFMachPort_Lifetime.h
    
    Copyright (c) 1998-2019, Apple Inc. and the Swift project authors
    
    Utilities for orchestrating the exact time/circumstances we decrement 
    mach_port rights for CF types that make use of: deallocate, invalidate
    and dispatch_sources.
*/

#include "CoreFoundation_Prefix.h"

#if !defined(__COREFOUNDATION_CFMACHPORT_LIFETIME__)
#define __COREFOUNDATION_CFMACHPORT_LIFETIME__ 1

CF_EXTERN_C_BEGIN

#include <mach/mach_port.h>
#include <os/lock.h>

typedef CF_ENUM(uint8_t, _CFMPLifetimeClient) {
    _CFMPLifetimeClientCFMachPort = 0,
    _CFMPLifetimeClientCFMessagePort = 1,
    // NOTE: We current support MAX_CLIENTS more clients (currently 2)
};

/// Records that that a given mach_port has been deallocated.
CF_PRIVATE void _cfmp_record_deallocation(_CFMPLifetimeClient const client, mach_port_t const port, Boolean const doSend, Boolean const doReceive);

/// Records that we have called dispatch_source_cancel.
CF_PRIVATE void _cfmp_record_intent_to_invalidate(_CFMPLifetimeClient const client, mach_port_t const port);

/// Records when the cancel-handler for a given dispatch_port is called.
CF_PRIVATE void _cfmp_source_invalidated(_CFMPLifetimeClient const client, mach_port_t const port);

/// Records that we have received a deadname notification for the specified port.
CF_PRIVATE void _cfmp_source_record_deadness(_CFMPLifetimeClient const client, mach_port_t const port);

/// For Foundation Only
/// Records when an nsmach port is going to be interested in a bridges CFMachPort
CF_EXPORT void _cfmp_record_nsmachport_is_interested(_CFMPLifetimeClient const client, mach_port_t const port);

/// For Foundation Only
/// Records when an nsmachport deallocates its context
CF_EXPORT void _cfmp_record_nsmachport_deallocation(_CFMPLifetimeClient const client, mach_port_t const port, Boolean const doSend, Boolean const doReceive);

CF_EXTERN_C_END
#endif // __COREFOUNDATION_CFMACHPORT_LIFETIME__