【iOS】通知原理

news2024/10/5 13:56:23

我们可以通过看通知的实现机制来了解通知中心是怎么实现对观察者的引用的。由于苹果对Foundation源码是不开源的,我们具体就参考一下GNUStep的源码实现。GNUStep的源码地址为:GNUStep源码GitHub下载地址, 具体源码可以进行查看。

通知的主要流程

  • 通知全局对象是一个名为NCTbl的结构体,里头有三个重要的成员变量,分别是是两张GSIMapTable表:namednameless,及单链表wildcard
    • named是存放传入了通知名称的通知的hash表。
    • nameless是存放没有传入通知名称但是传入了消息发送者object的通知的hash表。
    • wildcard是存既没有传入通知名称,也没有传入消息发送者的通知的链表。
  • 我们每次注册一个通知的时候,所注册的那个通知就会按照这三种类型来对号入座放入相应的NCTbl的结构体中的GSIMapTablewildcard
  • 接着我们每次发送通知(发送消息)的时候,就是先创建存储所有匹配通知的数组GSIArray,按照以下流程将符合条件的通知添加到数组GSIArray中。
    1. 获取所有wildcard中符合条件的通知并添加到数组GSIArray
    2. nameless表中查找符合条件的通知并添加到数组GSIArray
    3. named表中查找符合条件的通知并添加到数组GSIArray
  • 最后待所有符合条件的通知都添加好之后,就遍历整个GSIArray数组并依次调用performSelector:withObject处理通知消息发送。

通知原理

数据结构

_GSIMapTable映射表数据结构图如下:

相关数据结构:

  • _GSIMapTable映射表包含了nodeChunksbuketsbuketCountchunkCount
  • nodeChunksnodeChunks 是一个指向 GSIMapNode 指针数组的指针。它用于管理动态分配的内存块,这些内存块用于存储哈希表的节点(GSIMapNode)。
  • bukets:记录单链表节点指针数组的各个链表的节点数量及链表首部地址。
  • bucketCount:记录了node节点的数目。
  • chunkCount:记录单链表节点指针数组的数目。
  • nodeCount:哈希表中当前已使用的节点数量。

定义源代码:

typedef struct _GSIMapBucket GSIMapBucket_t;
typedef struct _GSIMapNode GSIMapNode_t;

typedef GSIMapBucket_t *GSIMapBucket;
typedef GSIMapNode_t *GSIMapNode;

typedef struct _GSIMapTable GSIMapTable_t;
typedef GSIMapTable_t *GSIMapTable;

struct	_GSIMapNode {
    GSIMapNode	nextInBucket;	/* Linked list of bucket.	*/
    GSIMapKey	key;
#if	GSI_MAP_HAS_VALUE
    GSIMapVal	value;
#endif
};

struct	_GSIMapBucket {
    uintptr_t	nodeCount;	/* Number of nodes in bucket.	*/
    GSIMapNode	firstNode;	/* The linked list of nodes.	*/
};

struct	_GSIMapTable {
  NSZone	*zone;
  uintptr_t	nodeCount;	/* Number of used nodes in map.	*/
  uintptr_t	bucketCount;	/* Number of buckets in map.	*/
  GSIMapBucket	buckets;	/* Array of buckets.		*/
  GSIMapNode	freeNodes;	/* List of unused nodes.	*/
  uintptr_t	chunkCount;	/* Number of chunks in array.	*/
  GSIMapNode	*nodeChunks;	/* Chunks of allocated memory.	*/
  uintptr_t	increment;
#ifdef	GSI_MAP_EXTRA
  GSI_MAP_EXTRA	extra;
#endif
};

具体的从映射表中添加/删除的代码如下:

GS_STATIC_INLINE GSIMapBucket
GSIMapPickBucket(unsigned hash, GSIMapBucket buckets, uintptr_t bucketCount)
{
    return buckets + hash % bucketCount;
}

