metaapi.cloud-sdk
Version:
SDK for MetaApi, a professional cloud forex API which includes MetaTrader REST API and MetaTrader websocket API. Supports both MetaTrader 5 (MT5) and MetaTrader 4 (MT4). CopyFactory copy trading API included. (https://metaapi.cloud)
49 lines (48 loc) • 1.34 kB
TypeScript
/**
* Util class to track usages of something
*/
export default class UsageCounter {
private _usages;
/**
* Acquires a usage. If already acquired by specified usage, the count won't be incremented
* @param key key to count
* @param usage usage
*/
acquire(key: string, usage: any): void;
/**
* Releases a usage. If already not acquired by specified usage, the counte won't be decremented
* @param key key to count
* @param usage usage
*/
release(key: string, usage: any): void;
/**
* Releases all usages of a key
* @param key key to release
*/
releaseAll(key: string): void;
/**
* Returns whether a key is currently in use
* @param key key to check
* @returns is in use
*/
isInUse(key: string): boolean;
/**
* Returns key usage IDs
* @param key key to count
* @returns usages
*/
getUsages(key: any): Set<any>;
/**
* Returns if key is acquired by usage
* @param key key to check
* @param usage usage
* @returns is acquired
*/
isAcquiredBy(key: string, usage: any): boolean;
/**
* Returns keys which are acquired by specific usage
* @param usage usage
* @returns keys acquired by the specified usage
*/
getAcquiredBy(usage: string): string[];
}