blob: 0bb8e464ddf5e76db32db4c91a44b937debd6576 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
import Foundation
import Ice
class RetryI: Retry {
var _counter: Int32
init() {
_counter = 0
}
func op(kill: Bool, current: Ice.Current) throws {
if kill {
if let con = current.con {
try con.close(.Forcefully)
} else {
throw Ice.ConnectionLostException(error: 1)
}
}
}
func opIdempotent(c: Int32, current _: Ice.Current) throws -> Int32 {
if c < 0 {
_counter = 0
return 0
}
if c > _counter {
_counter += 1
throw Ice.ConnectionLostException(error: 1)
}
let counter = _counter
_counter = 0
return counter
}
func opNotIdempotent(current _: Ice.Current) throws {
throw Ice.ConnectionLostException(error: 1)
}
func opSystemException(current _: Ice.Current) throws {
throw Ice.RuntimeError("")
}
func sleep(delay: Int32, current _:Ice.Current) throws {
Thread.sleep(forTimeInterval: Double(delay) / 1000.0)
}
func shutdown(current: Ice.Current) {
current.adapter!.getCommunicator().shutdown()
}
}
|