GS_STATIC_INLINE GSIMapBucket
GSIMapBucketForKey(GSIMapTable map, GSIMapKey key)
{
    return GSIMapPickBucket(GSI_MAP_HASH(map, key),
                            map->buckets, map->bucketCount);
}

GS_STATIC_INLINE void
GSIMapLinkNodeIntoBucket(GSIMapBucket bucket, GSIMapNode node)
{
    node->nextInBucket = bucket->firstNode;
    bucket->firstNode = node;
}

GS_STATIC_INLINE void
GSIMapUnlinkNodeFromBucket(GSIMapBucket bucket, GSIMapNode node)
{
    if (node == bucket->firstNode)
    {
        bucket->firstNode = node->nextInBucket;
    }
    else
    {
        GSIMapNode	tmp = bucket->firstNode;
        
        while (tmp->nextInBucket != node)
        {
            tmp = tmp->nextInBucket;
        }
        tmp->nextInBucket = node->nextInBucket;
    }
    node->nextInBucket = 0;
}

其实就是一个hash表结构,可以以数组的形式取到每个单链表首元素,再利用链表结构增删。

通知全局对象表结构如下:

typedef struct NCTbl {
    Observation		*wildcard;	/* Get ALL messages*///获取所有消息
    GSIMapTable		nameless;	/* Get messages for any name.*///获取任何名称的消息
    GSIMapTable		named;		/* Getting named messages only.*///仅获取命名消息
    unsigned		lockCount;	/* Count recursive operations.	*///递归运算计数
    NSRecursiveLock	*_lock;		/* Lock out other threads.	*///锁定其他线程
    Observation		*freeList;
    Observation		**chunks;
    unsigned		numChunks;
    GSIMapTable		cache[CACHESIZE];
    unsigned short	chunkIndex;
    unsigned short	cacheIndex;
} NCTable;

其中数据结构中重要的是两张GSIMapTable表:namednameless,及单链表wildcard

  • named,保存着传入通知名称的通知hash
  • nameless,保存没有传入通知名称但传入了消息发送者objecthash
  • wildcard,保存既没有通知名称又没有传入object的通知的单链表

保存含有通知名称的通知表named需要注册object对象,因此该表结构体通过传入的name作为key。而它的value也是一个GSIMapTable表,这个表用于存储对应的object对象的observer对象;

对没有传入通知名称只传入object对象的通知表nameless而言,只需要保存objectobserver的对应关系,因此object作为keyobserver作为value

具体的添加观察者的核心函数(block形式只是该函数的包装)大致代码如下:

- (void) addObserver: (id)observer
            selector: (SEL)selector
                name: (NSString*)name
              object: (id)object
{
    Observation	*list;
    Observation	*o;
    GSIMapTable	m;
    GSIMapNode	n;

    //入参检查异常处理
    ...
		//table加锁保持数据一致性
    lockNCTable(TABLE);
		//创建Observation对象包装相应的调用函数
    o = obsNew(TABLE, selector, observer);
		//处理存在通知名称的情况
    if (name)
    {
        //table表中获取相应name的节点
        n = GSIMapNodeForKey(NAMED, (GSIMapKey)(id)name);
        if (n == 0)
        {
           //未找到相应的节点,则创建内部GSIMapTable表,以name作为key添加到talbe中
          m = mapNew(TABLE);
          name = [name copyWithZone: NSDefaultMallocZone()];
          GSIMapAddPair(NAMED, (GSIMapKey)(id)name, (GSIMapVal)(void*)m);
          GS_CONSUMED(name)
        }
        else
        {
            //找到则直接获取相应的内部table
          	m = (GSIMapTable)n->value.ptr;
        }

        //内部table表中获取相应object对象作为key的节点
        n = GSIMapNodeForSimpleKey(m, (GSIMapKey)object);
        if (n == 0)
        {
          	//不存在此节点,则直接添加observer对象到table中
            o->next = ENDOBS;//单链表observer末尾指向ENDOBS
            GSIMapAddPair(m, (GSIMapKey)object, (GSIMapVal)o);
        }
        else
        {
          	//存在此节点,则获取并将obsever添加到单链表observer中
            list = (Observation*)n->value.ptr;
            o->next = list->next;
            list->next = o;
        }
    }
    //只有观察者对象情况
    else if (object)
    {
      	//获取对应object的table
        n = GSIMapNodeForSimpleKey(NAMELESS, (GSIMapKey)object);
        if (n == 0)
        {
          	//未找到对应object key的节点,则直接添加observergnustep-base-1.25.0
            o->next = ENDOBS;
            GSIMapAddPair(NAMELESS, (GSIMapKey)object, (GSIMapVal)o);
        }
        else
        {
          	//找到相应的节点则直接添加到链表中
            list = (Observation*)n->value.ptr;
            o->next = list->next;
            list->next = o;
        }
    }
    //处理即没有通知名称也没有观察者对象的情况
    else
    {
      	//添加到单链表中
        o->next = WILDCARD;
        WILDCARD = o;
    }
		//解锁
    unlockNCTable(TABLE);
}

