Jim, You do need to do your own synchronization.
It's basically possible for ANY callback to call your code in any order. The API does not guarantee ordering. For example, say you launch a task, before the method returns (say you do some blocking stuff after, like sync update zookeeper), you might get a statusUpdate() callback. Effectively, you have 3 steps. 1. a list of tasks for things that are pending (not launched, not enough resources yet) 2. a list of tasks for things that have launched but not yet 'statusUpdate()' 3. a form of persistent list (zk, mysql, whatev) for things that confirm they are running if you need High Avail. On Tue, Jun 9, 2015 at 12:02 PM, James Vanns <[email protected]> wrote: > Replying to my own thread here ;) It is also possible that > resourceOffers() is called more than once before the first statusUpdate() > is received. That is more likely. > > Some links to state transitions, and any threading model would be handy > though. Or at least how and when callbacks are invoked. Just so I know what > I need to protect access to ;) > > Cheers, > > Jim > > > On 9 June 2015 at 16:58, James Vanns <[email protected]> wrote: > >> Hi. I'm toying with the mesos scheduler (C++) API and running into >> unexpected race conditions. I have *not* synchronised access to attributes >> of my Scheduler-derived class. Is the mesos library code threaded and >> network communication asynchronous? What it *looks like* I'm seeing is my >> statusUpdate() callback being executed before the return of >> resourceOffers(). Naturally I call driver->launchTasks() inside >> resourceOffers(). This is intermittent but generally triggered by tasks >> that report status changes very quickly; eg. a task that fails instantly. >> >> Can anyone point me in the right direction of any online API docs that >> explain how callbacks are invoked? Distributed over a pool of worker >> threads? >> >> Also are the state transitions documented? Eg. >> mesos::TASK_STAGING -> mesos::TASK_STARTING -> etc. >> >> Cheers, >> >> Jim >> >> -- >> Senior Code Pig >> Industrial Light & Magic >> > > > > -- > -- > Senior Code Pig > Industrial Light & Magic >

