mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-22 03:58:47 +00:00
no message
This commit is contained in:
@@ -27,6 +27,9 @@ typedef struct {
|
||||
- (void)addIncomingBytes:(NSUInteger)incomingBytes interface:(MTNetworkUsageManagerInterface)interface;
|
||||
- (void)addOutgoingBytes:(NSUInteger)outgoingBytes interface:(MTNetworkUsageManagerInterface)interface;
|
||||
|
||||
- (void)resetIncomingBytes:(MTNetworkUsageManagerInterface)interface;
|
||||
- (void)resetOutgoingBytes:(MTNetworkUsageManagerInterface)interface;
|
||||
|
||||
- (MTSignal *)currentStats;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
#import "MTNetworkUsageManager.h"
|
||||
|
||||
#import "MTNetworkUsageCalculationInfo.h"
|
||||
#import "MTTimer.h"
|
||||
#import "MTQueue.h"
|
||||
#import "MTSignal.h"
|
||||
#include <sys/mman.h>
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#if defined(MtProtoKitDynamicFramework)
|
||||
# import <MTProtoKitDynamic/MTNetworkUsageCalculationInfo.h>
|
||||
# import <MTProtoKitDynamic/MTSignal.h>
|
||||
# import <MTProtoKitDynamic/MTTimer.h>
|
||||
# import <MTProtoKitDynamic/MTQueue.h>
|
||||
#elif defined(MtProtoKitMacFramework)
|
||||
# import <MTProtoKitMac/MTNetworkUsageCalculationInfo.h>
|
||||
# import <MTProtoKitMac/MTSignal.h>
|
||||
# import <MTProtoKitMac/MTTimer.h>
|
||||
# import <MTProtoKitMac/MTQueue.h>
|
||||
#else
|
||||
# import <MTProtoKit/MTNetworkUsageCalculationInfo.h>
|
||||
# import <MTProtoKit/MTSignal.h>
|
||||
# import <MTProtoKit/MTTimer.h>
|
||||
# import <MTProtoKit/MTQueue.h>
|
||||
#endif
|
||||
|
||||
@implementation MTNetworkUsageManagerStats
|
||||
|
||||
- (instancetype)initWithWWAN:(MTNetworkUsageManagerInterfaceStats)wwan other:(MTNetworkUsageManagerInterfaceStats)other {
|
||||
@@ -95,6 +108,24 @@ static int interfaceOffset(MTNetworkUsageManagerInterface interface) {
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resetIncomingBytes:(MTNetworkUsageManagerInterface)interface {
|
||||
[_queue dispatchOnQueue:^{
|
||||
if (_map) {
|
||||
int64_t *ptr = (int64_t *)(_map + 0 * 16 + interfaceOffset(interface));
|
||||
*ptr = 0;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resetOutgoingBytes:(MTNetworkUsageManagerInterface)interface {
|
||||
[_queue dispatchOnQueue:^{
|
||||
if (_map) {
|
||||
int64_t *ptr = (int64_t *)(_map + 1 * 16 + interfaceOffset(interface));
|
||||
*ptr = 0;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (MTSignal *)currentStats {
|
||||
return [[MTSignal alloc] initWithGenerator:^id<MTDisposable>(MTSubscriber *subscriber) {
|
||||
[_queue dispatchOnQueue:^{
|
||||
|
||||
Reference in New Issue
Block a user