对于block形式代码如下:

- (id) addObserverForName: (NSString *)name 
                   object: (id)object 
                    queue: (NSOperationQueue *)queue 
               usingBlock: (GSNotificationBlock)block
{
    GSNotificationObserver *observer = 
        [[GSNotificationObserver alloc] initWithQueue: queue block: block];

    [self addObserver: observer 
             selector: @selector(didReceiveNotification:) 
                 name: name 
               object: object];

    return observer;
}

- (id) initWithQueue: (NSOperationQueue *)queue 
               block: (GSNotificationBlock)block
{
    self = [super init];
    if (self == nil)
        return nil;

    ASSIGN(_queue, queue); 
    _block = Block_copy(block);
    return self;
}

- (void) didReceiveNotification: (NSNotification *)notif
{
    if (_queue != nil)
    {
        GSNotificationBlockOperation *op = [[GSNotificationBlockOperation alloc] 
            initWithNotification: notif block: _block];

        [_queue addOperation: op];
    }
    else
    {
        CALL_BLOCK(_block, notif);
    }
}

对于block形式通过创建GSNotificationObserver对象,该对象会通过Block_copy拷贝block,并确定通知操作队列,通知的接收处理函数didReceiveNotification中是通过addOperation来实现指定操作队列处理,否则直接执行block

发送通知的核心函数大致逻辑如下:

- (void) _postAndRelease: (NSNotification*)notification
{
    //入参检查校验
    //创建存储所有匹配通知的数组GSIArray
   	//加锁table避免数据一致性问题
    //获取所有WILDCARD中的通知并添加到数组中
    //查找NAMELESS表中指定对应消息发送者对象object的通知并添加到数组中
	//查找NAMED表中相应的通知并添加到数组中
    //解锁table
    //遍历整个数组并依次调用performSelector:withObject处理通知消息发送
    //解锁table并释放资源
}

上面发送的重点就是获取所有匹配的通知,并通过performSelector:withObject发送通知消息,因此通知发送和接收通知的线程是同一个线程(block形式通过操作队列来指定队列处理)。

通知中的各个部分

NSNotification

NSNotification包含了消息发送的一些信息,包括name消息名称、object消息发送者、userinfo消息发送者携带的额外信息,其类结构如下:

@interface NSNotification : NSObject <NSCopying, NSCoding>

@property (readonly, copy) NSNotificationName name;
@property (nullable, readonly, retain) id object;
@property (nullable, readonly, copy) NSDictionary *userInfo;

- (instancetype)initWithName:(NSNotificationName)name object:(nullable id)object userInfo:(nullable NSDictionary *)userInfo API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)) NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;

@end

@interface NSNotification (NSNotificationCreation)

+ (instancetype)notificationWithName:(NSNotificationName)aName object:(nullable id)anObject;
+ (instancetype)notificationWithName:(NSNotificationName)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo;

