FiberFactory.StartNew.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Threading;
4 
5 namespace SpicyPixel.Threading
6 {
7  public partial class FiberFactory
8  {
19  public Fiber StartNew(IEnumerator coroutine)
20  {
21  return StartNew(coroutine, cancellationToken);
22  }
23 
35  public Fiber StartNew(IEnumerator coroutine, CancellationToken cancellationToken)
36  {
37  return StartNew(coroutine, cancellationToken, GetScheduler());
38  }
39 
53  public Fiber StartNew(IEnumerator coroutine, FiberScheduler scheduler)
54  {
55  return StartNew(coroutine, cancellationToken, scheduler);
56  }
57 
72  public Fiber StartNew(IEnumerator coroutine, CancellationToken cancellationToken, FiberScheduler scheduler)
73  {
74  var fiber = new Fiber(coroutine, cancellationToken);
75  fiber.Start(scheduler);
76  return fiber;
77  }
78 
89  public Fiber StartNew(Action action)
90  {
91  return StartNew(action, cancellationToken);
92  }
93 
105  public Fiber StartNew(Action action, CancellationToken cancellationToken)
106  {
107  return StartNew(action, cancellationToken, GetScheduler());
108  }
109 
123  public Fiber StartNew(Action action, FiberScheduler scheduler)
124  {
125  return StartNew(action, cancellationToken, scheduler);
126  }
127 
142  public Fiber StartNew(Action action, CancellationToken cancellationToken, FiberScheduler scheduler)
143  {
144  var fiber = new Fiber(action, cancellationToken);
145  fiber.Start(scheduler);
146  return fiber;
147  }
148 
162  public Fiber StartNew(Action<object> action, object state)
163  {
164  return StartNew(action, state, cancellationToken);
165  }
166 
181  public Fiber StartNew(Action<object> action, object state, CancellationToken cancellationToken)
182  {
183  return StartNew(action, state, cancellationToken, GetScheduler());
184  }
185 
202  public Fiber StartNew(Action<object> action, object state, FiberScheduler scheduler)
203  {
204  return StartNew(action, state, cancellationToken, scheduler);
205  }
206 
224  public Fiber StartNew(Action<object> action, object state, CancellationToken cancellationToken, FiberScheduler scheduler)
225  {
226  var fiber = new Fiber(action, state, cancellationToken);
227  fiber.Start(scheduler);
228  return fiber;
229  }
230 
237  public Fiber StartNew(Func<FiberInstruction> func)
238  {
239  return StartNew(func, cancellationToken);
240  }
241 
249  public Fiber StartNew(Func<FiberInstruction> func, CancellationToken cancellationToken)
250  {
251  return StartNew(func, cancellationToken, GetScheduler());
252  }
253 
263  public Fiber StartNew(Func<FiberInstruction> func, FiberScheduler scheduler)
264  {
265  return StartNew(func, cancellationToken, scheduler);
266  }
267 
278  public Fiber StartNew(Func<FiberInstruction> func, CancellationToken cancellationToken, FiberScheduler scheduler)
279  {
280  var fiber = new Fiber(func, cancellationToken);
281  fiber.Start(scheduler);
282  return fiber;
283  }
284 
294  public Fiber StartNew(Func<object, FiberInstruction> func, object state)
295  {
296  return StartNew(func, state, cancellationToken);
297  }
298 
309  public Fiber StartNew(Func<object, FiberInstruction> func, object state, CancellationToken cancellationToken)
310  {
311  return StartNew(func, state, cancellationToken, GetScheduler());
312  }
313 
326  public Fiber StartNew(Func<object, FiberInstruction> func, object state, FiberScheduler scheduler)
327  {
328  return StartNew(func, state, cancellationToken, scheduler);
329  }
330 
344  public Fiber StartNew(Func<object, FiberInstruction> func, object state, CancellationToken cancellationToken, FiberScheduler scheduler)
345  {
346  var fiber = new Fiber(func, state, cancellationToken);
347  fiber.Start(scheduler);
348  return fiber;
349  }
350 
351  FiberScheduler GetScheduler()
352  {
353  return scheduler ?? FiberScheduler.Current;
354  }
355  }
356 }
357 
Fiber StartNew(Func< FiberInstruction > func)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Schedules fibers for execution.
Fiber StartNew(IEnumerator coroutine)
Start executing a new fiber using the default scheduler on the thread.
A Fiber is a lightweight means of scheduling work that enables multiple units of processing to execut...
Fiber StartNew(Func< object, FiberInstruction > func, object state, CancellationToken cancellationToken, FiberScheduler scheduler)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(Func< object, FiberInstruction > func, object state)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(Action< object > action, object state, CancellationToken cancellationToken)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Func< object, FiberInstruction > func, object state, CancellationToken cancellationToken)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(Action< object > action, object state)
Start executing a new fiber using the default scheduler on the thread.
static FiberScheduler Current
Gets the default fiber scheduler for the thread.
Fiber StartNew(IEnumerator coroutine, CancellationToken cancellationToken, FiberScheduler scheduler)
Start executing a new fiber using the specified scheduler.
Fiber StartNew(Action action, CancellationToken cancellationToken, FiberScheduler scheduler)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Action< object > action, object state, CancellationToken cancellationToken, FiberScheduler scheduler)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Action action, CancellationToken cancellationToken)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(IEnumerator coroutine, FiberScheduler scheduler)
Start executing a new fiber using the specified scheduler.
Fiber StartNew(Action< object > action, object state, FiberScheduler scheduler)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Action action, FiberScheduler scheduler)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Action action)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Func< FiberInstruction > func, CancellationToken cancellationToken, FiberScheduler scheduler)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(IEnumerator coroutine, CancellationToken cancellationToken)
Start executing a new fiber using the default scheduler on the thread.
Fiber StartNew(Func< object, FiberInstruction > func, object state, FiberScheduler scheduler)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(Func< FiberInstruction > func, CancellationToken cancellationToken)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.
Fiber StartNew(Func< FiberInstruction > func, FiberScheduler scheduler)
Initializes a new instance of the SpicyPixel.Threading.Fiber class.