Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
ab.ThreadRunner Class Reference

Public Member Functions

def __init__ (self, args)
 
def add (self, args, fn)
 
def wait (self)
 

Public Attributes

 concise
 
 threads
 

Detailed Description

Simplest and stupidiest threaded executer.

Definition at line 145 of file ab.py.

Constructor & Destructor Documentation

◆ __init__()

def ab.ThreadRunner.__init__ (   self,
  args 
)

Definition at line 147 of file ab.py.

147 def __init__(self, args):
148 self.concise = args.concise
149 self.threads = []
150

Member Function Documentation

◆ add()

def ab.ThreadRunner.add (   self,
  args,
  fn 
)

Definition at line 151 of file ab.py.

151 def add(self, args, fn):
152 if len(self.threads) >= args.threads:
153 self.wait()
154 t = ThreadWithException(target = fn)
155 t.daemon = True
156 self.threads.append(t)
157 t.start()
158
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition: editor.cpp:211

◆ wait()

def ab.ThreadRunner.wait (   self)

Definition at line 159 of file ab.py.

159 def wait(self):
160 def spin():
161 i = 0
162 spinners = [". ", ".. ", "..."]
163 while len(self.threads) > 0:
164 timesLock.acquire()
165 sys.stderr.write(
166 "\r" + spinners[i % len(spinners)] +
167 " (%d threads running)" % len(self.threads) +
168 " \r" # spaces for erasing characters
169 )
170 timesLock.release()
171 time.sleep(0.5)
172 i += 1
173
174 if not self.concise:
175 ts = Thread(target = spin);
176 ts.start()
177
178 for t in self.threads:
179 t.join()
180
181 exceptions = []
182 for t in self.threads:
183 if t.exception:
184 exceptions.append(t.exception)
185
186 self.threads = []
187
188 if not self.concise:
189 ts.join()
190
191 if len(exceptions):
192 for exc in exceptions:
193 print(exc)
194 raise exceptions[0]
195
196
def print(*args, **kwargs)
Definition: run_tests.py:49
static sk_sp< SkColorFilter > spin(sk_sp< SkColorFilter > cf)

Member Data Documentation

◆ concise

ab.ThreadRunner.concise

Definition at line 148 of file ab.py.

◆ threads

ab.ThreadRunner.threads

Definition at line 149 of file ab.py.


The documentation for this class was generated from the following file: