Skip to content

Commit

Permalink
profilecollector: add listener only once
Browse files Browse the repository at this point in the history
fix documentation
  • Loading branch information
kosyloa committed Nov 14, 2023
1 parent c489cbb commit 28454ad
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 26 deletions.
38 changes: 19 additions & 19 deletions DXFeedFramework/Api/DXEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,58 +73,58 @@ public class DXEndpoint {
/// Use ``Builder/withProperty(_:_:)`` method.
/// This property is also changed by ``Builder/withName(_:)`` method.
case name = "name"
/// Defines path to a file with properties for an endpoint with role ``Role-swift.enum/feed``
/// or ``Role-swift.enum/onDemandFeed``
/// Defines path to a file with properties for an endpoint with role ``DXEndpoint/Role-swift.enum/feed``
/// or ``DXEndpoint/Role-swift.enum/onDemandFeed``
/// This file must be in the [Java properties file format](https://en.wikipedia.org/wiki/.properties) .
/// This property can also be set using ``SystemProperty/setProperty(_:_:)``,
/// as the default property for all instances ``DXEndpoint`` with ``Role-swift.enum/feed`` or
/// ``Role-swift.enum/onDemandFeed`` role.
/// as the default property for all instances ``DXEndpoint`` with ``DXEndpoint/Role-swift.enum/feed`` or
/// ``DXEndpoint/Role-swift.enum/onDemandFeed`` role.
/// When the path to this properties file not provided ``SystemProperty/setProperty(_:_:)``
/// and ``Builder/withProperty(_:_:)``,
/// the file "dxfeed.properties" loaded from current runtime directory.
/// It means that the corresponding file can be placed into the current directory with any need
/// to specify additional properties.
case properties = "dxfeed.properties"
/// Defines default connection address for an endpoint with role ``Role-swift.enum/feed``
/// or ``Role-swift.enum/onDemandFeed``.
/// Connection is established to this address by role ``Role-swift.enum/feed``
/// Defines default connection address for an endpoint with role ``DXEndpoint/Role-swift.enum/feed``
/// or ``DXEndpoint/Role-swift.enum/onDemandFeed``.
/// Connection is established to this address by role ``DXEndpoint/Role-swift.enum/feed``
/// as soon as endpoint is created.
/// By default, without this property, connection is not established until ``DXEndpoint/connect(_:)``
/// is invoked.
/// Credentials for access to premium services may be configured with ``user`` and ``password``
case address = "dxfeed.address"
/// Defines default user name for an endpoint with role ``Role-swift.enum/feed``
/// or ``Role-swift.enum/onDemandFeed``
/// Defines default user name for an endpoint with role ``DXEndpoint/Role-swift.enum/feed``
/// or ``DXEndpoint/Role-swift.enum/onDemandFeed``
case user = "dxfeed.user"
/// Defines default password for an endpoint with role
/// ``Role-swift.enum/feed`` or ``Role-swift.enum/onDemandFeed``
/// ``DXEndpoint/Role-swift.enum/feed`` or ``DXEndpoint/Role-swift.enum/onDemandFeed``
case password = "dxfeed.password"
/// Defines thread pool size for an endpoint with role ``Role-swift.enum/feed``
/// Defines thread pool size for an endpoint with role ``DXEndpoint/Role-swift.enum/feed``
/// By default, the thread pool size is equal to the number of available processors.
case threadPoolSize = "dxfeed.threadPoolSize"
/// Defines data aggregation period an endpoint with role ``Role-swift.enum/feed`` that
/// Defines data aggregation period an endpoint with role ``DXEndpoint/Role-swift.enum/feed`` that
/// limits the rate of data notifications. For example, setting the value of this property
/// to "0.1s" limits notification to once every 100ms (at most 10 per second).
case aggregationPeriod = "dxfeed.aggregationPeriod"
/// Set this property to **true** to turns on wildcard support.
/// By default, the endpoint does not support wildcards. This property is needed for ``WildcardSymbol``
/// support and for the use of "tape:..." address in ``DXPublisher``.
case wildcardEnable = "dxfeed.wildcard.enable"
/// Defines path to a file with properties for an endpoint with role ``Role-swift.enum/feed``
/// Defines path to a file with properties for an endpoint with role ``DXEndpoint/Role-swift.enum/feed``
/// This file must be in the [Java properties file format](https://en.wikipedia.org/wiki/.properties)
/// This property can also be set using ``SystemProperty/setProperty(_:_:)``
/// as the default property for all instances ``DXEndpoint`` with ``Role-swift.enum/publisher``
/// as the default property for all instances ``DXEndpoint`` with ``DXEndpoint/Role-swift.enum/publisher``
/// When the path to this properties file not provided ``SystemProperty/setProperty(_:_:)``
/// and ``Builder/withProperty(_:_:)``
/// the file "dxpublisher.properties" loaded from current runtime directory.
/// It means that the corresponding file can be placed into the current directory with any need
/// to specify additional properties.
case publisherProperties = "dxpublisher.properties"
/// Defines default connection address for an endpoint with role ``Role-swift.enum/publisher``
/// Defines default connection address for an endpoint with role ``DXEndpoint/Role-swift.enum/publisher``
/// Connection is established to this address as soon as endpoint is created.
/// By default, connection is not established until ``DXEndpoint/connect(_:)`` is invoked.
case publisherAddressProperty = "dxpublisher.address"
/// Defines thread pool size for an endpoint with role ``Role-swift.enum/publisher``
/// Defines thread pool size for an endpoint with role ``DXEndpoint/Role-swift.enum/publisher``
/// By default, the thread pool size is equal to the number of available processors.
case publisherThreadPoolSize = "dxpublisher.threadPoolSize"
/// Set this property to **true** to enable ``IEventType/eventTime``support.
Expand Down Expand Up @@ -305,7 +305,7 @@ public class DXEndpoint {
/// Closes this endpoint and wait until all pending data processing tasks are completed.
/// This method performs the same actions as close ``close()``, but also awaits
/// termination of all outstanding data processing tasks. It is designed to be used
/// with ``Role-swift.enum/streamFeed`` role after ``awaitNotConnected()`` method returns
/// with ``DXEndpoint/Role-swift.enum/streamFeed`` role after ``awaitNotConnected()`` method returns
/// to make sure that file was completely processed.
///
/// This method is blocking.
Expand Down Expand Up @@ -366,14 +366,14 @@ public class DXEndpoint {
}
/// Creates an endpoint with a role.
/// - Parameters:
/// - role: Role for endpoint. Default: ``Role-swift.enum/feed``
/// - role: Role for endpoint. Default: ``DXEndpoint/Role-swift.enum/feed``
/// - Returns: The created ``DXEndpoint`` instance.
/// - Throws: GraalException. Rethrows exception from Java.
public static func create(_ role: Role = .feed) throws -> DXEndpoint {
return try Builder().withRole(role).build()
}

/// Gets a default application-wide singleton instance of DXEndpoint with a ``Role-swift.enum/feed`` role.
/// Gets a default application-wide singleton instance of DXEndpoint with a ``DXEndpoint/Role-swift.enum/feed`` role.
/// Most applications use only a single data-source and should rely on this method to get one.
/// - Returns: Returns singleton instance of ``DXEndpoint``
/// - Throws: GraalException. Rethrows exception from Java.
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/AnalyticOrder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation
/// Represents an extension of ``Order`` introducing analytics information,
/// e.g. adding to this order iceberg related information ``icebergPeakSize``, ``IcebergHiddenSize``, ``IcebergExecutedSize``
/// e.g. adding to this order iceberg related information ``icebergPeakSize``, ``icebergHiddenSize``, ``icebergExecutedSize``
///
/// The collection of analytic order events of a symbol represents the most recent analytic information
/// that is available about orders on the market at any given moment of time.
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/Extra/OrderSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Foundation
/// Aggregate sources ``agregateBid`` and ``agregateAsk`` provide
/// futures depth (aggregated by price level) and NASDAQ Level II (top of book for each market maker).
/// These source cannot be directly published to via dxFeed API.
/// ``isPublishable(eventType:)`` sources ``defaultOrderSource``, ``NTV``, and ``ISE``
/// ``isPublishable(eventType:)`` sources ``defaultOrderSource``, ``NTV-773uf``, and ``ISE``
/// support full range of dxFeed API features.
///
///
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/Greeks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation
/// The logic behind this property is detailed in ``IIndexedEvent`` class documentation
///
/// Multiple event sources for the same symbol are not supported for greeks, thus
/// ``source`` property is always ``IndexedEventSource/defaultSource``.
/// ``eventSource`` property is always ``IndexedEventSource/defaultSource``.
///
/// Publishing Greeks
/// Publishing of greeks events follows the general rules explained in ``ITimeSeriesEvent`` class
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/Order.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
/// The collection of order events of a symbol represents the most recent information
/// that is available about orders on the market at any given moment of time.
/// Order events give information on several levels of details, called scopes - see ``Scope``.
/// Scope of an order is available via ``OrderBase.Scope``property.
/// Scope of an order is available via ``OrderBase/scope``property.
///
/// [For more details see](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/event/market/Order.html)
public class Order: OrderBase {
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/SpreadOrder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Foundation
/// Spread order is similar to a regular ``Order``, but it has a
/// ``SpreadSymbol`` property that contains the symbol
/// of the actual spread that is being represented by spread order object.
/// ``MarketEvent.EventSymbol`` property contains the underlying symbol
/// ``IEventType/eventSymbol`` property contains the underlying symbol
/// that was used in subscription.
///
/// [For more details see](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/event/market/SpreadOrder.html)
Expand Down
6 changes: 4 additions & 2 deletions DXFeedFramework/Ipf/Live/DXInstrumentProfileCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public class DXInstrumentProfileCollector {
public func add<O>(listener: O) throws
where O: DXInstrumentProfileUpdateListener,
O: Hashable {
try native.addListener(listener)
listeners.insert(listener)
if !listeners.member(listener) {
try native.addListener(listener)
listeners.insert(listener)
}
}

/// Removes listener that is notified about any updates in the set of instrument profiles.
Expand Down
6 changes: 6 additions & 0 deletions DXFeedFramework/Utils/ConcurrentWeakHashTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public class ConcurrentWeakHashTable<T> {
writer { $0.removeAllObjects() }
}

public func member(_ newMember: T) -> Bool {
return reader {
return $0.member(newMember as AnyObject) != nil
}
}

public func reader<U>(_ block: (NSHashTable<AnyObject>) throws -> U) rethrows -> U {
try accessQueue.sync { try block(set) }
}
Expand Down
2 changes: 2 additions & 0 deletions DXFeedFrameworkTests/IPFTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY
wait(seconds: 1)
try collector.add(listener: listener)
try collector.add(listener: listener2)
try collector.add(listener: listener)

wait(for: [expectation1, expectation2], timeout: 2.0)
collector.remove(listener: listener2)
try collector.updateInstrumentProfile(profile: firstListnerProfile)
Expand Down

0 comments on commit 28454ad

Please sign in to comment.