no message

This commit is contained in:
Peter
2016-12-23 20:32:29 +03:00
parent e141530d22
commit a907fdd030
2 changed files with 38 additions and 4 deletions

View File

@@ -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

View File

@@ -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:^{