- (instancetype)init /*API_UNAVAILABLE(macos, ios, watchos, tvos)*/;	/* do not invoke; not a valid initializer for this class */

@end

可以通过实例方式构建NSNotification对象,也可以通过类方式构建。(- (instancetype)init这个方法是初始化方法,但在 NSNotification 类中,它被标记为 API_UNAVAILABLE,表示不可用。因此,不能直接使用此方法来初始化 NSNotification 对象。)

NSNotificationCenter

NSNotificationCenter消息通知中心,全局单例模式(每个进程都默认有一个默认的通知中心,用于进程内通信),通过如下方法获取通知中心:

+ (NSNotificationCenter *)defaultCenter

对于macOS系统,每个进程都有一个默认的分布式通知中心NSDistributedNotificationCenter,具体可参见:NSDistributedNotificationCenter。

具体的注册通知消息方法如下:

//注册观察者
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject;
- (id <NSObject>)addObserverForName:(nullable NSNotificationName)name object:(nullable id)obj queue:(nullable NSOperationQueue *)queue usingBlock:(void (^)(NSNotification *note))block API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));

注册观察者方法提供了两种形式:selectorblock,对于添加指定观察者对象的方式,observer不能为nilblock方式会执行copy方法,返回的是使用的匿名观察者对象,且指定观察者处理消息的操作对象NSOperationQueue

对于指定的消息名称name及发送者对象object都可以为空,即接收所有消息及所有发送对象发送的消息;若指定其中之一或者都指定,则表示接收指定消息名称及发送者的消息

对于block方式指定的queue队列可为nil,则默认在发送消息线程处理;若指定主队列,即主线程处理,避免执行UI操作导致异常

注意:注册观察者通知消息应避免重复注册,会导致重复处理通知消息,且block对持有外部对象,因此需要避免引发循环引用问题。

消息发送方法如下:

//发送消息
- (void)postNotification:(NSNotification *)notification;
- (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject;
- (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo;

可以通过NSNotification包装的通知消息对象发送消息,也可以分别指定消息名称、发送者及携带的信息来发送,且为同步执行模式,需要等待所有注册的观察者处理完成该通知消息,方法才会返回继续往下执行,且对于block形式处理通知对象是在注册消息指定的队列中执行,对于非block方式是在同一线程处理

注意:消息发送类型需要与注册时类型一致,即若注册观察者同时指定了消息名称及发送者,则发送消息也需要同时指定消息名称及发送者,否则无法接收到消息

移除观察者方法如下:

//移除观察者
- (void)removeObserver:(id)observer;
- (void)removeObserver:(id)observer name:(nullable NSNotificationName)aName object:(nullable id)anObject;

可移除指定的观察者所有通知消息,即该观察者不再接收任何消息,一般用于观察者对象dealloc释放后调用,但在iOS9macos10.11之后不需要手动调用,dealloc已经自动处理。

If your app targets iOS 9.0 and later or macOS 10.11 and later, you don't need to unregister an observer in its dealloc method. Otherwise, you should call this method or removeObserver:name:object: before observer or any object specified in addObserverForName:object:queue:usingBlock: or addObserver:selector:name:object:is deallocated.
翻译如下:
如果你的应用目标是iOS 9.0及更高版本或macOS 10.11及更高版本,你不需要在dealloc方法中注销观察者。否则,您应该调用此方法或在取消分配addObserverForName:object:queue:usingBlock:或addObserver:selector:name:object:中指定的任何对象之前删除观察者:name:object:方法。

NSNotificationQueue

NSNotificationQueue通知队列实现了通知消息的管理,如消息发送时机、消息合并策略,并且为先入先出方式管理消息,但实际消息发送仍然是通过NSNotificationCenter通知中心完成。

@interface NSNotificationQueue : NSObject
@property (class, readonly, strong) NSNotificationQueue *defaultQueue;

- (instancetype)initWithNotificationCenter:(NSNotificationCenter *)notificationCenter NS_DESIGNATED_INITIALIZER;

- (void)enqueueNotification:(NSNotification *)notification postingStyle:(NSPostingStyle)postingStyle;
- (void)enqueueNotification:(NSNotification *)notification postingStyle:(NSPostingStyle)postingStyle coalesceMask:(NSNotificationCoalescing)coalesceMask forModes:(nullable NSArray<NSRunLoopMode> *)modes;

- (void)dequeueNotificationsMatching:(NSNotification *)notification coalesceMask:(NSUInteger)coalesceMask;

可以通过defaultQueue获取当前线程绑定的通知消息队列,也可以通过initWithNotificationCenter:来指定通知管理中心,具体的消息管理策略如下:

NSPostingStyle:用于配置通知什么时候发送

  • NSPostASAP:在当前通知调用或者计时器结束发出通知
  • NSPostWhenIdle:当runloop处于空闲时发出通知
  • NSPostNow:在合并通知完成之后立即发出通知

NSNotificationCoalescing(注意这是一个NS_OPTIONS):用于配置如何合并通知:

  • NSNotificationNoCoalescing:不合并通知
  • NSNotificationCoalescingOnName:按照通知名字合并通知
  • NSNotificationCoalescingOnSender:按照传入的object合并通知

对于NSNotificationQueue通知队列若不是指定NSPostNow立即发送模式,则可以通过runloop实现异步发送

NSNotification与多线程

对于NSNotification与多线程官方文档说明如下:

In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself.
翻译如下:
在多线程应用程序中,通知始终在发布通知的线程中传递,该线程可能与观察者注册自身的线程不同。

即是NSNotification的发送与接收处理都是在同一个线程中,对于block形式则是接收处理在指定的队列中处理,上面已说明这点,这里重点说明下如何接收处理在其他线程处理。

For example, if an object running in a background thread is listening for notifications from the user interface, such as a window closing, you would like to receive the notifications in the background thread instead of the main thread. In these cases, you must capture the notifications as they are delivered on the default thread and redirect them to the appropriate thread.
翻译如下:
例如,如果在后台线程中运行的对象正在侦听来自用户界面的通知,例如窗口关闭,则您希望在后台线程而不是主线程中接收通知。在这些情况下,您必须在通知在默认线程上传递时捕获通知,并将其重定向到适当的线程。

如官方说明;对于处理通知线程不是主线程的,如后台线程,存在此处理场景,并且官方也提供了具体的实施方案:

一种重定向的实现思路是自定义一个通知队列(注意,不是NSNotificationQueue对象,而是一个数组),让这个队列去维护那些我们需要重定向的Notification。我们仍然是像平常一样去注册一个通知的观察者,当Notification来了时,先看看post这个Notification的线程是不是我们所期望的线程,如果不是,则将这个Notification存储到我们的队列中,并发送一个mach信号到期望的线程中,来告诉这个线程需要处理一个Notification。指定的线程在收到信号后,将Notification从队列中移除,并进行处理。

官方demo如下:

@interface MyThreadedClass: NSObject
/* Threaded notification support. */
@property NSMutableArray *notifications;
@property NSThread *notificationThread;
@property NSLock *notificationLock;
@property NSMachPort *notificationPort;
 
- (void) setUpThreadingSupport;
- (void) handleMachMessage:(void *)msg;
- (void) processNotification:(NSNotification *)notification;
@end

通知线程定义类MyThreadedClass包含了用于记录所有通知消息的通知消息队列notifications,记录当前通知接收线程notificationThread,多线程并发处理需要的互斥锁NSLock,用于线程间通信通知处理线程处理通知消息的NSMachPort;并提供了设置线程属性、处理mach消息及处理通知消息的实例方法

对于setUpThreadSupport方法如下:

- (void) setUpThreadingSupport {
    if (self.notifications) {
        return;
    }
    self.notifications      = [[NSMutableArray alloc] init];
    self.notificationLock   = [[NSLock alloc] init];
    self.notificationThread = [NSThread currentThread];
 
    self.notificationPort = [[NSMachPort alloc] init];
    [self.notificationPort setDelegate:self];
    [[NSRunLoop currentRunLoop] addPort:self.notificationPort
            forMode:(NSString __bridge *)kCFRunLoopCommonModes];
}

主要是初始化类属性,并指定NSMachPort代理及添加至处理线程的runloop中;若mach消息到达而接收线程的runloop没有运行时,内核会保存此消息,直到下一次runloop运行;也可以通过performSelectro:inThread:withObject:waitUtilDone:modes实现,不过对于子线程需要开启runloop,否则该方法失效,且需指定waitUtilDone参数为NO异步调用。

NSMachPortDelegate协议方法处理如下:

- (void) handleMachMessage:(void *)msg {
    [self.notificationLock lock];
 
    while ([self.notifications count]) {
        NSNotification *notification = [self.notifications objectAtIndex:0];
        [self.notifications removeObjectAtIndex:0];
        [self.notificationLock unlock];
        [self processNotification:notification];
        [self.notificationLock lock];
    };
 
    [self.notificationLock unlock];
}

NSMachPort协议方法主要是检查需要处理的任何通知消息并迭代处理(防止并发发送大量端口消息,导致消息丢失),处理完成后同步从消息队列中移除;

通知处理方法如下:

- (void)processNotification:(NSNotification *)notification {
    if ([NSThread currentThread] != notificationThread) {
        // 将通知转发到正确的线程。
        [self.notificationLock lock];
        [self.notifications addObject:notification];
        [self.notificationLock unlock];
        [self.notificationPort sendBeforeDate:[NSDate date]
                components:nil
                from:nil
                reserved:0];
    }
    else {
        // Process the notification here;
    }
}

为区分NSMachPort协议方法内部调用及通知处理消息回调,需要通过判定当前处理线程来处理不同的通知消息处理方式;对于通知观察回调,将消息添加至消息队列并发送线程间通信mach消息;其实本方案的核心就是通过线程间异步通信NSMachPort来通知接收线程处理通知队列中的消息;

对于接收线程需要调用如下方法启动通知消息处理:

[self setupThreadingSupport];
[[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(processNotification:)
        name:@"NotificationName"//通知消息名称,可自定义
        object:nil];

官方也给出了此方案的问题及思考:

First, all threaded notifications processed by this object must pass through the same method (processNotification:). Second, each object must provide its own implementation and communication port. A better, but more complex, implementation would generalize the behavior into either a subclass of NSNotificationCenter or a separate class that would have one notification queue for each thread and be able to deliver notifications to multiple observer objects and methods
翻译如下:
首先,此对象处理的所有线程通知必须通过相同的方法(processNotification:)。第二,每个对象必须提供自己的实现和通信端口。更好但更复杂的实现将行为概括为NSNotificationCenter的一个子类或一个单独的类,每个线程有一个通知队列,并且能够向多个观察者对象和方法传递通知

其中指出更好地方式是自己去子类化一个NSNotficationCenter(github上有大佬实现了此方案,可参考GYNotificationCenter)或者单独写一个类处理这种转发。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/817502.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AD21 PCB设计的高级应用(二)PCB常见走线等长设计

&#xff08;二&#xff09;PCB常见走线等长设计 1.蛇形线的等长设计2.DDR的等长分组3.等长的拓扑结构3.1 点对点连接3.2 T型拓扑结构3.3 菊花链拓扑结构 1.蛇形线的等长设计 在 PCB 设计中,网络等长调节目的就是为了尽可能地降低信号在 PCB上传输延迟的差异。在 Altium Desig…

C语言第十三课--------初阶指针的认识--------重要部分

作者前言 &#x1f382; ✨✨✨✨✨✨&#x1f367;&#x1f367;&#x1f367;&#x1f367;&#x1f367;&#x1f367;&#x1f367;&#x1f382; &#x1f382; 作者介绍&#xff1a; &#x1f382;&#x1f382; &#x1f382;…

JavaSE类和对象(重点:this引用、构造方法)

目录 一、类的定义方式以及实例化 1.面向对象 Java是一门纯面向对象的语言(Object Oriented Program&#xff0c;简称OOP)&#xff0c;在Java的世界里一切皆为对象。 2.类的定义和使用 1.在java中定义类时需要用到class关键字 3.类的实例化 4.类实例化的使用 二、this引用 …

面试中常聊 AMS,你是否又真的了解?

在面试的时候&#xff0c;经常会被问到这些问题&#xff1a; 对Activity的启动流程了解吗&#xff1f;AMS在Android起到什么作用&#xff0c;简单分析下Android的源码system_server为什么要在Zygote中启动&#xff0c;而不是由init直接启动呢?为什么要专门使用Zygote进程去孵…

有点慌,新公司项目构建用的Gradle

入职新公司&#xff0c;构建项目的工具用的gradle&#xff0c;以前没用过&#xff0c;看到一个build.gradle&#xff0c;点进去&#xff0c;心里一句我曹&#xff0c;这写的都是些什么玩意&#xff0c;方得一批&#xff0c;赶紧去补了下课。 好吧&#xff0c;先学点语法&#…

根据选择内容自动生成正则表达式

地址: https://regex.ai/ 如何使用? 比如我这里有个需求: 提取图片路径中的文件名 https://wx4.sinaimg.cn/mw1024/0040jbadly1hg5nk0l3gtj62c0340kjl02.jpg 提取出0040jbadly1hg5nk0l3gtj62c0340kjl02.jpg 数据越多越准确 左边提供数据, 右边给出需要提取的数据, 点击run&…

地产变革中,物业等风来

2023年7月&#xff0c;也许是中国房地产行业变局中的一个大拐点。 中信建投研报表示&#xff0c;政治局会议指出当前我国房地产形势已发生重大变化&#xff0c;要适时调整优化政策&#xff0c;为行业形势定调……当前房地产行业β已至。 不久前&#xff0c;国家统计局公布了2…

Mag-Fluo-4 AM,镁离子荧光探针,是一种有用的细胞内镁离子指示剂

资料编辑|陕西新研博美生物科技有限公司小编MISSwu​ PART1----产品描述&#xff1a; 镁离子荧光探针Mag-Fluo-4 AM&#xff0c;具细胞膜渗透性&#xff0c;对镁离子&#xff08;Mg2&#xff09; 和钙离子&#xff08;Ca2&#xff09;的 Kd 值分别是 4.7mM 和 22mM&#xff0c…

运维:Multipass软件让你的虚拟机管理更简单高效

一、Multipass是什么&#xff1f; 官网&#xff1a;https://multipass.run/ 一提到虚拟机大家一般都会想到VMvare和Virtual Box这两个的虚拟机软件&#xff0c;这两个软件一个比较麻烦的地方是安装完虚拟机以后还需要下载操作系统镜像。小编偶然间发现了Multipass。这款轻量级的…

Flowable-子流程-嵌套子流程

目录 定义图形标记XML内容使用示例视频讲解 定义 内嵌子流程又叫嵌入式子流程&#xff0c;它是一个可以包含其它活动、分支、事件&#xff0c;等的活动。我们通 常意义上说的子流程通常就是指的内嵌子流程&#xff0c;它表现为将一个流程&#xff08;子流程&#xff09;定义在…

【C语言初阶(20)】调试练习题

文章目录 前言实例1实例2 前言 在我们开始调试之前&#xff0c;应该有个明确的思路&#xff1b;程序是如何完成工作的、变量到达某个步骤时的值应该是什么、出现的问题大概会在什么位置。这些东西在调试之前都需要先确认下来&#xff0c;不然自己都不知道自己在调试个什么东西…

IT服务管理学习笔记<一>

### IT服务管理知识整理 ITSM 的核心思想是&#xff0c;IT 组织&#xff0c;不管它是企业内部的还是外部的&#xff0c;都是 IT 服务提供者&#xff0c;其 主要工作就是提供低成本、高质量的 IT 服务。 ITSM 的核心思想是&#xff0c;IT 组织&#xff0c;不管它是企业内部的还…

中国农村大学生学习了这个【React教程】迎娶导师女儿,出任CEO走上人生巅峰

注&#xff1a;最后有面试挑战&#xff0c;看看自己掌握了吗 文章目录 React创建一个简单的 JSX 元素创建一个复杂的 JSX 元素在 JSX 中添加注释渲染 HTML 元素为 DOM 树 &#x1f338;I could be bounded in a nutshell and count myself a king of infinite space. 特别鸣谢…

《数据同步-NIFI系列》Nifi配置DBCPConnectionPool连接SQL Server数据库

Nifi配置DBCPConnectionPool连接SQL Server数据库 一、新增DBCPConnectionPool 在配置中新增DBCPConnectionPool&#xff0c;然后配置数据库相关信息 二、配置DBCPConnectionPool 2.1 DBCPConnectionPool介绍 主要介绍以下五个必填参数 Database Connection URL&#xff1…

简历上的项目,需要这样描述才有亮点!

作者&#xff1a;小傅哥 博客&#xff1a;https://bugstack.cn 沉淀、分享、成长&#xff0c;让自己和他人都能有所收获&#xff01;&#x1f604; 一、前言&#xff1b;豆包不是干粮 每每准备面试&#xff0c;总有些小伙子甩出自己的豆包项目&#xff0c;不是Xxx管理系统&…

绝绝子,这所211无歧视!极其保护一志愿!专硕爆冷全部录取!

一、学校及专业介绍 大连海事大学&#xff08;Dalian Maritime University&#xff09;&#xff0c;简称海大&#xff0c;位于辽宁省大连市&#xff0c;是中华人民共和国交通运输部所属的全国重点大学&#xff0c;位列国家“双一流”、“211工程”重点建设高校。 1.1 招生情况…

HJ99 自守数+OR86N 返回小于N的质数个数

HJ99 自守数 自守数_牛客题霸_牛客网 (nowcoder.com) #include <iostream> #include<cmath> using namespace std; bool Ending_Same(int a) {int a_a a * a;if (a_a a)return true;int i 1;while (a_a ! 0 && a_a/ (int)pow(10, i)!0)//保证a*a有足够…

SBFI AM(Na+Indicator),129423-53-6,可用来预测纯化线粒体Na+梯

资料编辑|陕西新研博美生物科技有限公司小编MISSwu​ SBFI AM(NaIndicator)钠离子荧光探针 PART1----​Product structure&#xff1a; PART2----​Product specifications&#xff1a; 1.CAS No&#xff1a;129423-53-6 2.Molecular formula&#xff1a;C56H58N2O23 3.Molec…

算法:HJ27 查找兄弟单词

描述 定义一个单词的“兄弟单词”为&#xff1a;交换该单词字母顺序&#xff08;注&#xff1a;可以交换任意次&#xff09;&#xff0c;而不添加、删除、修改原有的字母就能生成的单词。 兄弟单词要求和原来的单词不同。例如&#xff1a; ab 和 ba 是兄弟单词。 ab 和 ab 则…

职业发展规划指南:如何成为成功的产品经理

导语&#xff1a;产品经理是当今互联网时代最炙手可热的职位之一。作为连接技术、商业和用户需求的桥梁&#xff0c;产品经理在公司中扮演着至关重要的角色。本文将为你提供一些关于产品经理职业发展的规划指南&#xff0c;帮助你在这个领域取得成功。 掌握核心技能&#xff1…