MCPcopy Create free account
hub / github.com/apache/thrift / ThreadFactory

Class ThreadFactory

lib/cpp/src/thrift/concurrency/ThreadFactory.h:34–70  ·  view source on GitHub ↗

* Factory to create thread object and bind them to Runnable * object for execution */

Source from the content-addressed store, hash-verified

32 * object for execution
33 */
34class ThreadFactory {
35public:
36 /**
37 * All threads created by a factory are reference-counted
38 * via std::shared_ptr. The factory guarantees that threads and the Runnable tasks
39 * they host will be properly cleaned up once the last strong reference
40 * to both is given up.
41 *
42 * By default threads are not joinable.
43 */
44 ThreadFactory(bool detached = true) : detached_(detached) { }
45
46 virtual ~ThreadFactory() = default;
47
48 /**
49 * Gets current detached mode
50 */
51 bool isDetached() const { return detached_; }
52
53 /**
54 * Sets the detached disposition of newly created threads.
55 */
56 void setDetached(bool detached) { detached_ = detached; }
57
58 /**
59 * Create a new thread.
60 */
61 virtual std::shared_ptr<Thread> newThread(std::shared_ptr<Runnable> runnable) const;
62
63 /**
64 * Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread
65 */
66 Thread::id_t getCurrentThreadId() const;
67
68private:
69 bool detached_;
70};
71
72}
73}

Callers 3

reapNThreadsMethod · 0.85
synchStartTestMethod · 0.85
floodNTestMethod · 0.85

Calls

no outgoing calls

Tested by 3

reapNThreadsMethod · 0.68
synchStartTestMethod · 0.68
floodNTestMethod · 0.68