1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 module hunt.pool.impl.ThrowableCallStack;
18 
19 // import java.io.PrintWriter;
20 // import java.text.DateFormat;
21 // import java.text.SimpleDateFormat;
22 
23 /**
24  * CallStack strategy that uses the stack trace from a {@link Throwable}. This strategy, while slower than the
25  * SecurityManager implementation, provides call stack method names and other metadata in addition to the call stack
26  * of classes.
27  *
28  * @see Throwable#fillInStackTrace()
29  */
30 // class ThrowableCallStack : CallStack {
31 
32 //     private string messageFormat;
33 //     //@GuardedBy("dateFormat")
34 //     private DateFormat dateFormat;
35 
36 //     // private Snapshot snapshot;
37 
38 //     /**
39 //      * Create a new instance.
40 //      *
41 //      * @param messageFormat message format
42 //      * @param useTimestamp whether to format the dates in the output message or not
43 //      */
44 //     ThrowableCallStack(string messageFormat, bool useTimestamp) {
45 //         this.messageFormat = messageFormat;
46 //         this.dateFormat = useTimestamp ? new SimpleDateFormat(messageFormat) : null;
47 //     }
48 
49 //     override
50 //     synchronized bool printStackTrace(PrintWriter writer) {
51 //         Snapshot snapshotRef = this.snapshot;
52 //         if (snapshotRef is null) {
53 //             return false;
54 //         }
55 //         string message;
56 //         if (dateFormat is null) {
57 //             message = messageFormat;
58 //         } else {
59 //             synchronized (dateFormat) {
60 //                 message = dateFormat.format(Long.valueOf(snapshotRef.timestamp));
61 //             }
62 //         }
63 //         writer.println(message);
64 //         snapshotRef.printStackTrace(writer);
65 //         return true;
66 //     }
67 
68 //     override
69 //     void fillInStackTrace() {
70 //         snapshot = new Snapshot();
71 //     }
72 
73 //     override
74 //     void clear() {
75 //         snapshot = null;
76 //     }
77 
78 //     /**
79 //      * A snapshot of a throwable.
80 //      */
81 //     private static class Snapshot : Throwable {
82 
83 //         private long timestamp = DateTimeHelper.currentTimeMillis();
84 //     }
85 // }