MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / WorkerThread

Class WorkerThread

tensorflow/compiler/xla/python/worker_thread.h:31–50  ·  view source on GitHub ↗

A worker thread that runs a sequence of closures. Equivalent to a thread pool of size 1.

Source from the content-addressed store, hash-verified

29// A worker thread that runs a sequence of closures. Equivalent to a thread
30// pool of size 1.
31class WorkerThread {
32 public:
33 // 'name' is a name for the thread for debugging purposes.
34 WorkerThread(tensorflow::Env* env, const std::string& name);
35
36 // Blocks until all enqueued closures have completed.
37 ~WorkerThread();
38
39 // Adds 'fn' to the queue of closures to be executed by the worker thread.
40 void Schedule(std::function<void()> fn);
41
42 private:
43 bool WorkAvailable() TF_EXCLUSIVE_LOCKS_REQUIRED(mu_);
44 void WorkLoop();
45
46 absl::Mutex mu_;
47 std::queue<std::function<void()>> work_queue_ TF_GUARDED_BY(mu_);
48
49 std::unique_ptr<tensorflow::Thread> thread_;
50};
51
52} // namespace xla
53

Callers 3

RestoreInternalMethod · 0.85
AnnotateRequestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected